Commit c4978f69 authored by Claes Sjofors's avatar Claes Sjofors

Profinet configurator, sorting of moduletypes and iodata length settings

parent 5964a7aa
......@@ -137,6 +137,27 @@ void GsdmlAttrGtk::activate_change_value( GtkWidget *w, gpointer data)
attr->change_value();
}
void GsdmlAttrGtk::activate_ordermoduletype_default( GtkWidget *w, gpointer data)
{
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
attr->activate_ordermoduletype(attr_eOrderModuleType_Default);
}
void GsdmlAttrGtk::activate_ordermoduletype_name( GtkWidget *w, gpointer data)
{
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
attr->activate_ordermoduletype( attr_eOrderModuleType_Name);
}
void GsdmlAttrGtk::activate_ordermoduletype_number( GtkWidget *w, gpointer data)
{
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
attr->activate_ordermoduletype( attr_eOrderModuleType_Number);
}
void GsdmlAttrGtk::activate_exit( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
......@@ -408,8 +429,33 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
gtk_widget_add_accelerator( menubutton_changevalue, "activate", accel_g,
'q', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
// Submenu Order module type
GSList *radio_group = NULL;
GtkWidget *func_ordermoduletype_default = gtk_radio_menu_item_new_with_mnemonic( radio_group, "_Default");
radio_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(func_ordermoduletype_default));
g_signal_connect( func_ordermoduletype_default, "activate",
G_CALLBACK(activate_ordermoduletype_default), this);
GtkWidget *func_ordermoduletype_name = gtk_radio_menu_item_new_with_mnemonic( radio_group, "By _name");
radio_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(func_ordermoduletype_name));
g_signal_connect( func_ordermoduletype_name, "activate",
G_CALLBACK(activate_ordermoduletype_name), this);
GtkWidget *func_ordermoduletype_number = gtk_radio_menu_item_new_with_mnemonic( radio_group, "By n_umber");
radio_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(func_ordermoduletype_number));
g_signal_connect( func_ordermoduletype_number, "activate",
G_CALLBACK(activate_ordermoduletype_number), this);
GtkWidget *func_ordermoduletype = gtk_menu_item_new_with_mnemonic( "_Order ModuleType");
GtkMenu *func_ordermoduletype_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_ordermoduletype_menu), func_ordermoduletype_default);
gtk_menu_shell_append(GTK_MENU_SHELL(func_ordermoduletype_menu), func_ordermoduletype_name);
gtk_menu_shell_append(GTK_MENU_SHELL(func_ordermoduletype_menu), func_ordermoduletype_number);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(func_ordermoduletype),GTK_WIDGET(func_ordermoduletype_menu));
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), menubutton_changevalue);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), func_ordermoduletype);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic("_Functions");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
......
......@@ -80,6 +80,9 @@ class GsdmlAttrGtk : public GsdmlAttr {
static void gsdnkattr_message( void *attr, char severity, char *message);
static void gsdmlattr_change_value_cb( void *attr_ctx);
static void activate_change_value( GtkWidget *w, gpointer data);
static void activate_ordermoduletype_default( GtkWidget *w, gpointer data);
static void activate_ordermoduletype_name( GtkWidget *w, gpointer data);
static void activate_ordermoduletype_number( GtkWidget *w, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_copy( GtkWidget *w, gpointer data);
......
......@@ -91,6 +91,11 @@ void GsdmlAttr::activate_exit()
delete this;
}
void GsdmlAttr::activate_ordermoduletype( attr_eOrderModuleType type)
{
attrnav->set_order_moduletype( type);
}
void GsdmlAttr::activate_help()
{
int sts;
......
......@@ -54,6 +54,12 @@ typedef struct {
int mask;
} attr_sItem;
typedef enum {
attr_eOrderModuleType_Default,
attr_eOrderModuleType_Name,
attr_eOrderModuleType_Number
} attr_eOrderModuleType;
class GsdmlAttrNav;
class CoWow;
......@@ -87,6 +93,7 @@ class GsdmlAttr {
virtual void set_prompt( const char *prompt) {}
virtual void change_value() {}
void activate_ordermoduletype( attr_eOrderModuleType type);
void activate_exit();
void activate_help();
void activate_copy();
......
......@@ -469,7 +469,8 @@ GsdmlAttrNav::GsdmlAttrNav(
parent_ctx(xn_parent_ctx),
gsdml(xn_gsdml), edit_mode(xn_edit_mode), trace_started(0),
message_cb(0), change_value_cb(0), device_num(0), device_item(0),
device_confirm_active(0), device_read(0), viewio(0), time_ratio(1), send_clock(32), phase(1)
device_confirm_active(0), device_read(0), viewio(0), time_ratio(1), send_clock(32), phase(1),
order_moduletype( attr_eOrderModuleType_Default)
{
strcpy( name, xn_name);
......@@ -1712,9 +1713,8 @@ int GsdmlAttrNav::save( const char *filename)
for ( unsigned int j = 0; j < dev_data.slot_data[i]->subslot_data.size(); j++) {
GsdmlSubslotData *ssd = dev_data.slot_data[i]->subslot_data[j];
ssd->io_input_length = 0;
ssd->io_output_length = 0;
unsigned int io_input_length = 0;
unsigned int io_output_length = 0;
gsdml_VirtualSubmoduleItem *vsd = 0;
if ( ssd->submodule_enum_number) {
......@@ -1760,8 +1760,12 @@ int GsdmlAttrNav::save( const char *filename)
sts = gsdml->get_datavalue_length( datatype, di->Body.Length, &len);
if ( EVEN(sts)) printf( "GSDML-Error, Datatype %s not yet implemented\n", di->Body.DataType);
ssd->io_input_length += len;
io_input_length += len;
}
if ( ssd->io_input_length == 0)
ssd->io_input_length = io_input_length;
else if ( ssd->io_input_length > io_input_length)
ssd->io_input_length = io_input_length;
}
if ( vsd->IOData->Output) {
for ( unsigned k = 0; k < vsd->IOData->Output->DataItem.size(); k++) {
......@@ -1775,8 +1779,12 @@ int GsdmlAttrNav::save( const char *filename)
sts = gsdml->get_datavalue_length( datatype, di->Body.Length, &len);
if ( EVEN(sts)) printf( "GSDML-Error, Datatype %s not yet implemented\n", di->Body.DataType);
ssd->io_output_length += len;
io_output_length += len;
}
if ( ssd->io_output_length == 0)
ssd->io_output_length = io_output_length;
else if ( ssd->io_output_length > io_output_length)
ssd->io_output_length = io_output_length;
}
}
}
......@@ -2097,6 +2105,7 @@ ItemPnEnumValueMType::ItemPnEnumValueMType( GsdmlAttrNav *attrnav, const char *i
type = attrnav_eItemType_PnEnumValueMType;
strcpy( name, item_name);
strcpy( number, item_number);
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_enum_mtype,
dest, dest_code, (void *) this, 1, &node);
......@@ -2336,7 +2345,7 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[0],
mi->VirtualSubmoduleList->VirtualSubmoduleItem[0], slotdata->slot_idx,
node, flow_eDest_IntoLast);
}
......@@ -2373,7 +2382,7 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i],
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i], slotdata->slot_idx,
node, flow_eDest_IntoLast);
subslot_index++;
}
......@@ -2462,7 +2471,7 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
}
new ItemPnSubslot( attrnav, subslot_name, ssd, fixed_si,
new ItemPnSubslot( attrnav, subslot_name, ssd, fixed_si, slotdata->slot_idx,
node, flow_eDest_IntoLast);
subslot_index++;
}
......@@ -2546,9 +2555,9 @@ int ItemPnSlot::scan( GsdmlAttrNav *attrnav, void *p)
ItemPnSubslot::ItemPnSubslot( GsdmlAttrNav *attrnav, const char *item_name,
GsdmlSubslotData *item_subslotdata,
gsdml_VirtualSubmoduleItem *item_virtualsubmodule,
gsdml_VirtualSubmoduleItem *item_virtualsubmodule, int item_slot_idx,
brow_tNode dest, flow_eDest dest_code) :
subslotdata(item_subslotdata), virtualsubmodule(item_virtualsubmodule)
subslotdata(item_subslotdata), virtualsubmodule(item_virtualsubmodule), slot_idx(item_slot_idx)
{
type = attrnav_eItemType_PnSubslot;
......@@ -2616,7 +2625,7 @@ int ItemPnSubslot::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
if ( attrnav->viewio && virtualsubmodule->IOData) {
new ItemPnIOData( attrnav, "IOData", virtualsubmodule->IOData,
new ItemPnIOData( attrnav, "IOData", virtualsubmodule->IOData, subslotdata->subslot_idx, slot_idx,
node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
......@@ -2715,7 +2724,7 @@ int ItemPnSubslotPhys::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
if ( attrnav->viewio && subm && subm->IOData) {
new ItemPnIOData( attrnav, "IOData", subm->IOData,
new ItemPnIOData( attrnav, "IOData", subm->IOData, subslotdata->subslot_idx, slot_idx,
node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
......@@ -2807,7 +2816,7 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[0],
mi->VirtualSubmoduleList->VirtualSubmoduleItem[0], slotdata->slot_idx,
node, flow_eDest_IntoLast);
subslot_index++;
......@@ -2844,7 +2853,7 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i],
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i], slotdata->slot_idx,
node, flow_eDest_IntoLast);
subslot_index++;
}
......@@ -3404,6 +3413,32 @@ ItemPnModuleType::ItemPnModuleType( GsdmlAttrNav *attrnav, const char *item_name
brow_SetTraceAttr( node, name, "", flow_eTraceType_User);
}
static int gsdml_comp_nodes_name( const void *n1, const void *n2)
{
ItemPnEnumValueMType *item1;
ItemPnEnumValueMType *item2;
brow_tObject o1 = *(brow_tObject *)n1;
brow_tObject o2 = *(brow_tObject *)n2;
brow_GetUserData( o1, (void **)&item1);
brow_GetUserData( o2, (void **)&item2);
return strcmp( item1->name, item2->name);
}
static int gsdml_comp_nodes_number( const void *n1, const void *n2)
{
ItemPnEnumValueMType *item1;
ItemPnEnumValueMType *item2;
brow_tObject o1 = *(brow_tObject *)n1;
brow_tObject o2 = *(brow_tObject *)n2;
brow_GetUserData( o1, (void **)&item1);
brow_GetUserData( o2, (void **)&item2);
return strcmp( item1->number, item2->number);
}
int ItemPnModuleType::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
......@@ -3460,6 +3495,18 @@ int ItemPnModuleType::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
idx++;
}
// Sort
switch ( attrnav->order_moduletype) {
case attr_eOrderModuleType_Name:
brow_SortChildren( attrnav->brow->ctx, node, 1, gsdml_comp_nodes_name);
break;
case attr_eOrderModuleType_Number:
brow_SortChildren( attrnav->brow->ctx, node, 1, gsdml_comp_nodes_number);
break;
default: ;
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
......@@ -4334,8 +4381,9 @@ int ItemPnModuleClass::scan( GsdmlAttrNav *attrnav, void *p)
ItemPnIOData::ItemPnIOData( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_IOData *item_iodata,
int item_subslot_idx, int item_slot_idx,
brow_tNode dest, flow_eDest dest_code) :
iodata(item_iodata)
iodata(item_iodata), subslot_idx(item_subslot_idx), slot_idx(item_slot_idx)
{
type = attrnav_eItemType_PnIOData;
......@@ -4399,6 +4447,21 @@ int ItemPnIOData::open_children( GsdmlAttrNav *attrnav, double x, double y)
node, flow_eDest_IntoLast);
}
GsdmlSubslotData *ssd = attrnav->dev_data.slot_data[slot_idx]->subslot_data[subslot_idx];
if ( iodata->Input) {
void *p = (void *) &ssd->io_input_length;
new ItemPnBase( attrnav, "InputLength", "LocalGsdmlAttr",
pwr_eType_UInt32, sizeof(ssd->io_input_length), 0, 0,
p, 0, node, flow_eDest_IntoLast);
}
if ( iodata->Output) {
void *p = (void *) &ssd->io_output_length;
new ItemPnBase( attrnav, "OutputLength", "LocalGsdmlAttr",
pwr_eType_UInt32, sizeof(ssd->io_output_length), 0, 0,
p, 0, node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
......
......@@ -106,13 +106,14 @@ typedef enum {
attrnav_eItemType_PnEnumTimeRatio,
attrnav_eItemType_PnEnumSendClock,
attrnav_eItemType_PnEnumValueMType,
} attrnav_eItemType;
} attrnav_eItemType;
typedef enum {
attrnav_mOpen_All = ~0,
attrnav_mOpen_Children = 1 << 0,
attrnav_mOpen_Attributes = 1 << 1
} attrnav_mOpen;
} attrnav_mOpen;
class ItemPn;
......@@ -173,6 +174,7 @@ class GsdmlAttrNav {
unsigned int time_ratio;
unsigned int send_clock;
unsigned int phase;
attr_eOrderModuleType order_moduletype;
GsdmlAttrNav(
void *xn_parent_ctx,
......@@ -206,6 +208,7 @@ class GsdmlAttrNav {
void set_viewio( int set) { viewio = set;}
int search_class( const char *filename, const char *model,
const char *module, char *mclass);
void set_order_moduletype( attr_eOrderModuleType type) { order_moduletype = type;}
static void trace_scan( void *data);
static int trace_scan_bc( brow_tObject object, void *p);
......@@ -289,6 +292,7 @@ class ItemPnEnumValueMType : public ItemPn {
void *value_p;
int old_value;
int first_scan;
char number[80];
int scan( GsdmlAttrNav *attrnav, void *p);
};
......@@ -326,12 +330,13 @@ class ItemPnSlot : public ItemPn {
class ItemPnSubslot : public ItemPn {
public:
ItemPnSubslot( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSubslotData *item_subslotdata,
gsdml_VirtualSubmoduleItem *item_virtualsubmodule,
gsdml_VirtualSubmoduleItem *item_virtualsubmodule, int item_slot_idx,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnSubslot() {}
GsdmlSubslotData *subslotdata;
gsdml_VirtualSubmoduleItem *virtualsubmodule;
int slot_idx;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
......@@ -553,10 +558,13 @@ class ItemPnParEnumBit : public ItemPn {
class ItemPnIOData : public ItemPn {
public:
ItemPnIOData( GsdmlAttrNav *attrnav, const char *item_name, gsdml_IOData *item_iodata,
int item_subslot_idx, int item_slot_idx,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnIOData() {}
gsdml_IOData *iodata;
int subslot_idx;
int slot_idx;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
......
......@@ -1154,3 +1154,43 @@ int FlowArray::move_down( FlowArrayElem *element)
}
return FLOW__NOELEM;
}
int FlowArray::sort_children( FlowArrayElem *element, int offset,
int (*comp)(const void *, const void *)) {
// Count children
int i;
int idx;
int last_idx;
int found;
int level;
found = 0;
for ( i = 0; i < a_size; i++) {
if ( *(a + i) == element) {
idx = i;
found = 1;
break;
}
}
if ( !found)
return FLOW__NOELEM;
if ( idx == a_size - 1)
return FLOW__NOCHILD;
// Return next element of higher level
level = ((FlowNode *)a[idx])->get_level();
found = 0;
for ( i = idx + 1 + offset; i < a_size; i++) {
if (((FlowNode *)a[i])->get_level() <= level)
break;
found = 1;
last_idx = i;
}
if ( !found)
return FLOW__NOCHILD;
qsort( &a[idx+1 + offset], last_idx - (idx + 1) + 1 - offset, sizeof(a[0]), comp);
return FLOW__SUCCESS;
}
......@@ -110,6 +110,7 @@ class FlowArray {
int get_next( FlowArrayElem *element, FlowArrayElem **next);
int move_up( FlowArrayElem *element);
int move_down( FlowArrayElem *element);
int sort_children( FlowArrayElem *element, int offset, int (*comp)(const void *, const void *));
~FlowArray();
friend class FlowNodeClass;
friend class FlowCtx;
......
......@@ -734,6 +734,12 @@ int brow_MoveDown( brow_tCtx ctx, brow_tObject object)
return ctx->move_down( (FlowArrayElem *)object);
}
int brow_SortChildren( brow_tCtx ctx, brow_tObject object, int offset,
int (*comp)(const void *, const void *))
{
return ctx->sort_children( (FlowArrayElem *)object, offset, comp);
}
int brow_IsVisible( brow_tCtx ctx, brow_tObject object, flow_eVisible type)
{
return ctx->is_visible( (FlowArrayElem *)object, type);
......
......@@ -244,6 +244,8 @@ int brow_GetPreviousSibling( brow_tCtx ctx, brow_tObject object,
brow_tObject *sibling);
int brow_MoveUp( brow_tCtx ctx, brow_tObject object);
int brow_MoveDown( brow_tCtx ctx, brow_tObject object);
int brow_SortChildren( brow_tCtx ctx, brow_tObject object, int offset,
int (*comp)(const void *, const void *));
int brow_IsVisible( brow_tCtx ctx, brow_tObject object, flow_eVisible type);
int brow_GetFirstVisible( brow_tCtx ctx, brow_tObject *object);
int brow_GetLastVisible( brow_tCtx ctx, brow_tObject *object);
......
......@@ -82,6 +82,8 @@ class BrowCtx : public FlowCtx {
{ return a.move_up( element);};
int move_down( FlowArrayElem *element)
{ return a.move_down( element);};
int sort_children( FlowArrayElem *element, int offset, int (*comp)(const void *, const void *))
{ return a.sort_children( element, offset, comp); }
int is_visible( FlowArrayElem *element, flow_eVisible type);
int get_first_visible( FlowArrayElem **element);
int get_last_visible( FlowArrayElem **element);
......
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