Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
Diff: src/OutputTask/OutputTask.cpp
- Revision:
- 74:03ccf04998b5
- Parent:
- 72:3754b352f156
- Child:
- 75:96512ccc0443
--- a/src/OutputTask/OutputTask.cpp Fri Sep 16 21:44:38 2016 +0000 +++ b/src/OutputTask/OutputTask.cpp Mon Sep 19 12:54:55 2016 +0000 @@ -13,33 +13,11 @@ static int createOutput(const char *controlFile); static void loadPersistentOutputs(void); +// local helpers static int enableOutputReq (const char* id, unsigned int pri, const char* output); static int disableOutputReq(const char *id, unsigned int pri, const char *output); static int unregisterControl(const char *id, unsigned int pri, const char *output); -class Control -{ -private: - string id; - unsigned int priority; - ControlState state; -public: - Control(string id, unsigned int priority, ControlState state) : - id(id), priority(priority), state(state) {} - void display() { - printf("[%s | %s | %u]", - id.c_str(), (state == CONTROL_ON) ? "ON" : "OFF", priority); - } - //void setId(string id) id(id) { } - string getId() { - return id; - } - void setState(ControlState _state) { - state = _state; - } -}; - - typedef std::map<string, vector<Control> > StringOutputVector_t; StringOutputVector_t outputMap; @@ -64,10 +42,12 @@ osEvent evt = OutputMasterMailBox.get(); if (evt.status == osEventMail) { OutputControlMsg_t *msg = (OutputControlMsg_t*) evt.value.p; +#if 0 printf("\r%s received message from someone...\n", __func__); printf("\rmsg->relay = %s\n", msg->output); printf("\rmsg->state = %s\n", msg->state == ON ? "ON" : "OFF"); printf("\rmsg->priority = %u\n", msg->priority); +#endif switch ( msg->action ) { case ACTION_NEW: @@ -192,7 +172,6 @@ return 0; } - /***************************************************************************** * Function: disableOutputReq * Description: @@ -230,6 +209,16 @@ return 0; } +/***************************************************************************** + * Function: unregisterControl + * Description: + * + * @param id -> control identifier + * @param pri -> priority + * @param output -> output (e.g. "o_rly5) + * + * @return 0 on success; -1 on error + *****************************************************************************/ static int unregisterControl(const char *id, unsigned int pri, const char *output) { // attempt to find the output in the map @@ -250,7 +239,7 @@ pos->second.erase(v); break; } - } + } return 0; } @@ -288,6 +277,8 @@ string id = json_value["id"].get<string>(); printf("\r %s id = %s loaded\n", __func__, id.c_str()); + + // emplace the empty control vector into the outputm map vector<Control> v; outputMap[id] = v; }