Skip to content
Snippets Groups Projects
Commit f44b9483 authored by Claudio Scafuri's avatar Claudio Scafuri :speech_balloon:
Browse files

state machine and basics falut/reset/off handling

parent f6db453a
No related branches found
No related tags found
1 merge request!1start in OFF state
......@@ -440,6 +440,10 @@ void SimulatedE2PS::reset()
/* clang-format on */
// Add your own code
if(get_state() == Tango::FAULT){
set_state(Tango::OFF);
push_change_event("State");
}
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::reset
......@@ -494,7 +498,14 @@ void SimulatedE2PS::fault()
/* clang-format on */
// Add your own code
_current_read = 0.0;
_current = 0.0;
_voltage = 0.0;
attr_current->set_write_value(_current);
push_change_event("current",&_current_read);
push_change_event("currentSet",&_current);
set_state(Tango::FAULT);
push_change_event("State");
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::fault
}
......
......@@ -41,6 +41,8 @@
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="Off" description="Switch power supply OFF." execMethod="off" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -50,6 +52,7 @@
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
</commands>
<commands name="Reset" description="Reset the powersupply to a well known state." execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -59,6 +62,7 @@
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
</commands>
<commands name="StartCycling" description="" execMethod="start_cycling" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -68,6 +72,8 @@
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="Abort" description="stop ramp or cycling" execMethod="abort" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -77,6 +83,8 @@
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="fault" description="Force a simulated faulty condtion" execMethod="fault" displayLevel="EXPERT" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -94,6 +102,13 @@
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The powersupply current setting in amps" label="current" unit="A" standardUnit="1" displayUnit="A" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<readExcludedStates>UNKNOWN</readExcludedStates>
<readExcludedStates>FAULT</readExcludedStates>
<writeExcludedStates>UNKNOWN</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>MOVING</writeExcludedStates>
<writeExcludedStates>OFF</writeExcludedStates>
</attributes>
<attributes name="voltage" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
......@@ -102,6 +117,7 @@
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The powersupply voltage in volts." label="" unit="V" standardUnit="1" displayUnit="V" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<readExcludedStates>UNKNOWN</readExcludedStates>
</attributes>
<attributes name="currentSet" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
......@@ -110,7 +126,26 @@
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The current set value as stored in the powersupply." label="" unit="A" standardUnit="1" displayUnit="A" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<readExcludedStates>UNKNOWN</readExcludedStates>
</attributes>
<states name="UNKNOWN" description="initialization failed or incomlete">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="ON" description="power supply on">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="FAULT" description="power supply in fault - not sourcing cuurent">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="RUNNING" description="magnet cycling running">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="MOVING" description="output current changing">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="OFF" description="power supply off , not sourcing current">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.3.6/share/pogo/preferences"/>
</classes>
</pogoDsl:PogoSystem>
......@@ -36,8 +36,14 @@
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::SimulatedE2PSStateMachine.cpp
//================================================================
// States | Description
// States | Description
//================================================================
// UNKNOWN | initialization failed or incomlete
// ON | power supply on
// FAULT | power supply in fault - not sourcing cuurent
// RUNNING | magnet cycling running
// MOVING | output current changing
// OFF | power supply off , not sourcing current
namespace SimulatedE2PS_ns
......@@ -54,17 +60,41 @@ namespace SimulatedE2PS_ns
//--------------------------------------------------------
bool SimulatedE2PS::is_current_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for current attribute in Write access.
/*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_WRITE) ENABLED START -----*/
// Check access type.
if ( type!=Tango::READ_REQ )
{
// Compare device state with not allowed states for WRITE
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT ||
get_state()==Tango::RUNNING ||
get_state()==Tango::MOVING ||
get_state()==Tango::OFF)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_WRITE) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentStateAllowed_WRITE
return false;
}
return true;
}
else
// Not any excluded states for current attribute in read access.
/*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_READ) ENABLED START -----*/
// Check access type.
if ( type==Tango::READ_REQ )
{
// Compare device state with not allowed states for READ
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentStateAllowed_READ
return false;
}
return true;
}
return true;
}
......@@ -77,11 +107,20 @@ bool SimulatedE2PS::is_current_allowed(TANGO_UNUSED(Tango::AttReqType type))
bool SimulatedE2PS::is_voltage_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for voltage attribute in read access.
/*----- PROTECTED REGION ID(SimulatedE2PS::voltageStateAllowed_READ) ENABLED START -----*/
// Check access type.
if ( type==Tango::READ_REQ )
{
// Compare device state with not allowed states for READ
if (get_state()==Tango::UNKNOWN)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::voltageStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::voltageStateAllowed_READ
return false;
}
return true;
}
return true;
}
......@@ -94,11 +133,20 @@ bool SimulatedE2PS::is_voltage_allowed(TANGO_UNUSED(Tango::AttReqType type))
bool SimulatedE2PS::is_currentSet_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for currentSet attribute in read access.
/*----- PROTECTED REGION ID(SimulatedE2PS::currentSetStateAllowed_READ) ENABLED START -----*/
// Check access type.
if ( type==Tango::READ_REQ )
{
// Compare device state with not allowed states for READ
if (get_state()==Tango::UNKNOWN)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::currentSetStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentSetStateAllowed_READ
return false;
}
return true;
}
return true;
}
......@@ -115,11 +163,16 @@ bool SimulatedE2PS::is_currentSet_allowed(TANGO_UNUSED(Tango::AttReqType type))
//--------------------------------------------------------
bool SimulatedE2PS::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for On command.
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::OnStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::OnStateAllowed
return false;
}
return true;
}
......@@ -131,11 +184,15 @@ bool SimulatedE2PS::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any))
//--------------------------------------------------------
bool SimulatedE2PS::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for Off command.
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::OffStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::OffStateAllowed
return false;
}
return true;
}
......@@ -147,11 +204,15 @@ bool SimulatedE2PS::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any))
//--------------------------------------------------------
bool SimulatedE2PS::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for Reset command.
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::ResetStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::ResetStateAllowed
return false;
}
return true;
}
......@@ -163,11 +224,16 @@ bool SimulatedE2PS::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any))
//--------------------------------------------------------
bool SimulatedE2PS::is_StartCycling_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for StartCycling command.
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::StartCyclingStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::StartCyclingStateAllowed
return false;
}
return true;
}
......@@ -179,11 +245,16 @@ bool SimulatedE2PS::is_StartCycling_allowed(TANGO_UNUSED(const CORBA::Any &any))
//--------------------------------------------------------
bool SimulatedE2PS::is_Abort_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for Abort command.
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::AbortStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::AbortStateAllowed
return false;
}
return true;
}
......
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