Version: 9.16.0
YACS::HMI::CommandSetWhileCondition Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandSetWhileCondition:
Collaboration diagram for YACS::HMI::CommandSetWhileCondition:

Public Member Functions

 CommandSetWhileCondition (std::string whileLoop, 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...
 
virtual std::string dump ()
 
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 ()
 
virtual bool localExecute ()=0
 
virtual bool localReverse ()=0
 

Protected Attributes

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

Detailed Description

Definition at line 456 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandSetWhileCondition()

CommandSetWhileCondition::CommandSetWhileCondition ( std::string  whileLoop,
std::string  value 
)

Definition at line 2650 of file commandsProc.cxx.

2652 : Command(), _whileLoop(whileLoop), _value(value)
2653{
2654 DEBTRACE("CommandSetWhileCondition::CommandSetWhileCondition");
2655 _oldValue = 0;
2656}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _oldValue, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandSetWhileCondition::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 2658 of file commandsProc.cxx.

2659{
2660 string ret ="CommandSetWhileCondition " + _whileLoop + " " + _value;
2661 return ret;
2662}

References _value, and _whileLoop.

◆ localExecute()

bool CommandSetWhileCondition::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2664 of file commandsProc.cxx.

2665{
2666 DEBTRACE("CommandSetWhileCondition::localExecute");
2667 try
2668 {
2669 Proc* proc = GuiContext::getCurrent()->getProc();
2670 WhileLoop* whileLoop = dynamic_cast<WhileLoop*>(proc->getChildByName(_whileLoop));
2671 InputPort *cond = whileLoop->edGetConditionPort();
2672 _oldValue = atoi(whileLoop->edGetConditionPort()->getAsString().c_str());
2673 bool val = atoi(_value.c_str());
2674 cond->edInit(val);
2675 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(whileLoop));
2677 snode->update(SETVALUE, 0, snode);
2678 return true;
2679 }
2680 catch (Exception& ex)
2681 {
2682 DEBTRACE("CommandSetWhileCondition::localExecute() : " << ex.what());
2683 setErrorMsg(ex);
2684 return false;
2685 }
2686}
#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
Class for a while loop.
Definition: WhileLoop.hxx:39
InputPort * edGetConditionPort()
Definition: WhileLoop.hxx:48
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
virtual void update(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

References YACS::HMI::GuiContext::_mapOfSubjectNode, _oldValue, _value, _whileLoop, DEBTRACE, YACS::ENGINE::WhileLoop::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::SETVALUE, YACS::HMI::SubjectNode::update(), and YASSERT.

◆ localReverse()

bool CommandSetWhileCondition::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2688 of file commandsProc.cxx.

2689{
2690 DEBTRACE("CommandSetWhileCondition::localReverse");
2691 try
2692 {
2693 Proc* proc = GuiContext::getCurrent()->getProc();
2694 WhileLoop* whileLoop = dynamic_cast<WhileLoop*>(proc->getChildByName(_whileLoop));
2695 InputPort *cond = whileLoop->edGetConditionPort();
2696 cond->edInit(_oldValue);
2697 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(whileLoop));
2699 snode->update(SETVALUE, 0, snode);
2700 return true;
2701 }
2702 catch (Exception& ex)
2703 {
2704 DEBTRACE("CommandSetWhileCondition::localReverse() : " << ex.what());
2705 setErrorMsg(ex);
2706 return false;
2707 }
2708}

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

Member Data Documentation

◆ _oldValue

bool YACS::HMI::CommandSetWhileCondition::_oldValue
protected

Definition at line 467 of file commandsProc.hxx.

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

◆ _value

std::string YACS::HMI::CommandSetWhileCondition::_value
protected

Definition at line 466 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

◆ _whileLoop

std::string YACS::HMI::CommandSetWhileCondition::_whileLoop
protected

Definition at line 465 of file commandsProc.hxx.

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


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