1 // Counter.cpp: implementation of the CCounter class.
3 //////////////////////////////////////////////////////////////////////
6 #include "logic_editor.h"
9 #include "nel/logic/logic_variable.h"
14 using namespace NLLOGIC
;
18 static char THIS_FILE
[]=__FILE__
;
22 //////////////////////////////////////////////////////////////////////
23 // Construction/Destruction
24 //////////////////////////////////////////////////////////////////////
26 CCounter::CCounter(const CString
&name
)
41 //-----------------------------------------------------
42 // cCounterToCLogicCounter
44 //-----------------------------------------------------
45 void cCounterToCLogicCounter( CCounter
& counter
, CLogicCounter
& logicCounter
)
48 logicCounter
.setName(NLMISC::tStrToUtf8(counter
.m_sName
));
51 if( counter
.m_sMode
== "Shuttle" )
53 logicCounter
.Mode
.setValue( CLogicCounter::SHUTTLE
);
56 if( counter
.m_sMode
== "Loop" )
58 logicCounter
.Mode
.setValue( CLogicCounter::LOOP
);
61 if( counter
.m_sMode
== "Stop on arrival" )
63 logicCounter
.Mode
.setValue( CLogicCounter::STOP_AT_LIMIT
);
68 logicCounter
.Mode
.setValue( CLogicCounter::STOP_AT_LIMIT
);
72 logicCounter
.Control
.setValue( CLogicCounter::RUN
);
74 /// lower limit for counter
75 logicCounter
.LowLimit
.setValue( counter
.m_nLowerLimit
);
77 /// higher limit for counter
78 logicCounter
.HighLimit
.setValue( counter
.m_nUpperLimit
);
80 // TODO : phase, period,...
82 } // cCounterToCLogicCounter //
85 //-----------------------------------------------------
86 // cLogicCounterToCCounter
88 //-----------------------------------------------------
89 void cLogicCounterToCCounter( const CLogicCounter
& logicCounter
, CCounter
& counter
)
92 counter
.m_sName
= CString( logicCounter
.getName().c_str() );
95 switch( logicCounter
.Mode
.getValue() )
97 case CLogicCounter::SHUTTLE
: counter
.m_sMode
= "Shuttle"; break;
98 case CLogicCounter::LOOP
: counter
.m_sMode
= "Loop"; break;
99 case CLogicCounter::STOP_AT_LIMIT
: counter
.m_sMode
= "Stop on arrival"; break;
102 // lower limit for counter
103 counter
.m_nLowerLimit
= (long)logicCounter
.LowLimit
.getValue();
105 // higher limit for counter
106 counter
.m_nUpperLimit
= (long)logicCounter
.HighLimit
.getValue();
110 } // cLogicCounterToCCounter //