Changeset 15103


Ignore:
Timestamp:
03/18/13 14:56:33 (12 years ago)
Author:
tbretz
Message:
Handle the 'Power Problem' a bit more accurate.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/HeadersLid.h

    r14360 r15103  
    1010            kDisconnected = 1,
    1111            kConnected,
     12            kUnidentified,
    1213            kInconsistent,
    1314            kUnknown,
     15            kPowerProblem,
    1416            kClosed,
    1517            kOpen,
  • trunk/FACT++/src/lidctrl.cc

    r14978 r15103  
    166166        fRdfData = "";
    167167
    168         if ((fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Unknown") ||
    169             (fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Unknown"))
    170         {
    171             Warn("Lid status unknown ("+fLid1.status+"/"+fLid2.status+")");
    172             PostClose(false);
    173             return;
    174         }
     168        if ((fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Power Problem" && fLid1.status!="Unknown") ||
     169            (fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Power Problem" && fLid2.status!="Unknown"))
     170            Warn("Lid reported status unknown by lidctrl ("+fLid1.status+"/"+fLid2.status+")");
    175171
    176172        fLastReport = Time();
     
    358354            return State::kDisconnected;
    359355
     356        // Unidentified state detected
     357        if ((fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Power Problem" && fLid1.status!="Unknown") ||
     358            (fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Power Problem" && fLid2.status!="Unknown"))
     359            return State::kUnidentified;
     360
     361        // This is an assumption, but the best we have...
     362        if (fLid1.status=="Closed" && fLid2.status=="Power Problem")
     363            return State::kClosed;
     364        if (fLid2.status=="Closed" && fLid1.status=="Power Problem")
     365            return State::kClosed;
     366        if (fLid1.status=="Open" && fLid2.status=="Power Problem")
     367            return State::kOpen;
     368        if (fLid2.status=="Open" && fLid1.status=="Power Problem")
     369            return State::kOpen;
     370
    360371        // Inconsistency
    361372        if (fLid1.status!=fLid2.status)
     
    365376        if (fLid1.status=="Unknown")
    366377            return State::kUnknown;
     378
     379        // Power Problem
     380        if (fLid1.status=="Power Problem")
     381            return State::kPowerProblem;
    367382
    368383        // Closed
     
    413428        DimData data;
    414429
     430        if (l1.status=="Unknown")
     431            data.status[0] = 3;
     432        if (l1.status=="Power Problem")
     433            data.status[0] = 2;
    415434        if (l1.status=="Open")
    416435            data.status[0] = 1;
     
    418437            data.status[0] = 0;
    419438
     439        if (l2.status=="Unknown")
     440            data.status[1] = 3;
     441        if (l2.status=="Power Problem")
     442            data.status[1] = 2;
    420443        if (l2.status=="Open")
    421444            data.status[1] = 1;
     
    429452        data.position[1] = l2.position;
    430453
     454        fDim.setQuality(GetState());
    431455        fDim.Update(data);
    432456    }
     
    544568                     "Connection established, but status still not known");
    545569
     570        T::AddStateName(Lid::State::kUnidentified, "Unidentified",
     571                     "At least one lid reported a state which could not be identified by lidctrl");
     572
    546573        T::AddStateName(Lid::State::kInconsistent, "Inconsistent",
    547574                     "Both lids show different states");
     
    549576        T::AddStateName(Lid::State::kUnknown, "Unknown",
    550577                     "Arduino reports at least one lids in an unknown status");
     578
     579        T::AddStateName(Lid::State::kPowerProblem, "PowerProblem",
     580                     "Arduino reports both lids to have a power problem (might also be that both are at the end switches)");
    551581
    552582        T::AddStateName(Lid::State::kClosed, "Closed",
     
    566596             "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
    567597
    568         T::AddEvent("OPEN", Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kClosed)
     598        T::AddEvent("OPEN", Lid::State::kUnidentified, Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kPowerProblem, Lid::State::kClosed)
    569599            (bind(&StateMachineLidControl::Open, this))
    570600            ("Open the lids");
    571601
    572         T::AddEvent("CLOSE", Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kOpen)
     602        T::AddEvent("CLOSE", Lid::State::kUnidentified, Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kPowerProblem, Lid::State::kOpen)
    573603            (bind(&StateMachineLidControl::Close, this))
    574604            ("Close the lids");
Note: See TracChangeset for help on using the changeset viewer.