I have a very complex state machine and I need to use the Qt framework state machine to do it. I know how to create a states using the qtframework, but I don't know where to put the code inside each state that should occur. what I only know is addtransition but where to put the code inside the switch case ??
switch (state) {
case Z_START:
state = Z_SAMPLE;
emit stateChanged(Z_SAMPLE,0);
case Z_SAMPLE:
{
DP_ANDY = false; // moved to Z sample
GSet.absP = Fp.pxf; //s08 //remember ambient pressure for correction // moved to Z sample
ig.reset();
//setSecondlineibited(true); // moved to state=Z_SAMPLE;
int next = nextSample();
/*
for(;current_sample<FlashSampler;current_sample++)
{
currentMeasurement = SamplerTable.at(current_sample);
if(currentMeasurement->enabled)
break;
}
*/
if(next>=FlashSampler)
{
htim=1;
wtim=1;
emit stateChanged(state = Z_FINI,resStat /*0*/); // use state of last result instead of 0!
break;
}
current_sample=next;
currentMeasurement = SamplerTable.at(current_sample);
precool = Ta >currentMeasurement->Ta;
#endif
MethSet* ms = currentMeasurement->getMethod()->methset;
Ta = currentMeasurement->Ta;//s117
Te = currentMeasurement->Te;
Ts = Ta - GSet.stdT;
Ti = Ta; //wirkungslos hier
St = ms->Step;
Rt = ms->Rate / 200.0f; // C/min alle 300 ms
for(int i=0;i<6;i++)
Ptim[i]=(int)(ms->airVol[i]*PUMPFACT);
#ifndef FlashSampler
if(Fp.powvers<200)
stirval = (ms->stir?255:0); //stirrer was at fixed speed for first 5 units with old powerboard
else
#endif
stirval=(int)((float)ms->stir/7.5f); //factor to be set
if(stirval&&stirval<5)
stirval=5;
state=Z_SAMPLE_wait,0);
}
switch (state) {
case Z_START:
state = Z_SAMPLE;
emit stateChanged(Z_SAMPLE,0);
case Z_SAMPLE:
{
DP_ANDY = false; // moved to Z sample
GSet.absP = Fp.pxf; //s08 //remember ambient pressure for correction // moved to Z sample
ig.reset();
//setSecondlineibited(true); // moved to state=Z_SAMPLE;
int next = nextSample();
/*
for(;current_sample<FlashSampler;current_sample++)
{
currentMeasurement = SamplerTable.at(current_sample);
if(currentMeasurement->enabled)
break;
}
*/
if(next>=FlashSampler)
{
htim=1;
wtim=1;
emit stateChanged(state = Z_FINI,resStat /*0*/); // use state of last result instead of 0!
break;
}
current_sample=next;
currentMeasurement = SamplerTable.at(current_sample);
precool = Ta >currentMeasurement->Ta;
#endif
MethSet* ms = currentMeasurement->getMethod()->methset;
Ta = currentMeasurement->Ta;//s117
Te = currentMeasurement->Te;
Ts = Ta - GSet.stdT;
Ti = Ta; //wirkungslos hier
St = ms->Step;
Rt = ms->Rate / 200.0f; // C/min alle 300 ms
for(int i=0;i<6;i++)
Ptim[i]=(int)(ms->airVol[i]*PUMPFACT);
#ifndef FlashSampler
if(Fp.powvers<200)
stirval = (ms->stir?255:0); //stirrer was at fixed speed for first 5 units with old powerboard
else
#endif
stirval=(int)((float)ms->stir/7.5f); //factor to be set
if(stirval&&stirval<5)
stirval=5;
state=Z_SAMPLE_wait,0);
}
To copy to clipboard, switch view to plain text mode
Bookmarks