Version: 9.15.0
YACS::HMI::CommandSetSwitchSelect Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandSetSwitchSelect:
Collaboration diagram for YACS::HMI::CommandSetSwitchSelect:

Public Member Functions

 CommandSetSwitchSelect (std::string aSwitch, std::string value)
 
- Public Member Functions inherited from YACS::HMI::Command
 Command ()
 
virtual bool execute ()
 the command is executed a first time after its registration for undo redo, then on redo More...
 
virtual bool reverse (bool isNormal=true)
 Reverse action: undo. More...
 
virtual bool executeSubOnly ()
 execute only sub commands in a reverse action More...
 
std::string recursiveDump (int level=0)
 
void addSubCommand (Command *command)
 
bool isNormalReverse ()
 

Protected Member Functions

virtual bool localExecute ()
 
virtual bool localReverse ()
 
virtual std::string dump ()
 

Protected Attributes

std::string _switch
 
std::string _value
 
std::string _oldValue
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 411 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandSetSwitchSelect()

CommandSetSwitchSelect::CommandSetSwitchSelect ( std::string  aSwitch,
std::string  value 
)

Definition at line 2437 of file commandsProc.cxx.

2439  : Command(), _switch(aSwitch), _value(value)
2440 {
2441  DEBTRACE("CommandSetSwitchSelect::CommandSetSwitchSelect");
2442  _oldValue = "0";
2443 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _oldValue, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandSetSwitchSelect::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 2445 of file commandsProc.cxx.

2446 {
2447  string ret ="CommandSetSwitchSelect " + _switch + " " + _value;
2448  return ret;
2449 }

References _switch, and _value.

◆ localExecute()

bool CommandSetSwitchSelect::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2451 of file commandsProc.cxx.

2452 {
2453  DEBTRACE("CommandSetSwitchSelect::localExecute");
2454  try
2455  {
2456  Proc* proc = GuiContext::getCurrent()->getProc();
2457  Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2458  InputPort *condPort = aSwitch->edGetConditionPort();
2459  _oldValue = condPort->getAsString();
2460  if (_oldValue == "None") _oldValue = "0";
2461  int val = atoi(_value.c_str());
2462  condPort->edInit(val);
2463  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2465  snode->update(SETSELECT, 0, snode);
2466  }
2467  catch (Exception& ex)
2468  {
2469  DEBTRACE("CommandSetSwitchSelect::localExecute() : " << ex.what());
2470  setErrorMsg(ex);
2471  return false;
2472  }
2473  return true;
2474 }
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
Node * getChildByName(const std::string &name) const
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Definition: DataPort.cxx:84
Base class for Input Ports.
Definition: InputPort.hxx:44
void edInit(T value)
Definition: InputPort.hxx:129
Base class for all schema objects.
Definition: Proc.hxx:44
Control node that emulates the C switch.
Definition: Switch.hxx:85
InputPort * edGetConditionPort()
Definition: Switch.hxx:115
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:68
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
virtual void update(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

References YACS::HMI::GuiContext::_mapOfSubjectNode, _oldValue, _switch, _value, DEBTRACE, YACS::ENGINE::Switch::edGetConditionPort(), YACS::ENGINE::InputPort::edInit(), testCppPluginInvokation::ex, YACS::ENGINE::DataPort::getAsString(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::SETSELECT, YACS::HMI::SubjectNode::update(), and YASSERT.

◆ localReverse()

bool CommandSetSwitchSelect::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2476 of file commandsProc.cxx.

2477 {
2478  DEBTRACE("CommandSetSwitchSelect::localReverse");
2479  try
2480  {
2481  Proc* proc = GuiContext::getCurrent()->getProc();
2482  Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2483  InputPort *condPort = aSwitch->edGetConditionPort();
2484  int val = atoi(_oldValue.c_str());
2485  condPort->edInit(val);
2486  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2488  snode->update(SETSELECT, 0, snode);
2489  }
2490  catch (Exception& ex)
2491  {
2492  DEBTRACE("CommandSetSwitchSelect::localReverse() : " << ex.what());
2493  setErrorMsg(ex);
2494  return false;
2495  }
2496  return true;
2497 }

References YACS::HMI::GuiContext::_mapOfSubjectNode, _oldValue, _switch, DEBTRACE, YACS::ENGINE::Switch::edGetConditionPort(), YACS::ENGINE::InputPort::edInit(), testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::SETSELECT, YACS::HMI::SubjectNode::update(), and YASSERT.

Member Data Documentation

◆ _oldValue

std::string YACS::HMI::CommandSetSwitchSelect::_oldValue
protected

Definition at line 422 of file commandsProc.hxx.

Referenced by CommandSetSwitchSelect(), localExecute(), and localReverse().

◆ _switch

std::string YACS::HMI::CommandSetSwitchSelect::_switch
protected

Definition at line 420 of file commandsProc.hxx.

Referenced by dump(), localExecute(), and localReverse().

◆ _value

std::string YACS::HMI::CommandSetSwitchSelect::_value
protected

Definition at line 421 of file commandsProc.hxx.

Referenced by dump(), and localExecute().


The documentation for this class was generated from the following files: