if(active_accessory && off_timeout)
{
+ bool success = (monitor.get_peak()>0.35f && monitor.get_current()<monitor.get_peak()-0.2f);
Time::TimeStamp t = Time::now();
- if(t>off_timeout)
+ if(t>off_timeout || success)
{
Accessory &acc = *active_accessory;
// Assume success if we were uncertain of the physical setting
if(acc.uncertain&bit)
acc.uncertain &= ~bit;
- else if(acc.kind==Accessory::TURNOUT && monitor.get_peak()<0.5f)
+ else if(acc.kind==Accessory::TURNOUT && !success)
{
if(debug>=1)
IO::print("Peak current only %.2f A\n", monitor.get_peak());
state(0),
uncertain((1<<bits)-1),
target(0),
- active_time(500*Time::msec)
+ active_time((bits*700)*Time::msec)
{ }
unsigned ArduControl::Accessory::create_state_command(unsigned b, bool c, char *buffer) const
}
+bool ArduControl::CommandQueueTask::get_work(PendingCommand &cmd)
+{
+ return queue.pop(cmd);
+}
+
+void ArduControl::CommandQueueTask::push(const PendingCommand &cmd)
+{
+ queue.push(cmd);
+}
+
+
ArduControl::RefreshTask::RefreshTask():
next(cycle.end()),
round(0),
control(c),
done(false)
{
+ tasks.push_back(&control.command_queue);
tasks.push_back(&control.monitor);
tasks.push_back(&control.mfx_announce);
tasks.push_back(&control.mfx_search);
bool ArduControl::ControlThread::get_work(PendingCommand &cmd)
{
- if(control.command_queue.pop(cmd))
- return true;
-
for(vector<Task *>::iterator i=tasks.begin(); i!=tasks.end(); ++i)
if((*i)->get_work(cmd))
return true;