Commit d4f33b4e authored by claes's avatar claes

DigCommand added

parent fe498f9a
......@@ -1709,6 +1709,7 @@ AnalogShift <t>Float32 Int32 <t>Shift between different pages in the subgraph. T
Animation <t>Boolean <t>Different types of animation. <link>GeDynAnimation
Video <t>- <t>Display a continously updated image file. <link>GeDynVideo
SliderBackground <t>- <t>Indicates that the subgraph is background to a slider component. <link>GeDynSliderBackground
DigCommand <t>Boolean <t>Executes a command when signal gets high. <link>GeDynDigCommand
<h2>Inherit
For an instance of a subgraph, Inherit means, that the dynamic is inherited from the subgraph
......@@ -2183,6 +2184,25 @@ Video
Displays a gif-file that is continously updated by a web camera.
Video has no attribues.
</topic>
<topic>GeDynDigCommand <style>function
DigCommand
Execute specified command when the signal goes from low to high.
The object is connected to a digital signal in the database. When the value changes from 0 to
1, the command is executed.
DigCommand can exist in several instances, which makes it possible to execute several
command.
<b>Attribute <t><t>Description
DigCommand.Attribute <t><t>Signal in the database of type boolean that should
<t><t>influence the component.
DigCommand.Command <t><t>Xtt command that is executed when the signal value changes from 0 to 1.
DigCommand.Instance <t><t>States the number of instances that is created.
DigCommand.Attribute <t><t>Signal for instance number 2.
DigCommand.Command <t><t>Command for instance number 2.
</topic>
</headerlevel>
<pagebreak>
......
......@@ -1708,6 +1708,7 @@ AnalogShift <t>Float32 Int32 <t>Skiftar mellan olika sidor i subgrafen. V
Animation <t>Boolean <t>Olika typer av animering. <link>GeDynAnimation
Video <t>- <t>Kontinuerlig uppdatering av en blidfil. <link>GeDynVideo
SliderBackground <t>- <t>Markerar att subgrafen är bakgrund till en slider-komponent. <link>GeDynSliderBackground
DigCommand <t>Boolean <t>Exekverar ett kommando när signalet blir hög. <link>GeDynDigCommand
<h2>Inherit
För en instans av en subgraph betyder det att dynamiken ärvs från subgrafs-klassen, dvs den
......@@ -2168,6 +2169,23 @@ Video
Visar en gif-fil som kontinuerligt uppdateras av en Web-kamera.
Video har inga attribut.
</topic>
<topic>GeDynDigCommand <style>function
DigCommand
Exekvera ett kommando när signalen går från låg till hög.
Objektet kopplas till en digital signal i rtdb. När signalvärdet ändras från 0 till 1
exekveras kommandot.
DigCommand kan finnas i flera instanser, vilket gör det möjlit att exekvera flera kommandon.
<b>Attribute <t><t>Description
DigCommand.Attribute <t><t>Signal i databasen av typ boolean som ska påverka komponenten.
DigCommand.Command <t><t>Xtt kommando som exekveras när signalen går från 0 till 1.
DigCommand.Instance <t><t>Anger vilka instanser som ska skapas.
DigCommand2.Attribute <t><t>Signal för instans nr 2.
DigCommand2.Command <t><t>Kommando för instans nr 2.
</topic>
</headerlevel>
<pagebreak>
......
......@@ -83,4 +83,5 @@
080403 cs flow Bugrix for unbalanced paranthesis in pdf texts.
080408 cs glow Ge connections routing not sensitive for other nodes.
080408 cs ge Connections menu added in gtk version.
080408 cs xtt Format check added in Value dynamics.
\ No newline at end of file
080408 cs xtt Format check added in Value dynamics.
080414 cs ge Dynamic DigCommand added.
\ No newline at end of file
/*
* Proview $Id: ge_attrnav.cpp,v 1.19 2008-01-24 09:28:01 claes Exp $
* Proview $Id: ge_attrnav.cpp,v 1.20 2008-04-14 07:02:30 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -88,6 +88,7 @@ static attrnav_sEnumElement elem_dyn_type[] = {
{ (int) ge_mDynType_Table , "Table"},
{ (int) ge_mDynType_HostObject , "HostObject"},
{ (int) ge_mDynType_DigSound , "DigSound"},
{ (int) ge_mDynType_DigCommand , "DigCommand"},
{ 0, ""}};
static attrnav_sEnumElement elem_dyn_type_tone[] = {
......@@ -120,6 +121,7 @@ static attrnav_sEnumElement elem_dyn_type_tone[] = {
{ (int) ge_mDynType_Table , "Table"},
{ (int) ge_mDynType_HostObject , "HostObject"},
{ (int) ge_mDynType_DigSound , "DigSound"},
{ (int) ge_mDynType_DigCommand , "DigCommand"},
{ 0, ""}};
static attrnav_sEnumElement elem_action_type[] = {
......
/*
* Proview $Id: ge_dyn.cpp,v 1.61 2008-04-08 11:21:52 claes Exp $
* Proview $Id: ge_dyn.cpp,v 1.62 2008-04-14 07:02:30 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -374,6 +374,8 @@ GeDyn::GeDyn( const GeDyn& x) :
e = new GeDigSound((const GeDigSound&) *elem); break;
case ge_mDynType_XY_Curve:
e = new GeXY_Curve((const GeXY_Curve&) *elem); break;
case ge_mDynType_DigCommand:
e = new GeDigCommand((const GeDigCommand&) *elem); break;
default: ;
}
switch( elem->action_type) {
......@@ -486,6 +488,7 @@ void GeDyn::open( ifstream& fp)
case ge_eSave_HostObject: e = (GeDynElem *) new GeHostObject(this); break;
case ge_eSave_DigSound: e = (GeDynElem *) new GeDigSound(this); break;
case ge_eSave_XY_Curve: e = (GeDynElem *) new GeXY_Curve(this); break;
case ge_eSave_DigCommand: e = (GeDynElem *) new GeDigCommand(this); break;
case ge_eSave_PopupMenu: e = (GeDynElem *) new GePopupMenu(this); break;
case ge_eSave_SetDig: e = (GeDynElem *) new GeSetDig(this); break;
case ge_eSave_ResetDig: e = (GeDynElem *) new GeResetDig(this); break;
......@@ -1208,6 +1211,9 @@ GeDynElem *GeDyn::create_dyn_element( int mask, int instance)
case ge_mDynType_XY_Curve:
e = (GeDynElem *) new GeXY_Curve(this, (ge_mInstance)instance);
break;
case ge_mDynType_DigCommand:
e = (GeDynElem *) new GeDigCommand(this, (ge_mInstance)instance);
break;
default: ;
}
return e;
......@@ -1341,6 +1347,9 @@ GeDynElem *GeDyn::copy_element( GeDynElem& x)
case ge_mDynType_XY_Curve:
e = (GeDynElem *) new GeXY_Curve((GeXY_Curve&) x);
break;
case ge_mDynType_DigCommand:
e = (GeDynElem *) new GeDigCommand((GeDigCommand&) x);
break;
case ge_mDynType_FillLevel:
e = (GeDynElem *) new GeFillLevel((GeFillLevel&) x);
break;
......@@ -8664,6 +8673,192 @@ int GeFillLevel::export_java( grow_tObject object, ofstream& fp, bool first, cha
return 1;
}
void GeDigCommand::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
if ( instance == ge_mInstance_1) {
strcpy( attrinfo[i].name, "DigCommand.Attribute");
attrinfo[i].value = attribute;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( attribute);
strcpy( attrinfo[i].name, "DigCommand.Command");
attrinfo[i].value = command;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( command);
strcpy( attrinfo[i].name, "DigCommand.Instances");
attrinfo[i].value = &instance_mask;
attrinfo[i].type = ge_eAttrType_InstanceMask;
attrinfo[i++].size = sizeof( instance_mask);
}
else {
// Get instance number
int inst = 1;
unsigned int m = instance;
while( m > 1) {
m = m >> 1;
inst++;
}
sprintf( attrinfo[i].name, "DigCommand%d.Attribute", inst);
attrinfo[i].value = attribute;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( attribute);
sprintf( attrinfo[i].name, "DigCommand%d.Command", inst);
attrinfo[i].value = command;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( command);
}
*item_count = i;
}
void GeDigCommand::set_attribute( grow_tObject object, char *attr_name, int *cnt)
{
(*cnt)--;
if ( *cnt == 0) {
char msg[200];
strncpy( attribute, attr_name, sizeof( attribute));
if ( instance == ge_mInstance_1) {
sprintf( msg, "DigCommand.Attribute = %s", attr_name);
}
else {
sprintf( msg, "DigCommand%d.Attribute = %s", GeDyn::instance_to_number( instance),
attr_name);
}
dyn->graph->message( 'I', msg);
}
}
void GeDigCommand::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeDigCommand::save( ofstream& fp)
{
fp << int(ge_eSave_DigCommand) << endl;
fp << int(ge_eSave_DigCommand_attribute) << FSPACE << attribute << endl;
fp << int(ge_eSave_DigCommand_command) << FSPACE << command << endl;
fp << int(ge_eSave_DigCommand_instance) << FSPACE << int(instance) << endl;
fp << int(ge_eSave_DigCommand_instance_mask) << FSPACE << int(instance_mask) << endl;
fp << int(ge_eSave_End) << endl;
}
void GeDigCommand::open( ifstream& fp)
{
int type;
int end_found = 0;
int tmp;
char dummy[40];
for (;;)
{
fp >> type;
switch( type) {
case ge_eSave_DigCommand: break;
case ge_eSave_DigCommand_attribute:
fp.get();
fp.getline( attribute, sizeof(attribute));
break;
case ge_eSave_DigCommand_command:
fp.get();
fp.getline( command, sizeof(command));
break;
case ge_eSave_DigCommand_instance: fp >> tmp; instance = (ge_mInstance)tmp; break;
case ge_eSave_DigCommand_instance_mask: fp >> tmp; instance_mask = (ge_mInstance)tmp; break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeDigCommand:open syntax error" << endl;
fp.getline( dummy, sizeof(dummy));
}
if ( end_found)
break;
}
}
int GeDigCommand::connect( grow_tObject object, glow_sTraceData *trace_data)
{
int attr_type, attr_size;
pwr_tAName parsed_name;
int sts;
size = 4;
p = 0;
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
sts = dyn->graph->ref_object_info( dyn->cycle, parsed_name, (void **)&p, &subid, size);
a_typeid = attr_type;
if ( EVEN(sts)) return sts;
trace_data->p = &pdummy;
first_scan = true;
return 1;
}
int GeDigCommand::disconnect( grow_tObject object)
{
if ( p && db == graph_eDatabase_Gdh)
gdh_UnrefObjectInfo( subid);
p = 0;
return 1;
}
int GeDigCommand::scan( grow_tObject object)
{
if ( first_scan) {
old_value = *p;
first_scan = false;
return 1;
}
switch ( a_typeid) {
case pwr_eType_Boolean:
case pwr_eType_Int32:
case pwr_eType_UInt32: {
if ( old_value == *p) {
// No change since last time
return 1;
}
else {
if ( (!inverted && *p) || (inverted && !*p)) {
if ( dyn->graph->command_cb) {
char cmd[400];
dyn->graph->get_command( command, cmd, dyn);
(dyn->graph->command_cb)( dyn->graph->parent_ctx, cmd);
}
}
}
old_value = *p;
break;
}
default:;
}
return 1;
}
int GeDigCommand::export_java( grow_tObject object, ofstream& fp, bool first, char *var_name)
{
#if 0
if ( first)
fp << " ";
else
fp << " ,";
fp << "new GeDynDigCommand(" << var_name << ".dd, \"" << attribute << "\",\"" << command << "\")" << endl;
#endif
return 1;
}
void GePopupMenu::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
......@@ -8869,6 +9064,7 @@ int GePopupMenu::export_java( grow_tObject object, ofstream& fp, bool first, cha
return 1;
}
void GeSetDig::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
......
/*
* Proview $Id: ge_dyn.h,v 1.35 2008-01-24 09:28:01 claes Exp $
* Proview $Id: ge_dyn.h,v 1.36 2008-04-14 07:02:30 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -142,6 +142,7 @@
ge_eDynPrio_PulldownMenu,
ge_eDynPrio_OptionMenu,
ge_eDynPrio_InputFocus,
ge_eDynPrio_DigCommand,
// This should always be last
ge_eDynPrio_CloseGraph = 10000
......@@ -178,7 +179,8 @@
ge_mDynType_StatusColor = 1 << 25,
ge_mDynType_HostObject = 1 << 26,
ge_mDynType_DigSound = 1 << 27,
ge_mDynType_XY_Curve = 1 << 28
ge_mDynType_XY_Curve = 1 << 28,
ge_mDynType_DigCommand = 1 << 29
} ge_mDynType;
//! Action types.
......@@ -276,6 +278,7 @@
ge_eSave_HostObject = 32,
ge_eSave_DigSound = 33,
ge_eSave_XY_Curve = 34,
ge_eSave_DigCommand = 35,
ge_eSave_PopupMenu = 50,
ge_eSave_SetDig = 51,
ge_eSave_ResetDig = 52,
......@@ -438,6 +441,10 @@
ge_eSave_XY_Curve_instance_mask = 3415,
ge_eSave_XY_Curve_curve_color = 3416,
ge_eSave_XY_Curve_fill_color = 3417,
ge_eSave_DigCommand_attribute = 3500,
ge_eSave_DigCommand_command = 3501,
ge_eSave_DigCommand_instance = 3502,
ge_eSave_DigCommand_instance_mask = 3503,
ge_eSave_PopupMenu_ref_object = 5000,
ge_eSave_SetDig_attribute = 5100,
ge_eSave_SetDig_instance = 5101,
......@@ -2182,6 +2189,39 @@ class GeXY_Curve : public GeDynElem {
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Execute the supplied command when the value gets high.
class GeDigCommand : public GeDynElem {
public:
pwr_tAName attribute; //!< Database reference for digital attribute.
char command[400]; //!< Command to execute.
pwr_tBoolean *p;
pwr_tSubid subid;
int size;
graph_eDatabase db;
int inverted;
bool first_scan;
pwr_tBoolean old_value;
int a_typeid;
GeDigCommand( GeDyn *e_dyn, ge_mInstance e_instance = ge_mInstance_1) :
GeDynElem(e_dyn, ge_mDynType_DigCommand, (ge_mActionType) 0, ge_eDynPrio_DigCommand)
{ strcpy( attribute, ""); strcpy( command, ""); instance = e_instance;}
GeDigCommand( const GeDigCommand& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio)
{ strcpy( attribute, x.attribute); strcpy( command, x.command);
instance = x.instance; instance_mask = x.instance_mask;}
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
void open( ifstream& fp);
int connect( grow_tObject object, glow_sTraceData *trace_data);
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Dynamics for a trend object.
class GeFastCurve : public GeDynElem {
public:
......
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