I`m trying to make a timer that switch off a vent after a set time from the swithing on.
I have a Yes/No panel to comfirm the order, and the code associated to the yes button.
I then call the dpWaitForValue in a new thread and then close the panel with panelOff, but the thread stops.
Commenting the panelOff line allows the execution of dpWait.
I thought the new thread was not dependat from the parent, but it doesn´t seem that way.
Is there any solution or anther way of doing it?
The idea is to switch off the any number of vents after a set period of time, unless the vent is manually switched off, so the automatic off is cancelled.
the vents have a button to send the order that opens a confirmation window, and associated to the click event is the code:
Code: Select all
main()
{
string ordenes;
dyn_string buffer;
if(isDollarDefined("$valor")){
dpSet($dp,$valor);
}
else{
ordenes=$dp;
strreplace(ordenes,"_marcha_rapida","_paro");
strreplace(ordenes,"_marcha_lenta","_paro");
ordenes+=":_original.._value";
startThread("marchaTemp",ordenes);
//dpGet("pulso_3s.buffer1:_online.._value",buffer);
// dynAppend(buffer, ordenes);
//dpSet("pulso_3s.buffer1:_original.._value",buffer);
}
PanelOff();//if i comment this line, it works
}
void marchaTemp(string dp)
{
time t;
dyn_string dpNamesWait, dpNamesReturn;
dyn_anytype conditions, returnValues;
int status;
dpNamesWait = makeDynString(dp);
conditions[1]=true;
dpNamesReturn = makeDynString(dp);
t=10;
status = dpWaitForValue( dpNamesWait, conditions, dpNamesReturn, returnValues, t );
if ( status == -1 )
{
DebugN( "Error" );
DebugN( "dpNamesWait : " + dpNamesWait );
DebugN( "conditions : " + conditions );
DebugN( "dpNamesReturn : " + dpNamesReturn );
DebugN( "returnValues : " + returnValues );
}
else if ( dynlen(getLastError()) != 0 )
{
DebugN( "Error returned in message" );
// Reaction: , for example, output
DebugN( getLastError() );
DebugN( "dpNamesWait : " + dpNamesWait );
DebugN( "conditions : " + conditions );
DebugN( "dpNamesReturn : " + dpNamesReturn );
DebugN( "returnValues : " + returnValues );
}
else
{
DebugN( "everything ok" );
DebugN( "dpNamesWait : " + dpNamesWait );
DebugN( "conditions : " + conditions );
DebugN( "dpNamesReturn : " + dpNamesReturn );
DebugN( "returnValues : " + returnValues );
}
}i am using version WinCCOA 3.10 SP1
Thank you very much