Commit 1389cbf7 authored by Claes Sjofors's avatar Claes Sjofors

Ge action EmitSignal added

parent b11f6edd
......@@ -177,6 +177,14 @@ public class JopSession {
public Object getUtility( int type, PwrtObjid objid, String name) {
return ((JopSessionIfc) sessionRep).getUtility( type, objid, name);
}
public Object getUtilityFirst( int type) {
return ((JopSessionIfc) sessionRep).getUtilityFirst( type);
}
public Object getUtilityNext( int type, Object o) {
return ((JopSessionIfc) sessionRep).getUtilityNext( type, o);
}
}
......
......@@ -67,4 +67,6 @@ public interface JopSessionIfc {
public void openTrend( String[] trendList);
public void openFast( String fastObject);
public Object getUtility( int type, PwrtObjid objid, String name);
public Object getUtilityFirst( int type);
public Object getUtilityNext( int type, Object o);
}
......@@ -402,6 +402,32 @@ public class JopSessionRep implements JopSessionIfc {
}
public Object getUtilityFirst( int type) {
for ( int i = 0; i < frames.size(); i++) {
Object o = frames.get(i);
if ( ((JopUtilityIfc) o).getUtilityType() == type)
return o;
}
return null;
}
public Object getUtilityNext( int type, Object previous) {
boolean found = false;
for ( int i = 0; i < frames.size(); i++) {
Object o = frames.get(i);
if ( found) {
if ( ((JopUtilityIfc) o).getUtilityType() == type)
return o;
}
else {
if ( ((JopUtilityIfc) o).getUtilityType() == type &&
o == previous)
found = true;
}
}
return null;
}
public int executeCommand( String command) {
return JopSpider.command( session, command);
}
......
......@@ -199,6 +199,7 @@ public class JopSpider {
new CliTable( "LOGIN", new String[] {"cli_arg1", "cli_arg2"}),
new CliTable( "LOGOUT", null),
new CliTable( "SHOW", new String[] {"cli_arg1"}),
new CliTable( "EMIT", new String[] {"cli_arg1", "/SIGNALNAME", "/GRAPH", "/INSTANCE"}),
};
......@@ -934,6 +935,45 @@ public class JopSpider {
}
}
}
else if ( command.equals("EMIT")) {
if ( cli.qualifierFound("cli_arg1")) {
String signalstr = "SIGNAL";
String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
if ( signalstr.length() >= cli_arg1.length() &&
signalstr.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "EMIT SIGNAL"
String signalname;
String graph;
String instance;
if ( cli.qualifierFound("/SIGNALNAME"))
signalname = cli.getQualValue("/SIGNALNAME");
else {
System.out.println( "Cmd: Signalname is missing\n");
return 0;
}
if ( cli.qualifierFound("/GRAPH"))
graph = cli.getQualValue("/GRAPH");
else
graph = null;
if ( cli.qualifierFound("/INSTANCE"))
instance = cli.getQualValue("/INSTANCE");
else
instance = null;
if ( graph == null) {
for ( Object utility = session.getUtilityFirst( JopUtility.GRAPH);
utility != null;
utility = session.getUtilityNext( JopUtility.GRAPH, utility)) {
((GrowFrame)utility).signalSend( signalname);
}
}
}
}
}
}
else {
System.out.println( "JopSpider: Parse error " + cli.getStsString());
......
......@@ -157,6 +157,8 @@ public class Dyn {
public static final int mActionType1_MethodToolbar = 1 << 22;
public static final int mActionType1_MethodPulldownMenu = 1 << 23;
public static final int mActionType1_Script = 1 << 24;
public static final int mActionType1_CatchSignal = 1 << 25;
public static final int mActionType1_EmitSignal = 1 << 26;
public static final int mActionType2_No = 0;
......@@ -221,6 +223,8 @@ public class Dyn {
public static final int eDynPrio_ColorThemeLightness = 57;
public static final int eDynPrio_DigSwap = 58;
public static final int eDynPrio_DigScript = 59;
public static final int eDynPrio_CatchSignal = 60;
public static final int eDynPrio_EmitSignal = 61;
public static final int eDynPrio_Script = 9998;
public static final int eDynPrio_Command = 9999;
public static final int eDynPrio_CloseGraph = 10000;
......@@ -289,6 +293,8 @@ public class Dyn {
public static final int eSave_MethodToolbar = 71;
public static final int eSave_MethodPulldownMenu = 72;
public static final int eSave_Script = 73;
public static final int eSave_CatchSignal = 74;
public static final int eSave_EmitSignal = 75;
public static final int eSave_End = 99;
public static final int eSave_Dyn_dyn_type1 = 100;
public static final int eSave_Dyn_action_type1 = 101;
......@@ -683,6 +689,9 @@ public class Dyn {
public static final int eSave_MethodPulldownMenu_menu_type = 7201;
public static final int eSave_Script_script_len = 7300;
public static final int eSave_Script_script = 7301;
public static final int eSave_CatchSignal_signal_name = 7400;
public static final int eSave_EmitSignal_signal_name = 7500;
public static final int eSave_EmitSignal_global = 7501;
public static final int eAnimSequence_Inherit = 0;
public static final int eAnimSequence_Cycle = 1;
......@@ -880,6 +889,10 @@ public class Dyn {
e = new DynMethodPulldownMenu((DynMethodPulldownMenu) x.elements.get(i)); break;
case Dyn.mActionType1_Script:
e = new DynScript((DynScript) x.elements.get(i)); break;
case Dyn.mActionType1_EmitSignal:
e = new DynEmitSignal((DynEmitSignal) x.elements.get(i)); break;
case Dyn.mActionType1_CatchSignal:
e = new DynCatchSignal((DynCatchSignal) x.elements.get(i)); break;
default: ;
}
switch( x.elements.get(i).action_type2) {
......@@ -969,6 +982,12 @@ public class Dyn {
case mActionType1_Script:
e = (DynElem) new DynScript((DynScript) x);
break;
case mActionType1_CatchSignal:
e = (DynElem) new DynCatchSignal((DynCatchSignal) x);
break;
case mActionType1_EmitSignal:
e = (DynElem) new DynEmitSignal((DynEmitSignal) x);
break;
default: ;
}
}
......@@ -1358,6 +1377,12 @@ public class Dyn {
case Dyn.eSave_Script:
elem = (DynElem) new DynScript(this);
break;
case Dyn.eSave_CatchSignal:
elem = (DynElem) new DynCatchSignal(this);
break;
case Dyn.eSave_EmitSignal:
elem = (DynElem) new DynEmitSignal(this);
break;
case Dyn.eSave_End:
end_found = true;
break;
......@@ -13345,5 +13370,151 @@ public class Dyn {
}
public class DynCatchSignal extends DynElem {
String signal_name;
public DynCatchSignal( Dyn dyn) {
super(dyn, 0, 0, Dyn.mActionType1_CatchSignal, 0, Dyn.eDynPrio_CatchSignal);
}
public DynCatchSignal( DynCatchSignal x) {
super(x);
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_Signal:
if ( signal_name.equals( ((GlowEventSignal)e).signal_name)) {
GlowEvent ce = new GlowEvent();
ce.event = Glow.eEvent_MB1Click;
dyn.action( object, ce);
}
break;
}
return 1;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end_found = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = Integer.valueOf(token.nextToken());
if ( Dyn.debug) System.out.println( "DynCatchSignal : " + line);
switch ( key) {
case Dyn.eSave_CatchSignal:
break;
case Dyn.eSave_CatchSignal_signal_name:
if ( token.hasMoreTokens())
signal_name = token.nextToken();
break;
case Dyn.eSave_End:
end_found = true;
break;
default:
System.out.println( "Syntax error in DynCatchSignal");
break;
}
if ( end_found)
break;
}
} catch ( Exception e) {
System.out.println( "IOException DynCatchSignal");
}
}
}
public class DynEmitSignal extends DynElem {
String signal_name;
int global;
public DynEmitSignal( Dyn dyn) {
super(dyn, 0, 0, Dyn.mActionType1_EmitSignal, 0, Dyn.eDynPrio_EmitSignal);
}
public DynEmitSignal( DynEmitSignal x) {
super(x);
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
dyn.graph.setClickActive(1);
break;
case Glow.eEvent_MB1Up:
object.setColorInverse( 0);
dyn.repaintNow = true;
dyn.graph.setClickActive( 0);
break;
case Glow.eEvent_MB1Click:
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) != 0)
break;
if ( global != 0) {
int sts;
String command = "emit signal /signalname=" + signal_name;
command = dyn.graph.getCommand(command);
sts = dyn.graph.command(command);
}
else
dyn.graph.signalSend(signal_name);
}
return 1;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end_found = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = Integer.valueOf(token.nextToken());
if ( Dyn.debug) System.out.println( "DynEmitSignal : " + line);
switch ( key) {
case Dyn.eSave_EmitSignal:
break;
case Dyn.eSave_EmitSignal_signal_name:
if ( token.hasMoreTokens())
signal_name = token.nextToken();
break;
case Dyn.eSave_EmitSignal_global:
global = Integer.valueOf(token.nextToken());
break;
case Dyn.eSave_End:
end_found = true;
break;
default:
System.out.println( "Syntax error in DynEmitSignal");
break;
}
if ( end_found)
break;
}
} catch ( Exception e) {
System.out.println( "IOException DynEmitSignal");
}
}
}
}
......@@ -1602,6 +1602,8 @@ public class Glow {
public static final int eEventType_Menu = 1;
public static final int eEventType_Toolbar = 2;
public static final int eEventType_Table = 3;
public static final int eEventType_CustomColor = 4;
public static final int eEventType_Signal = 5;
public static final int eEvent_MB1Click = 0;
public static final int eEvent_MB1Up = 2;
......@@ -1617,4 +1619,5 @@ public class Glow {
public static final int eEvent_SliderMoved = 12;
public static final int eEvent_SliderMoveEnd = 13;
public static final int eEvent_MB3Press = 14;
public static final int eEvent_Signal = 15;
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
public class GlowEventSignal extends GlowEvent {
public String signal_name;
public GlowEventSignal() {}
}
......@@ -457,6 +457,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
case Glow.eEvent_SliderMoveStart:
case Glow.eEvent_SliderMoveEnd:
case Glow.eEvent_SliderMoved:
case Glow.eEvent_Signal:
if ( e.object != null) {
int sts;
Dyn dyn = (Dyn)((GlowArrayElem)e.object).getUserData();
......@@ -629,4 +630,8 @@ public class Graph implements GraphIfc, GrowApplIfc {
public int getClickActive() {
return clickActive;
}
public void signalSend( String signalName) {
ctx.signalSend( signalName);
}
}
......@@ -71,4 +71,5 @@ public interface GraphIfc {
public double getAnimationScanTime();
public String getCommand(String cmd);
public void setClickActive(int active);
public void signalSend(String signalName);
}
......@@ -47,4 +47,5 @@ public interface GrowApplIfc {
public int getHeight();
public Object loadCtx( String file);
public int loadSubgraph( String file);
public void signalSend( String signalName);
}
......@@ -954,6 +954,32 @@ public class GrowCtx implements GrowCtxIfc {
}
return 1;
}
public int signalSend(String signalName) {
for ( int i = 0; i < cmn.a.size(); i++) {
switch ( cmn.a.get(i).type()) {
case Glow.eObjectType_GrowNode:
case Glow.eObjectType_GrowGroup:
GlowEventSignal e = new GlowEventSignal();
e.event = Glow.eEvent_Signal;
e.type = Glow.eEventType_Signal;
e.x = 0;
e.y = 0;
e.object_type = cmn.a.get(i).type();
e.object = cmn.a.get(i);
e.signal_name = signalName;
cmn.appl.eventHandler(e);
break;
case Glow.eObjectType_GrowWindow:
case Glow.eObjectType_GrowFolder:
((GrowWindow)cmn.a.get(i)).windowCmn.ctx.signalSend(signalName);
break;
}
}
return 1;
}
}
......
......@@ -72,4 +72,5 @@ public interface GrowCtxIfc {
public void setSubwindowSource( String name, String source, String owner);
public void setSliderActive( boolean active);
public int loadSubgraph( String file);
public int signalSend( String signalName);
}
......@@ -731,6 +731,10 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
public boolean isAuthorized(int access) {
return graph.gdh.isAuthorized(access);
}
public void signalSend( String signalName) {
graph.signalSend( signalName);
}
}
......
......@@ -47,6 +47,7 @@ local_java_sources := \
GlowEventMenu.java,\
GlowEventToolbar.java,\
GlowEventTable.java,\
GlowEventSignal.java,\
GrowCtxIfc.java,\
GrowCmn.java,\
GrowAnnotIfc.java,\
......
......@@ -3853,6 +3853,8 @@ OpenURL <t>- <t>Open an URL in a suitable web browser on Click MB1. <
PulldownMenu <t>- <t>Action for pulldown menus. <link>GeDynPulldownMenu
OptionMenu <t>- <t>Action for option menus. <link>GeDynOptionMenu
MethodPulldownMenu <t>- <t>Action for pulldown menus for object methods. <link>GeDynMethodPulldownMenu
EmitSignal <t>- <t>Emit a signal. <link>GeDynEmitSignal
CatchSignal <t>- <t>Catch a signal. <link>GeDynCatchSignal
</topic>
<headerlevel>
......@@ -4236,6 +4238,30 @@ MethodPulldownMenu.HelpMenu <t><t>The menu is a help menu and only the help meth
<t><t>Help and Help Class is shown in the menu.
</topic>
<topic>GeDynEmitSignal <style>function
EmitSignal
Action to emit a signal.
<b>Attribute <t><t>Description
EmitSignal.SignalName <t><t>Signal name.
EmitSignal.Global <t><t>If global is set, the signal is emitted to all open
<t><t>graphs and multiviews, Otherwise only to the current
<t><t>graph.
</topic>
<topic>GeDynCatchSignal <style>function
CatchSignal
Action to catch a signal. When the signal is caught, the click actions for the
current object is executed.
<b>Attribute <t><t>Description
CatchSignal.SignalName <t><t>Signal name.
</topic>
</headerlevel>
<pagebreak>
......
......@@ -1592,6 +1592,7 @@ crossreference<t>Show crossreferenses <LINK> crossreference
define <t>Define a symbol <LINK> define
delete item <t>Delete a menu item in the Xtt menu <LINK> delete item
delete opmenuitem <t>Delete a menu item in the operator window menu <LINK> delete opmenuitem
emit signal <t>Emit a Ge signal <LINK> emit signal
eventlist <t>Handle the eventlist <LINK> eventlist
exit <t>close xtt <LINK> exit
help <t>Display help <LINK> help
......@@ -1965,6 +1966,20 @@ xtt> cross /name=hql-hvk-Start
xtt> cross /function="CreateHvkObject"
</TOPIC>
<TOPIC> emit signal <style> function
Command emit signal
Emit a Ge signal.
The signal is be emitted to a specific graph, or to all graphs and multiviews
if graph is not specified.
<B>xtt> emit signal /signalname= {/graph=] [/instance=]
/signal_name<t>Name of signal.
/graph <t>Graph or multiview to which the signal is directed.
/instance <t>Instance object if the graph is an object graph.
</TOPIC>
<TOPIC> exit <style> function
Command exit
......
......@@ -4181,6 +4181,31 @@ Endast konfigurerade metoder visas i menyn.
MethodPulldownMenu.Object <t><t>Objekt för vilket metoderna ska visas.
MethodPulldownMenu.HelpMenu <t><t>Menyn är en hjälpmeny och endast hjälp-metoderna
<t><t>Help och Help Class visas i menyn.
</topic>
<topic>GeDynEmitSignal <style>function
EmitSignal
Aktion för att sända en signal.
<b>Attribut <t><t>Beskrivning
EmitSignal.SignalName <t><t>Signalnamn.
EmitSignal.Global <t><t>Om global är satt, sänds signalen till all öppna grafer
<t><t>och multiviewer. Annars vara till den nuvarande grafen.
</topic>
<topic>GeDynCatchSignal <style>function
CatchSignal
Aktion för att fånga en signal. När signalen är fångad, exekveras aktionerna för mus-klick för
det aktuella objektet.
<b>Attribut <t><t>Beskrivning
CatchSignal.SignalName <t><t>Signalnamn.
</topic>
</headerlevel>
<pagebreak>
......
......@@ -1601,7 +1601,8 @@ crossreference<t>Visa korsreferenser <LINK> crossreference
define <t>Definiera en symbol <LINK> define
delete opmenuitem <t>Ta bort ett xtt menyalternativ <LINK> delete item
delete item <t>Ta bort ett menyalternativ i operatörsfönstret <LINK> delete item
eventlist <t>Hantera händlselistan <LINK> eventlist
emit signal <t>Sänd en Ge signal. <LINK> emit signal
eventlist <t>Hantera händelselistan <LINK> eventlist
exit <t>Stäng xtt <LINK> exit
help <t>Visa hjälp <LINK> help
login <t>Inloggning av användare <LINK> login
......@@ -1934,6 +1935,20 @@ xtt> cross /name=hql-hvk-Start
xtt> cross /function="CreateHvkObject"
</TOPIC>
<TOPIC> emit signal <style> function
Command emit signal
Sänd en Ge signal.
Signalen är sänd till en specificerad graf, eller till alla grafer och multiview
om graf inte är specificerad.
<B>xtt> emit signal /signalname= {/graph=] [/instance=]
/signal_name<t>Signalnamn.
/graph <t>Graf eller multiview till vilken signalen är riktad.
/instance <t>Instansobjekt om grafen är en objektsbild.
</TOPIC>
<TOPIC> exit <style> function
Kommando exit
......
......@@ -180,6 +180,7 @@ static attrnav_sEnumElement elem_action_type[] = {
{ (unsigned int) ge_mActionType1_MethodPulldownMenu , "MethodPulldownMenu"},
{ (unsigned int) ge_mActionType1_Slider , "Slider"},
{ (unsigned int) ge_mActionType1_CatchSignal , "CatchSignal"},
{ (unsigned int) ge_mActionType1_EmitSignal , "EmitSignal"},
{ 0, ""}};
static attrnav_sEnumElement elem_color[] = {
......
......@@ -522,6 +522,8 @@ GeDyn::GeDyn( const GeDyn& x) :
e = new GeScript((const GeScript&) *elem); break;
case ge_mActionType1_CatchSignal:
e = new GeCatchSignal((const GeCatchSignal&) *elem); break;
case ge_mActionType1_EmitSignal:
e = new GeEmitSignal((const GeEmitSignal&) *elem); break;
default: ;
}
switch( elem->action_type2) {
......@@ -651,6 +653,7 @@ void GeDyn::open( ifstream& fp)
case ge_eSave_MethodPulldownMenu: e = (GeDynElem *) new GeMethodPulldownMenu(this); break;
case ge_eSave_Script: e = (GeDynElem *) new GeScript(this); break;
case ge_eSave_CatchSignal: e = (GeDynElem *) new GeCatchSignal(this); break;
case ge_eSave_EmitSignal: e = (GeDynElem *) new GeEmitSignal(this); break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeDyn:open syntax error" << endl;
......@@ -1442,6 +1445,9 @@ GeDynElem *GeDyn::create_action1_element( int mask, int instance)
case ge_mActionType1_CatchSignal:
e = (GeDynElem *) new GeCatchSignal(this);
break;
case ge_mActionType1_EmitSignal:
e = (GeDynElem *) new GeEmitSignal(this);
break;
default: ;
}
return e;
......@@ -1672,6 +1678,9 @@ GeDynElem *GeDyn::copy_element( GeDynElem& x)
case ge_mActionType1_CatchSignal:
e = (GeDynElem *) new GeCatchSignal((GeCatchSignal&) x);
break;
case ge_mActionType1_EmitSignal:
e = (GeDynElem *) new GeEmitSignal((GeEmitSignal&) x);
break;
default: ;
}
}
......@@ -18960,6 +18969,103 @@ int GeCatchSignal::export_java( grow_tObject object, ofstream& fp, bool first, c
return 1;
}
void GeEmitSignal::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
strcpy( attrinfo[i].name, "EmitSignal.SignalName");
attrinfo[i].value = signal_name;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( signal_name);
strcpy( attrinfo[i].name, "EmitSignal.Global");
attrinfo[i].value = &global;
attrinfo[i].type = glow_eType_Int;
attrinfo[i++].size = sizeof(global);
dyn->display_access = true;
*item_count = i;
}
void GeEmitSignal::save( ofstream& fp)
{
fp << int(ge_eSave_EmitSignal) << endl;
fp << int(ge_eSave_EmitSignal_signal_name) << FSPACE << signal_name << endl;
fp << int(ge_eSave_EmitSignal_global) << FSPACE << global << endl;
fp << int(ge_eSave_End) << endl;
}
void GeEmitSignal::open( ifstream& fp)
{
int type;
int end_found = 0;
char dummy[40];
for (;;)
{
if ( !fp.good()) {
fp.clear();
fp.getline( dummy, sizeof(dummy));
printf( "** Read error GeEmitSignal: \"%d %s\"\n", type, dummy);
}
fp >> type;
switch( type) {
case ge_eSave_EmitSignal: break;
case ge_eSave_EmitSignal_signal_name:
fp.get();
fp.getline( signal_name, sizeof(signal_name));
break;
case ge_eSave_EmitSignal_global: fp >> global; break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeEmitSignal:open syntax error" << endl;
fp.getline( dummy, sizeof(dummy));
}
if ( end_found)
break;
}
}
int GeEmitSignal::action( grow_tObject object, glow_tEvent event)
{
if ( !dyn->graph->is_authorized( dyn->access))
return 1;
switch ( event->event) {
case glow_eEvent_MB1Down:
grow_SetClickSensitivity( dyn->graph->grow->ctx, glow_mSensitivity_MB1Click);
grow_SetObjectColorInverse( object, 1);
break;
case glow_eEvent_MB1Up:
grow_SetObjectColorInverse( object, 0);
break;
case glow_eEvent_Key_Return:
case glow_eEvent_MB1Click: {
if ( global) {
pwr_tCmd command, cmd;
int sts;
sprintf( command, "emit signal/signalname=%s", signal_name);
dyn->graph->get_command( command, cmd, dyn);
sts = (dyn->graph->command_cb)( dyn->graph->parent_ctx, cmd, 0);
}
else {
dyn->graph->signal_send( signal_name);
}
break;
}
default: ;
}
return 1;
}
int GeEmitSignal::export_java( grow_tObject object, ofstream& fp, bool first, char *var_name)
{
return 1;
}
......
......@@ -198,6 +198,7 @@
ge_eDynPrio_DigSwap,
ge_eDynPrio_DigScript,
ge_eDynPrio_CatchSignal,
ge_eDynPrio_EmitSignal,
// This should always be last
ge_eDynPrio_Script = 9998,
......@@ -283,7 +284,8 @@
ge_mActionType1_MethodToolbar = 1 << 22,
ge_mActionType1_MethodPulldownMenu = 1 << 23,
ge_mActionType1_Script = 1 << 24,
ge_mActionType1_CatchSignal = 1 << 25
ge_mActionType1_CatchSignal = 1 << 25,
ge_mActionType1_EmitSignal = 1 << 26
} ge_mActionType1;
typedef enum {
......@@ -396,6 +398,7 @@
ge_eSave_MethodPulldownMenu = 72,
ge_eSave_Script = 73,
ge_eSave_CatchSignal = 74,
ge_eSave_EmitSignal = 75,
ge_eSave_End = 99,
ge_eSave_Dyn_dyn_type1 = 100,
ge_eSave_Dyn_action_type1 = 101,
......@@ -790,7 +793,9 @@
ge_eSave_MethodPulldownMenu_menu_type = 7201,
ge_eSave_Script_script_len = 7300,
ge_eSave_Script_script = 7301,
ge_eSave_CatchSignal_signal_name = 7400
ge_eSave_CatchSignal_signal_name = 7400,
ge_eSave_EmitSignal_signal_name = 7500,
ge_eSave_EmitSignal_global = 7501
} ge_eSave;
......@@ -3234,6 +3239,25 @@ class GeCatchSignal : public GeDynElem {
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Emit signal.
class GeEmitSignal : public GeDynElem {
public:
pwr_tString80 signal_name;
int global;
GeEmitSignal( GeDyn *e_dyn) :
GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_EmitSignal, ge_mActionType2_No, ge_eDynPrio_EmitSignal), global(0)
{ strcpy( signal_name, "");}
GeEmitSignal( const GeEmitSignal& x) :
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio), global(x.global)
{ strcpy( signal_name, x.signal_name);}
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
/*@}*/
#endif
......
......@@ -259,7 +259,7 @@ static int xnav_wait_func( void *client_data,
void *client_flag);
static int xnav_oplog_func( void *client_data,
void *client_flag);
static int xnav_send_func( void *client_data,
static int xnav_emit_func( void *client_data,
void *client_flag);
dcli_tCmdTable xnav_command_table[] = {
......@@ -452,9 +452,9 @@ dcli_tCmdTable xnav_command_table[] = {
{ "dcli_arg1", "/FILE", "/SPEED", "/PID", "/EVENT", ""}
},
{
"SEND",
&xnav_send_func,
{ "dcli_arg1", "/SIGNALNAME", ""}
"EMIT",
&xnav_emit_func,
{ "dcli_arg1", "/SIGNALNAME", "/GRAPH", "/INSTANCE", ""}
},
{"",}};
......@@ -7748,7 +7748,7 @@ static int xnav_oplog_func(void *client_data,
return XNAV__SUCCESS;
}
static int xnav_send_func(void *client_data,
static int xnav_emit_func( void *client_data,
void *client_flag)
{
XNav *xnav = (XNav *)client_data;
......@@ -7761,12 +7761,37 @@ static int xnav_send_func(void *client_data,
if ( cdh_NoCaseStrncmp( arg1_str, "SIGNAL", strlen( arg1_str)) == 0) {
pwr_tString80 signalname_str;
ApplListElem *elem;
char *instance_p;
char *graph_p;
pwr_tAName instance_str;
pwr_tString80 graph_str;
void *appl_ctx;
if ( EVEN( dcli_get_qualifier( "/SIGNALNAME", signalname_str, sizeof(signalname_str)))) {
xnav->message('E',"Syntax error");
return XNAV__HOLDCOMMAND;
}
if ( ODD( dcli_get_qualifier( "/GRAPH", graph_str, sizeof(graph_str))))
graph_p = graph_str;
else
graph_p = 0;
if ( ODD( dcli_get_qualifier( "/INSTANCE", instance_str, sizeof(instance_str))))
instance_p = instance_str;
else
instance_p = 0;
if ( graph_p) {
// Send to specified graph
if ( xnav->appl.find( applist_eType_Graph, graph_p, instance_p, &appl_ctx))
((XttGe *)appl_ctx)->signal_send( signalname_str);
else if ( xnav->appl.find( applist_eType_MultiView, graph_p, instance_p, &appl_ctx))
((XttMultiView *)appl_ctx)->signal_send( signalname_str);
}
else {
// Graph not specified, send to all
for ( elem = xnav->appl.root; elem; elem = elem->next) {
if ( elem->type == applist_eType_Graph)
((XttGe *)elem->ctx)->signal_send( signalname_str);
......@@ -7774,6 +7799,7 @@ static int xnav_send_func(void *client_data,
((XttMultiView *)elem->ctx)->signal_send( signalname_str);
}
}
}
else {
xnav->message('E',"Syntax error");
return XNAV__HOLDCOMMAND;
......
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