Commit c7d8661b authored by Claes Sjofors's avatar Claes Sjofors

Xtt display values as hex, octal, binary etc (refs #14)

parent fc301adb
...@@ -1554,6 +1554,7 @@ open trend <t>Open DsTrend or PlotGroup graph <LINK> open trend ...@@ -1554,6 +1554,7 @@ open trend <t>Open DsTrend or PlotGroup graph <LINK> open trend
read object <t>Read the content of an object from file <LINK> read object read object <t>Read the content of an object from file <LINK> read object
search <t>Search for an object or a string <LINK> search search <t>Search for an object or a string <LINK> search
set advanceduser<t>Set advanced user <LINK> set advanceduser set advanceduser<t>Set advanced user <LINK> set advanceduser
set display<t>Set format of display for selected attribute <LINK> set display
set folder <t>Set a folder in a tabbed window. <LINK> set folder set folder <t>Set a folder in a tabbed window. <LINK> set folder
set parameter<t>Set the value of an attribute <LINK> set parameter set parameter<t>Set the value of an attribute <LINK> set parameter
set subwindow<t>View a graph in a Ge window object. <LINK> set subwindow set subwindow<t>View a graph in a Ge window object. <LINK> set subwindow
...@@ -2227,6 +2228,25 @@ Set or reset advanced user. ...@@ -2227,6 +2228,25 @@ Set or reset advanced user.
advanced user <LINK> advanced user advanced user <LINK> advanced user
</TOPIC> </TOPIC>
<TOPIC> set display <style> function
Command set display
Set format for display of the selected attribute. The attribute can
be displayed as decimal, hexadecimal, octal, binary, integer or float.
Object identities and attribute references can be displayed
as identity.
<B>xtt> set display default
<B>xtt> set display hexdecimal
<B>xtt> set display decimal
<B>xtt> set display octal
<B>xtt> set display binary
<B>xtt> set display integer
<B>xtt> set display float
<B>xtt> set display identity
</TOPIC>
<TOPIC> setup <style> function <TOPIC> setup <style> function
Xtt setup Xtt setup
Setup of xtt properies Setup of xtt properies
......
...@@ -1563,6 +1563,7 @@ open operatorwindow<t> ...@@ -1563,6 +1563,7 @@ open operatorwindow<t>
read object <t>Läs innehållet av ett objekt från fil <LINK> read object read object <t>Läs innehållet av ett objekt från fil <LINK> read object
search <t>Leta efter objekt eller sträng <LINK> search search <t>Leta efter objekt eller sträng <LINK> search
set advanceduser<t>Sätt avancerad användare <LINK> set advanceduser set advanceduser<t>Sätt avancerad användare <LINK> set advanceduser
set display<t>Sätt format for visning av utvalt attribut <LINK> set display
set folder <t>Aktivera en flik i ett flikfönster. <LINK> set folder set folder <t>Aktivera en flik i ett flikfönster. <LINK> set folder
set parameter<t>Sätt värdet på ett attribut <LINK> set parameter set parameter<t>Sätt värdet på ett attribut <LINK> set parameter
set subwindow<t>Visa in graf i ett Ge window objekt. <LINK> set subwindow set subwindow<t>Visa in graf i ett Ge window objekt. <LINK> set subwindow
...@@ -2189,6 +2190,25 @@ S ...@@ -2189,6 +2190,25 @@ S
advanced user <LINK> advanced user advanced user <LINK> advanced user
</TOPIC> </TOPIC>
<TOPIC> set display <style> function
Command set display
Sätt format for visning av utvalt attribut. Ett attribut kan visas
som decimalt, hexadecimalt, oktalt, binärt, eller som heltal eller
flyttal. Objektidentiteter och attribut-referenser kan visas som
identiteter.
<B>xtt> set display default
<B>xtt> set display hexdecimal
<B>xtt> set display decimal
<B>xtt> set display octal
<B>xtt> set display binary
<B>xtt> set display integer
<B>xtt> set display float
<B>xtt> set display identity
</TOPIC>
<TOPIC> setup <style> function <TOPIC> setup <style> function
Xtt setup Xtt setup
Unställning av xtt egenskaper. Unställning av xtt egenskaper.
......
...@@ -755,9 +755,13 @@ static const pwr_tDeltaTime pwr_cNDeltaTime = {0, 0}; //!< Zero deltatime consta ...@@ -755,9 +755,13 @@ static const pwr_tDeltaTime pwr_cNDeltaTime = {0, 0}; //!< Zero deltatime consta
#if (defined OS_POSIX) && defined HW_X86_64 #if (defined OS_POSIX) && defined HW_X86_64
# define pwr_dFormatUInt64 "%lu" # define pwr_dFormatUInt64 "%lu"
# define pwr_dFormatInt64 "%ld" # define pwr_dFormatInt64 "%ld"
# define pwr_dFormatHexInt64 "%lx"
# define pwr_dFormatOctInt64 "%lo"
#else #else
# define pwr_dFormatUInt64 "%llu" # define pwr_dFormatUInt64 "%llu"
# define pwr_dFormatInt64 "%lld" # define pwr_dFormatInt64 "%lld"
# define pwr_dFormatHexInt64 "%llx"
# define pwr_dFormatOctInt64 "%llo"
#endif #endif
/*@}*/ /*@}*/
......
...@@ -595,6 +595,7 @@ cdh_AttrValueToString ( ...@@ -595,6 +595,7 @@ cdh_AttrValueToString (
strncpy(String, sval, MaxSize); strncpy(String, sval, MaxSize);
return sts; return sts;
} }
//! Converts an attribute value given as a text string, to internal binary format. //! Converts an attribute value given as a text string, to internal binary format.
...@@ -872,6 +873,29 @@ cdh_StringToAttrValue ( ...@@ -872,6 +873,29 @@ cdh_StringToAttrValue (
return sts; return sts;
} }
//! Converts a bitmask to a binary string.
char *cdh_MaskToBinaryString(
unsigned int mask,
int noofbits
)
{
static char str[80];
unsigned int m;
int i;
m = 1 << (noofbits - 1);
strcpy( str, "");
for ( i = 0; i < noofbits; i++) {
if ( m & mask)
strcat( str, "1");
else
strcat( str, "0");
m >>= 1;
}
return str;
}
//! Convert ClassId string to id. //! Convert ClassId string to id.
/*! /*!
......
...@@ -867,6 +867,11 @@ cdh_StringToAttrValue ( ...@@ -867,6 +867,11 @@ cdh_StringToAttrValue (
void *Value void *Value
); );
char *cdh_MaskToBinaryString(
unsigned int mask,
int noofbits
);
pwr_tStatus pwr_tStatus
cdh_StringToClassId ( cdh_StringToClassId (
const char *s, const char *s,
......
...@@ -324,24 +324,6 @@ static int dyn_get_typeid( char *format) ...@@ -324,24 +324,6 @@ static int dyn_get_typeid( char *format)
return pwr_eType_Int32; return pwr_eType_Int32;
} }
// Convert a bitmask to binary string
static char *dyn_mask_to_bits( unsigned int value, int noofbits)
{
static char str[40];
unsigned int m;
m = 1 << (noofbits - 1);
strcpy( str, "");
for ( int i = 0; i < noofbits; i++) {
if ( m & value)
strcat( str, "1");
else
strcat( str, "0");
m >>= 1;
}
return str;
}
// Replace " to \" // Replace " to \"
char *GeDyn::cmd_cnv( char *instr) char *GeDyn::cmd_cnv( char *instr)
...@@ -3981,9 +3963,9 @@ int GeValue::scan( grow_tObject object) ...@@ -3981,9 +3963,9 @@ int GeValue::scan( grow_tObject object)
switch ( format[strlen(format)-1]) { switch ( format[strlen(format)-1]) {
case 'b': case 'b':
if ( strncmp( &format[1], "16", 2) == 0) if ( strncmp( &format[1], "16", 2) == 0)
strcpy( buf, dyn_mask_to_bits( val, 16)); strcpy( buf, cdh_MaskToBinaryString( val, 16));
else else
strcpy( buf, dyn_mask_to_bits( val, 32)); strcpy( buf, cdh_MaskToBinaryString( val, 32));
len = strlen(buf); len = strlen(buf);
break; break;
default: { default: {
......
...@@ -148,7 +148,7 @@ int XAttOneGtk::change_value( int set_focus) ...@@ -148,7 +148,7 @@ int XAttOneGtk::change_value( int set_focus)
if ( atype == pwr_eType_Text) if ( atype == pwr_eType_Text)
value = aval; value = aval;
else { else {
XNav::attrvalue_to_string( atype, atype, &aval, buf, sizeof(buf), &len, NULL); XNav::attrvalue_to_string( atype, atype, &aval, buf, sizeof(buf), &len, NULL, 0);
value = buf; value = buf;
} }
......
...@@ -766,7 +766,7 @@ ItemAttr::ItemAttr( XNavBrow *brow, pwr_tObjid item_objid, ...@@ -766,7 +766,7 @@ ItemAttr::ItemAttr( XNavBrow *brow, pwr_tObjid item_objid,
int attr_size, int attr_flags, int attr_size, int attr_flags,
int item_is_root, item_eDisplayType item_display_type) : int item_is_root, item_eDisplayType item_display_type) :
ItemBaseAttr( item_objid, attr_name, ItemBaseAttr( item_objid, attr_name,
attr_type_id, attr_tid, attr_size, attr_flags, item_is_root, item_display_type) attr_type_id, attr_tid, attr_size, attr_flags, item_is_root, item_display_type)
{ {
pwr_tOName obj_name; pwr_tOName obj_name;
pwr_tAName annot; pwr_tAName annot;
...@@ -829,7 +829,7 @@ ItemAttr::ItemAttr( XNavBrow *brow, pwr_tObjid item_objid, ...@@ -829,7 +829,7 @@ ItemAttr::ItemAttr( XNavBrow *brow, pwr_tObjid item_objid,
strcat( aname, attr_name); strcat( aname, attr_name);
sts = gdh_GetObjectInfo( aname, buff, size); sts = gdh_GetObjectInfo( aname, buff, size);
((XNav *)brow->userdata)->attrvalue_to_string( type_id, tid, buff, str, sizeof(str), &len, NULL); ((XNav *)brow->userdata)->attrvalue_to_string( type_id, tid, buff, str, sizeof(str), &len, NULL, 0);
brow_SetAnnotation( node, 1, str, len); brow_SetAnnotation( node, 1, str, len);
} }
else else
......
...@@ -131,6 +131,7 @@ class Item { ...@@ -131,6 +131,7 @@ class Item {
virtual int open_crossref( XNavBrow *brow, double x, double y) virtual int open_crossref( XNavBrow *brow, double x, double y)
{ return 1;} { return 1;}
virtual void close( XNavBrow *brow, double x, double y) {} virtual void close( XNavBrow *brow, double x, double y) {}
virtual void set_conversion( xnav_eConv c) {}
xnav_eItemType type; xnav_eItemType type;
pwr_tObjid objid; pwr_tObjid objid;
...@@ -142,28 +143,34 @@ class Item { ...@@ -142,28 +143,34 @@ class Item {
class ItemBaseAttr : public Item { class ItemBaseAttr : public Item {
public: public:
ItemBaseAttr( pwr_tObjid item_objid, ItemBaseAttr( pwr_tObjid item_objid,
char *attr_name, int attr_type_id, pwr_tTid attr_tid, char *attr_name, int attr_type_id, pwr_tTid attr_tid,
int attr_size, int attr_flags, int attr_size, int attr_flags,
int item_is_root, item_eDisplayType item_display_type) : int item_is_root, item_eDisplayType item_display_type) :
Item( item_objid, item_is_root), Item( item_objid, item_is_root),
type_id(attr_type_id), tid(attr_tid), size(attr_size), flags(attr_flags), type_id(attr_type_id), tid(attr_tid), size(attr_size), flags(attr_flags),
subid(pwr_cNSubid), first_scan(1), display_type(item_display_type) subid(pwr_cNSubid), first_scan(1), display_type(item_display_type),
{ strcpy( attr, attr_name); conversion(xnav_eConv_No)
memset( old_value, 0, sizeof(old_value)); { strcpy( attr, attr_name);
noedit = flags & PWR_MASK_PRIVATE ? 1 : 0;}; memset( old_value, 0, sizeof(old_value));
virtual int open_children( XNavBrow *brow, double x, double y); noedit = flags & PWR_MASK_PRIVATE ? 1 : 0;};
virtual void close( XNavBrow *brow, double x, double y); virtual int open_children( XNavBrow *brow, double x, double y);
virtual void close( XNavBrow *brow, double x, double y);
int type_id; virtual void set_conversion( xnav_eConv c) {
pwr_tTid tid; conversion = c;
int size; memset(old_value,-99,sizeof(old_value));
int flags; }
pwr_tSubid subid;
char old_value[80]; int type_id;
int first_scan; pwr_tTid tid;
pwr_tOName attr; int size;
item_eDisplayType display_type; int flags;
int noedit; pwr_tSubid subid;
char old_value[80];
int first_scan;
pwr_tOName attr;
item_eDisplayType display_type;
int noedit;
xnav_eConv conversion;
}; };
class ItemHeader : public Item { class ItemHeader : public Item {
......
...@@ -603,7 +603,8 @@ int XAttNav::trace_scan_bc( brow_tObject object, void *p) ...@@ -603,7 +603,8 @@ int XAttNav::trace_scan_bc( brow_tObject object, void *p)
else else
item->first_scan = 0; item->first_scan = 0;
XNav::attrvalue_to_string( item->type_id, item->tid, p, buf, sizeof(buf), &len, NULL); XNav::attrvalue_to_string( item->type_id, item->tid, p, buf, sizeof(buf), &len, NULL,
item->conversion);
brow_SetAnnotation( object, 1, buf, len); brow_SetAnnotation( object, 1, buf, len);
memcpy( item->old_value, p, min(item->size, (int) sizeof(item->old_value))); memcpy( item->old_value, p, min(item->size, (int) sizeof(item->old_value)));
break; break;
......
This diff is collapsed.
...@@ -165,6 +165,17 @@ typedef enum { ...@@ -165,6 +165,17 @@ typedef enum {
menu_ePixmap_Leaf menu_ePixmap_Leaf
} menu_ePixmap; } menu_ePixmap;
typedef enum {
xnav_eConv_No,
xnav_eConv_Hex,
xnav_eConv_Decimal,
xnav_eConv_Binary,
xnav_eConv_Octal,
xnav_eConv_Integer,
xnav_eConv_Float,
xnav_eConv_Identity
} xnav_eConv;
typedef struct { typedef struct {
char title[80]; char title[80];
int item_type; int item_type;
...@@ -414,6 +425,7 @@ class XNav { ...@@ -414,6 +425,7 @@ class XNav {
int get_select_all( pwr_sAttrRef **attrref, int **is_attr); int get_select_all( pwr_sAttrRef **attrref, int **is_attr);
int get_all_objects( pwr_sAttrRef **attrref, int **is_attr); int get_all_objects( pwr_sAttrRef **attrref, int **is_attr);
int get_all_collect_objects( pwr_sAttrRef **attrref, int **is_attr); int get_all_collect_objects( pwr_sAttrRef **attrref, int **is_attr);
void set_select_conversion( xnav_eConv conv);
int collect_insert( pwr_sAttrRef *attrref); int collect_insert( pwr_sAttrRef *attrref);
int collect_remove(); int collect_remove();
int collect_show(); int collect_show();
...@@ -468,7 +480,7 @@ class XNav { ...@@ -468,7 +480,7 @@ class XNav {
static int attr_string_to_value( int type_id, char *value_str, static int attr_string_to_value( int type_id, char *value_str,
void *buffer_ptr, int buff_size, int attr_size); void *buffer_ptr, int buff_size, int attr_size);
static void attrvalue_to_string( int type_id, pwr_tTid tid, void *value_ptr, static void attrvalue_to_string( int type_id, pwr_tTid tid, void *value_ptr,
char *str, int size, int *len, char *format); char *str, int size, int *len, char *format, int conv);
static void trace_subwindow_cb( void *ctx, pwr_tObjid objid); static void trace_subwindow_cb( void *ctx, pwr_tObjid objid);
static void trace_display_object_cb( void *ctx, pwr_tObjid objid); static void trace_display_object_cb( void *ctx, pwr_tObjid objid);
static int is_authorized_cb( void *xnav, unsigned int access); static int is_authorized_cb( void *xnav, unsigned int access);
......
...@@ -884,6 +884,40 @@ static int xnav_set_func( void *client_data, ...@@ -884,6 +884,40 @@ static int xnav_set_func( void *client_data,
char c; char c;
c = *p; c = *p;
} }
else if ( cdh_NoCaseStrncmp( arg1_str, "DISPLAY", strlen( arg1_str)) == 0)
{
// Command is "SET DISPLAY"
xnav_eConv conv;
char arg2_str[80];
if ( EVEN( dcli_get_qualifier( "dcli_arg2", arg2_str, sizeof(arg2_str)))) {
xnav->message('E',"Syntax error");
return 1;
}
if ( cdh_NoCaseStrncmp( arg2_str, "HEXADECIMAL", strlen( arg2_str)) == 0)
conv = xnav_eConv_Hex;
else if ( cdh_NoCaseStrncmp( arg2_str, "DECIMAL", strlen( arg2_str)) == 0)
conv = xnav_eConv_Decimal;
else if ( cdh_NoCaseStrncmp( arg2_str, "OCTAL", strlen( arg2_str)) == 0)
conv = xnav_eConv_Octal;
else if ( cdh_NoCaseStrncmp( arg2_str, "BINARY", strlen( arg2_str)) == 0)
conv = xnav_eConv_Binary;
else if ( cdh_NoCaseStrncmp( arg2_str, "FLOAT", strlen( arg2_str)) == 0)
conv = xnav_eConv_Float;
else if ( cdh_NoCaseStrncmp( arg2_str, "INTEGER", strlen( arg2_str)) == 0)
conv = xnav_eConv_Integer;
else if ( cdh_NoCaseStrncmp( arg2_str, "IDENTITY", strlen( arg2_str)) == 0)
conv = xnav_eConv_Identity;
else if ( cdh_NoCaseStrncmp( arg2_str, "DEFAULT", strlen( arg2_str)) == 0)
conv = xnav_eConv_No;
else {
xnav->message('E',"Syntax error");
return 1;
}
xnav->set_select_conversion( conv);
}
else else
xnav->message('E',"Syntax error"); xnav->message('E',"Syntax error");
return 1; return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment