From 86dbfde520d3281b61b9f0639cae256b862254f8 Mon Sep 17 00:00:00 2001 From: PlayWithIt Date: Mon, 23 Feb 2015 13:50:41 +0100 Subject: [PATCH] Improved GUI support (not in archive), Temperature_IR --- src/stubserver/DeviceBarometer.cpp | 12 +- src/stubserver/DeviceBarometer.h | 2 +- src/stubserver/DeviceFunctions.cpp | 34 +- src/stubserver/DeviceFunctions.h | 11 +- src/stubserver/DeviceHallEffect.cpp | 12 +- src/stubserver/DeviceHallEffect.h | 2 +- src/stubserver/DeviceInOut.cpp | 20 +- src/stubserver/DeviceLCD.cpp | 22 +- src/stubserver/DeviceLCD.h | 2 +- src/stubserver/DeviceLedStrip.cpp | 4 +- src/stubserver/DeviceMotionDetector.cpp | 12 +- src/stubserver/DeviceMotionDetector.h | 2 +- src/stubserver/DevicePiezoSpeaker.cpp | 4 +- src/stubserver/DeviceRelay.cpp | 38 +- src/stubserver/DeviceRelay.h | 2 +- src/stubserver/DeviceSensor.cpp | 16 +- src/stubserver/DeviceSensor.h | 2 +- src/stubserver/DeviceTilt.cpp | 12 +- src/stubserver/DeviceTilt.h | 2 +- src/stubserver/DeviceTouchPad.cpp | 4 +- src/stubserver/DeviceVoltageCurrent.cpp | 8 +- src/stubserver/SimulatedDevice.cpp | 39 +- src/stubserver/SimulatedDevice.h | 10 +- ...tionClient.cpp => VisualizationClient.cpp} | 12 +- ...lisationClient.h => VisualizationClient.h} | 47 +- src/stubserver/vp_sound_input2.txt | 1041 +++++++++++++++++ 26 files changed, 1226 insertions(+), 146 deletions(-) rename src/stubserver/{VisualisationClient.cpp => VisualizationClient.cpp} (89%) rename src/stubserver/{VisualisationClient.h => VisualizationClient.h} (80%) create mode 100644 src/stubserver/vp_sound_input2.txt diff --git a/src/stubserver/DeviceBarometer.cpp b/src/stubserver/DeviceBarometer.cpp index 70bb391..06b72c2 100644 --- a/src/stubserver/DeviceBarometer.cpp +++ b/src/stubserver/DeviceBarometer.cpp @@ -46,7 +46,7 @@ int DeviceBarometer::getAltitude(int pressure) const } -bool DeviceBarometer::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceBarometer::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { if (values == NULL) throw utils::Exception("ValueProvider not set!"); @@ -104,16 +104,16 @@ bool DeviceBarometer::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visua } // other get set functions - return getSetRefPressure->consumeCommand(relativeTimeMs, p, visualisationClient); + return getSetRefPressure->consumeCommand(relativeTimeMs, p, visualizationClient); } -void DeviceBarometer::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceBarometer::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { int currentValue; - if (visualisationClient.useAsInputSource()) { - currentValue = visualisationClient.getInputState(); + if (visualizationClient.useAsInputSource()) { + currentValue = visualizationClient.getInputState(); if (currentValue != sensorValue) sensorValue = currentValue; } @@ -122,7 +122,7 @@ void DeviceBarometer::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, if (currentValue != sensorValue) { sensorValue = currentValue; - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); } } diff --git a/src/stubserver/DeviceBarometer.h b/src/stubserver/DeviceBarometer.h index a78dc63..84d5596 100644 --- a/src/stubserver/DeviceBarometer.h +++ b/src/stubserver/DeviceBarometer.h @@ -11,7 +11,7 @@ #include #include "DeviceFunctions.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { diff --git a/src/stubserver/DeviceFunctions.cpp b/src/stubserver/DeviceFunctions.cpp index 0490a9a..7077342 100644 --- a/src/stubserver/DeviceFunctions.cpp +++ b/src/stubserver/DeviceFunctions.cpp @@ -125,20 +125,20 @@ ArrayDevice::~ArrayDevice() } -bool ArrayDevice::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool ArrayDevice::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { uint8_t itemNo = p.uint8Value; memmove(p.fullData.payload, p.fullData.payload + 1, sizeof(p.fullData.payload) - 1); if (itemNo < others.size()) - return others[itemNo]->consumeCommand(relativeTimeMs, p, visualisationClient); + return others[itemNo]->consumeCommand(relativeTimeMs, p, visualizationClient); if (itemNo == 255) { printf("Delegate to ALL other devices\n"); bool result = false; for (auto it : others) - result = it->consumeCommand(relativeTimeMs, p, visualisationClient); + result = it->consumeCommand(relativeTimeMs, p, visualizationClient); return result; } @@ -152,10 +152,10 @@ bool ArrayDevice::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa /** * Trigger all other objects. */ -void ArrayDevice::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void ArrayDevice::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { for (auto it : others) { - it->checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); + it->checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); } } @@ -200,7 +200,7 @@ DoNothing::~DoNothing() * First check if the other function supports this packet, if not * check for this function and ignore it. */ -bool DoNothing::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DoNothing::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { for (auto it : functionCodes) { @@ -214,7 +214,7 @@ bool DoNothing::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisati } } - if (other && other->consumeCommand(relativeTimeMs, p, visualisationClient)) + if (other && other->consumeCommand(relativeTimeMs, p, visualizationClient)) return true; return false; @@ -229,10 +229,10 @@ DeviceFunctions* DoNothing::clone() const /** * Just delegate to other function set since here we have no callbacks. */ -void DoNothing::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DoNothing::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { if (other) - other->checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); + other->checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); } @@ -293,7 +293,7 @@ void GetSetRaw::enableCallback(uint8_t getCallbackFuncCode, uint8_t setCallbackF * First check if the other function supports this packet, if not * check for this function and ignore it. */ -bool GetSetRaw::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool GetSetRaw::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { p.header.length = sizeof(p.header); @@ -324,7 +324,7 @@ bool GetSetRaw::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisati return true; } - if (other && other->consumeCommand(relativeTimeMs, p, visualisationClient)) + if (other && other->consumeCommand(relativeTimeMs, p, visualizationClient)) return true; return false; @@ -333,7 +333,7 @@ bool GetSetRaw::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisati /** * Check for the getCurrentValue callback and call other callbacks. */ -void GetSetRaw::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void GetSetRaw::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { if (getFunctionIntermediate != 0) updateIntermediateValue(); @@ -342,7 +342,7 @@ void GetSetRaw::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickS triggerCallback(uid, brickStack); } if (other) - other->checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); + other->checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); } /** @@ -422,7 +422,7 @@ DeviceFunctions* EnableDisableBool::clone() const * First check if the other function supports this packet, if not * check for this function and ignore it. */ -bool EnableDisableBool::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool EnableDisableBool::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { p.header.length = sizeof(p.header); if (getFunction == p.header.function_id) { @@ -439,7 +439,7 @@ bool EnableDisableBool::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Vis return true; } - if (other && other->consumeCommand(relativeTimeMs, p, visualisationClient)) + if (other && other->consumeCommand(relativeTimeMs, p, visualizationClient)) return true; return false; @@ -448,10 +448,10 @@ bool EnableDisableBool::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Vis /** * Just delegate to other function set since here we have no callbacks. */ -void EnableDisableBool::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void EnableDisableBool::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { if (other) - other->checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); + other->checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); } } /* namespace stubserver */ diff --git a/src/stubserver/DeviceFunctions.h b/src/stubserver/DeviceFunctions.h index 5ab1d94..63965fe 100644 --- a/src/stubserver/DeviceFunctions.h +++ b/src/stubserver/DeviceFunctions.h @@ -26,9 +26,8 @@ #include #include -#include "PacketTypes.h" #include "CallbackData.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" typedef std::lock_guard MutexLock; @@ -116,21 +115,21 @@ class DeviceFunctions /** * This method is called by the BrickStack if a client command comes in. */ - virtual bool consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) = 0; + virtual bool consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) = 0; /** * This method is called periodically (about each ms) in order to check if a callback * must be triggered. */ - virtual void checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) = 0; + virtual void checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) = 0; }; /** * Since we have quite a lot of derived classes: use a macro here to simplify interface changes. */ #define DECLARE_OWN_DEVICE_CALLBACKS \ - virtual bool consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) override; \ - virtual void checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) override; + virtual bool consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) override; \ + virtual void checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) override; /** diff --git a/src/stubserver/DeviceHallEffect.cpp b/src/stubserver/DeviceHallEffect.cpp index 3c1cf94..6d95b5b 100644 --- a/src/stubserver/DeviceHallEffect.cpp +++ b/src/stubserver/DeviceHallEffect.cpp @@ -43,7 +43,7 @@ DeviceHallEffect::~DeviceHallEffect() } -bool DeviceHallEffect::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceHallEffect::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -97,12 +97,12 @@ bool DeviceHallEffect::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visu } } -void DeviceHallEffect::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceHallEffect::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { - int newValue = visualisationClient.getInputState(); + int newValue = visualizationClient.getInputState(); - if (visualisationClient.useAsInputSource()) - newValue = visualisationClient.getInputState(); + if (visualizationClient.useAsInputSource()) + newValue = visualizationClient.getInputState(); else newValue = valueProvider->getValue(relativeTimeMs); @@ -123,7 +123,7 @@ void DeviceHallEffect::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, } sensorValue = newValue; - notify(visualisationClient); + notify(visualizationClient); // edge interrupt if (edgeInterrupt > 0 && counter - latestInterrupt >= edgeInterrupt) { diff --git a/src/stubserver/DeviceHallEffect.h b/src/stubserver/DeviceHallEffect.h index 61cdd5a..c1e0153 100644 --- a/src/stubserver/DeviceHallEffect.h +++ b/src/stubserver/DeviceHallEffect.h @@ -21,7 +21,7 @@ #define STUBSERVER_DEVICEHALLEFFECT_H_ #include "DeviceFunctions.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { diff --git a/src/stubserver/DeviceInOut.cpp b/src/stubserver/DeviceInOut.cpp index d67162c..2239a8b 100644 --- a/src/stubserver/DeviceInOut.cpp +++ b/src/stubserver/DeviceInOut.cpp @@ -61,7 +61,7 @@ void DeviceDigitalIn::changeValueProvider(utils::ValueProvider *newValueProvider } -bool DeviceDigitalIn::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceDigitalIn::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -150,7 +150,7 @@ bool DeviceDigitalIn::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visua } -void DeviceDigitalIn::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceDigitalIn::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { unsigned newValue = valueProvider->getValue(relativeTimeMs); @@ -212,7 +212,7 @@ DeviceInOut::DeviceInOut(utils::ValueProvider *vp, unsigned numPins) } -bool DeviceInOut::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceInOut::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -231,13 +231,13 @@ bool DeviceInOut::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa return true; } - if (DeviceDigitalIn::consumeCommand(relativeTimeMs, p, visualisationClient)) + if (DeviceDigitalIn::consumeCommand(relativeTimeMs, p, visualizationClient)) return true; - return DeviceRelay::consumeCommand(relativeTimeMs, p, visualisationClient); + return DeviceRelay::consumeCommand(relativeTimeMs, p, visualizationClient); } -void DeviceInOut::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceInOut::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { } @@ -252,16 +252,16 @@ DeviceInOut16::DeviceInOut16(utils::ValueProvider *a, utils::ValueProvider *b) } -bool DeviceInOut16::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceInOut16::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { return false; } -void DeviceInOut16::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceInOut16::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { - portA.checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); - portB.checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); + portA.checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); + portB.checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); } } /* namespace stubserver */ diff --git a/src/stubserver/DeviceLCD.cpp b/src/stubserver/DeviceLCD.cpp index 946e93d..fbf09ee 100644 --- a/src/stubserver/DeviceLCD.cpp +++ b/src/stubserver/DeviceLCD.cpp @@ -43,7 +43,7 @@ DeviceLCD::DeviceLCD(unsigned _cols, unsigned _lines) /** * */ -bool DeviceLCD::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceLCD::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -77,31 +77,31 @@ bool DeviceLCD::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisati cursorY = l; changedLine = l; - notify(visualisationClient, TEXT_CHANGE); + notify(visualizationClient, TEXT_CHANGE); return true; case LCD_20X4_FUNCTION_CLEAR_DISPLAY: for (unsigned i = 0; i < lines; ++i) { text[i] = std::string(cols, ' '); } - notify(visualisationClient, CLEAR_SCREEN); + notify(visualizationClient, CLEAR_SCREEN); return true; case LCD_20X4_FUNCTION_BACKLIGHT_ON: backlightOn = true; - notify(visualisationClient, LIGHT_CHANGE); + notify(visualizationClient, LIGHT_CHANGE); return true; case LCD_20X4_FUNCTION_BACKLIGHT_OFF: backlightOn = false; - notify(visualisationClient, LIGHT_CHANGE); + notify(visualizationClient, LIGHT_CHANGE); return true; case LCD_20X4_FUNCTION_SET_CONFIG: cursorVisible = p.fullData.payload[0] != 0; blinking = p.fullData.payload[1] != 0; - notify(visualisationClient, CURSOR_CHANGE); + notify(visualizationClient, CURSOR_CHANGE); return true; case LCD_20X4_FUNCTION_GET_CONFIG: @@ -135,7 +135,7 @@ bool DeviceLCD::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisati } memcpy(customChar + (index * 8), p.fullData.payload + 1, 8); changedLine = index; - notify(visualisationClient, CUSTOM_CHAR); + notify(visualizationClient, CUSTOM_CHAR); } return true; @@ -179,12 +179,12 @@ const uint8_t* DeviceLCD::getCustomerChar(unsigned index) const * Sets the default text if the counter has reached 0 or triggers some * button press/release events if those are active. */ -void DeviceLCD::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceLCD::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { unsigned newValue; - if (visualisationClient.useAsInputSource()) - newValue = visualisationClient.getInputState(); + if (visualizationClient.useAsInputSource()) + newValue = visualizationClient.getInputState(); else newValue = 0; @@ -216,7 +216,7 @@ void DeviceLCD::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickS text[i] = defaultText[i]; } changedLine = -1; - notify(visualisationClient, TEXT_CHANGE); + notify(visualizationClient, TEXT_CHANGE); counter = -1; } else if (counter > 0) diff --git a/src/stubserver/DeviceLCD.h b/src/stubserver/DeviceLCD.h index b1a02b8..c5eeef2 100644 --- a/src/stubserver/DeviceLCD.h +++ b/src/stubserver/DeviceLCD.h @@ -23,7 +23,7 @@ #include #include "DeviceFunctions.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { diff --git a/src/stubserver/DeviceLedStrip.cpp b/src/stubserver/DeviceLedStrip.cpp index a7a461f..e0d7e28 100644 --- a/src/stubserver/DeviceLedStrip.cpp +++ b/src/stubserver/DeviceLedStrip.cpp @@ -40,7 +40,7 @@ DeviceLedStrip::DeviceLedStrip() } -bool DeviceLedStrip::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceLedStrip::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { unsigned index, length, last; @@ -128,7 +128,7 @@ bool DeviceLedStrip::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visual } } -void DeviceLedStrip::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceLedStrip::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { if (frameRenderedCb.mayExecute(relativeTimeMs)) { diff --git a/src/stubserver/DeviceMotionDetector.cpp b/src/stubserver/DeviceMotionDetector.cpp index 629a45a..c61d7dd 100644 --- a/src/stubserver/DeviceMotionDetector.cpp +++ b/src/stubserver/DeviceMotionDetector.cpp @@ -38,7 +38,7 @@ DeviceMotionDetector::~DeviceMotionDetector() } -bool DeviceMotionDetector::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceMotionDetector::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -55,11 +55,11 @@ bool DeviceMotionDetector::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, } } -void DeviceMotionDetector::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceMotionDetector::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { - if (visualisationClient.useAsInputSource()) + if (visualizationClient.useAsInputSource()) { - int newValue = visualisationClient.getInputState() != 0 ? 1 : 0; + int newValue = visualizationClient.getInputState() != 0 ? 1 : 0; if (newValue == false && newValue != sensorValue) { IOPacket packet(uid, MOTION_DETECTOR_CALLBACK_DETECTION_CYCLE_ENDED); @@ -79,7 +79,7 @@ void DeviceMotionDetector::checkCallbacks(uint64_t relativeTimeMs, unsigned int IOPacket packet(uid, MOTION_DETECTOR_CALLBACK_DETECTION_CYCLE_ENDED); brickStack->dispatchCallback(packet); sensorValue = false; - notify(visualisationClient); + notify(visualizationClient); } } // a new motion will be detected only with small break of 1,5 seconds from the last cycle @@ -89,7 +89,7 @@ void DeviceMotionDetector::checkCallbacks(uint64_t relativeTimeMs, unsigned int brickStack->dispatchCallback(packet); sensorValue = true; motionEnd = relativeTimeMs + 5000; // 5 seconds after start - notify(visualisationClient); + notify(visualizationClient); } } diff --git a/src/stubserver/DeviceMotionDetector.h b/src/stubserver/DeviceMotionDetector.h index 53f27a8..2a67b99 100644 --- a/src/stubserver/DeviceMotionDetector.h +++ b/src/stubserver/DeviceMotionDetector.h @@ -21,7 +21,7 @@ #define STUBSERVER_DEVICEMOTIONDETECTOR_H_ #include "DeviceFunctions.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { diff --git a/src/stubserver/DevicePiezoSpeaker.cpp b/src/stubserver/DevicePiezoSpeaker.cpp index af9aa5d..c7447e8 100644 --- a/src/stubserver/DevicePiezoSpeaker.cpp +++ b/src/stubserver/DevicePiezoSpeaker.cpp @@ -41,7 +41,7 @@ DevicePiezoSpeaker::~DevicePiezoSpeaker() /** * Check for known function codes. */ -bool DevicePiezoSpeaker::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &) +bool DevicePiezoSpeaker::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -118,7 +118,7 @@ bool DevicePiezoSpeaker::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Vi /** * Check for the switchDone callbacks. */ -void DevicePiezoSpeaker::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &) +void DevicePiezoSpeaker::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &) { if (sendCallback && callbackTime <= relativeTimeMs) { diff --git a/src/stubserver/DeviceRelay.cpp b/src/stubserver/DeviceRelay.cpp index 30be396..ad48f4e 100644 --- a/src/stubserver/DeviceRelay.cpp +++ b/src/stubserver/DeviceRelay.cpp @@ -54,7 +54,7 @@ DeviceRelay::DeviceRelay(unsigned n, bool _bitSwitches) /** * Check for known function codes. */ -bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -67,7 +67,7 @@ bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa { for (unsigned x = 0; x < numSwitches; ++x) switchOn[x] = p.fullData.payload[x] != 0; - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; } @@ -77,7 +77,7 @@ bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa switchOn[x] = p.uint16Value & bitMask; bitMask <<= 1; } - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; } @@ -91,7 +91,7 @@ bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa return false; } switchOn[n] = p.fullData.payload[1] != 0; - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; } @@ -104,7 +104,7 @@ bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa if ((selection & bit) != 0) switchOn[i] = (bits & bit) != 0; } - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; } @@ -184,7 +184,7 @@ bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa //stateChanged = true; switchOn[n] = p.fullData.payload[1] != 0; callbacks[n].update(relativeTimeMs, p.monoflopResponse.time, n+1, !switchOn[n]); - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; } @@ -201,19 +201,19 @@ bool DeviceRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisa callbacks[i].update(relativeTimeMs, p.monoflopDefine.time, i, !switchOn[i]); } } - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; } if (other) - return other->consumeCommand(relativeTimeMs, p, visualisationClient); + return other->consumeCommand(relativeTimeMs, p, visualizationClient); return false; } /** * Check for monoflop callbacks. */ -void DeviceRelay::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceRelay::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { for (auto it = callbacks.begin(); it != callbacks.end(); ++it) { @@ -240,12 +240,12 @@ void DeviceRelay::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, Bric } //stateChanged = true; brickStack->dispatchCallback(packet); - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); } } if (other) - other->checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); + other->checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); } /** @@ -277,7 +277,7 @@ DeviceSolidStateRelay::DeviceSolidStateRelay() /** * Check for known function codes. */ -bool DeviceSolidStateRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceSolidStateRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -327,7 +327,7 @@ bool DeviceSolidStateRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, /** * Check callbacks for solid state relay. */ -void DeviceSolidStateRelay::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceSolidStateRelay::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { for (auto it = callbacks.begin(); it != callbacks.end(); ++it) { @@ -447,7 +447,7 @@ void DeviceRemoteRelay::updateRelay(const char *id, uint8_t state) /** * Check for known function codes. */ -bool DeviceRemoteRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceRemoteRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { char buf[32]; const char *fmt; @@ -486,7 +486,7 @@ bool DeviceRemoteRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Vis fmt = p.header.function_id == REMOTE_SWITCH_FUNCTION_SWITCH_SOCKET_C ? "Type C:\nSC: %c\nDC: %d" : "Type A:\nHC: 0x%X\nRC: 0x%X"; sprintf(buf, fmt, p.fullData.payload[0], p.fullData.payload[1]); updateRelay(buf, p.fullData.payload[2]); - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; case REMOTE_SWITCH_FUNCTION_SWITCH_SOCKET_B: @@ -500,7 +500,7 @@ bool DeviceRemoteRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Vis sprintf(buf, "Type B:\nA: %u\nU: %u", p.uint32Value, p.fullData.payload[4]); updateRelay(buf, p.fullData.payload[5] ? true : false); - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); return true; case REMOTE_SWITCH_FUNCTION_DIM_SOCKET_B: @@ -511,19 +511,19 @@ bool DeviceRemoteRelay::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Vis busy = true; switchDoneAtMs = relativeTimeMs + (repeats * 100); - //notify(visualisationClient, VALUE_CHANGE); + //notify(visualizationClient, VALUE_CHANGE); return true; } if (other) - return other->consumeCommand(relativeTimeMs, p, visualisationClient); + return other->consumeCommand(relativeTimeMs, p, visualizationClient); return false; } /** * Check for the switchDone callbacks. */ -void DeviceRemoteRelay::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceRemoteRelay::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { if (busy && switchDoneAtMs <= relativeTimeMs) { diff --git a/src/stubserver/DeviceRelay.h b/src/stubserver/DeviceRelay.h index 24c588f..1fa3199 100644 --- a/src/stubserver/DeviceRelay.h +++ b/src/stubserver/DeviceRelay.h @@ -22,7 +22,7 @@ #define DEVICERELAY_H_ #include "DeviceFunctions.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { diff --git a/src/stubserver/DeviceSensor.cpp b/src/stubserver/DeviceSensor.cpp index 6cac21e..9627ec2 100644 --- a/src/stubserver/DeviceSensor.cpp +++ b/src/stubserver/DeviceSensor.cpp @@ -74,7 +74,7 @@ DeviceSensor::~DeviceSensor() } -bool DeviceSensor::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceSensor::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { if (values == NULL) throw utils::Exception("ValueProvider not set!"); @@ -132,16 +132,19 @@ bool DeviceSensor::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualis return true; } + if (other) + return other->consumeCommand(relativeTimeMs, p, visualizationClient); + return false; } -void DeviceSensor::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceSensor::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { int currentValue; - if (visualisationClient.useAsInputSource()) { - currentValue = visualisationClient.getInputState(); + if (visualizationClient.useAsInputSource()) { + currentValue = visualizationClient.getInputState(getInternalSensorNo()); if (currentValue != sensorValue) sensorValue = currentValue; } @@ -150,7 +153,7 @@ void DeviceSensor::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, Bri if (currentValue != sensorValue) { sensorValue = currentValue; - notify(visualisationClient, VALUE_CHANGE); + notify(visualizationClient, VALUE_CHANGE); } } @@ -172,6 +175,9 @@ void DeviceSensor::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, Bri changedAnalogCb.param1 = v; } + if (other) + other->checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); + // mayExecute also checks the 'option' value ... if (!rangeCallback.mayExecute(relativeTimeMs)) return; diff --git a/src/stubserver/DeviceSensor.h b/src/stubserver/DeviceSensor.h index febbff4..b54a560 100644 --- a/src/stubserver/DeviceSensor.h +++ b/src/stubserver/DeviceSensor.h @@ -20,7 +20,7 @@ #define DEVICESENSOR_H_ #include "DeviceFunctions.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { diff --git a/src/stubserver/DeviceTilt.cpp b/src/stubserver/DeviceTilt.cpp index baf7771..1ea0cb9 100644 --- a/src/stubserver/DeviceTilt.cpp +++ b/src/stubserver/DeviceTilt.cpp @@ -38,7 +38,7 @@ DeviceTilt::~DeviceTilt() } -bool DeviceTilt::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceTilt::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -68,12 +68,12 @@ bool DeviceTilt::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visualisat } } -void DeviceTilt::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceTilt::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { - int newValue = visualisationClient.getInputState(); + int newValue = visualizationClient.getInputState(); - if (visualisationClient.useAsInputSource()) - newValue = visualisationClient.getInputState(); + if (visualizationClient.useAsInputSource()) + newValue = visualizationClient.getInputState(); else newValue = valueProvider->getValue(relativeTimeMs); @@ -87,7 +87,7 @@ void DeviceTilt::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, Brick brickStack->dispatchCallback(packet); } - notify(visualisationClient); + notify(visualizationClient); } } diff --git a/src/stubserver/DeviceTilt.h b/src/stubserver/DeviceTilt.h index 8305e95..a880d86 100644 --- a/src/stubserver/DeviceTilt.h +++ b/src/stubserver/DeviceTilt.h @@ -21,7 +21,7 @@ #define STUBSERVER_DEVICETILT_H_ #include "DeviceFunctions.h" -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { diff --git a/src/stubserver/DeviceTouchPad.cpp b/src/stubserver/DeviceTouchPad.cpp index 32844aa..eb6714d 100644 --- a/src/stubserver/DeviceTouchPad.cpp +++ b/src/stubserver/DeviceTouchPad.cpp @@ -43,7 +43,7 @@ DeviceTouchPad::~DeviceTouchPad() /** * Check for known function codes. */ -bool DeviceTouchPad::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &) +bool DeviceTouchPad::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &) { // set default dummy response size: header only p.header.length = sizeof(p.header); @@ -84,7 +84,7 @@ bool DeviceTouchPad::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, Visual /** * Check for monoflop callbacks. */ -void DeviceTouchPad::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &vc) +void DeviceTouchPad::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &vc) { unsigned newValue; diff --git a/src/stubserver/DeviceVoltageCurrent.cpp b/src/stubserver/DeviceVoltageCurrent.cpp index b4dd841..8fb6afe 100644 --- a/src/stubserver/DeviceVoltageCurrent.cpp +++ b/src/stubserver/DeviceVoltageCurrent.cpp @@ -94,7 +94,7 @@ void DeviceVoltageCurrent::setCurrentValueProvider(ValueProvider *vp) } -bool DeviceVoltageCurrent::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualisationClient &visualisationClient) +bool DeviceVoltageCurrent::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, VisualizationClient &visualizationClient) { uint8_t func = p.header.function_id; p.header.length = sizeof(p.header); @@ -179,13 +179,13 @@ bool DeviceVoltageCurrent::consumeCommand(uint64_t relativeTimeMs, IOPacket &p, } if (other) - return other->consumeCommand(relativeTimeMs, p, visualisationClient); + return other->consumeCommand(relativeTimeMs, p, visualizationClient); return false; } -void DeviceVoltageCurrent::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualisationClient &visualisationClient) +void DeviceVoltageCurrent::checkCallbacks(uint64_t relativeTimeMs, unsigned int uid, BrickStack *brickStack, VisualizationClient &visualizationClient) { int value; if (voltsChangedCb.mayExecute(relativeTimeMs) && @@ -213,7 +213,7 @@ void DeviceVoltageCurrent::checkCallbacks(uint64_t relativeTimeMs, unsigned int } if (other) - other->checkCallbacks(relativeTimeMs, uid, brickStack, visualisationClient); + other->checkCallbacks(relativeTimeMs, uid, brickStack, visualizationClient); } } /* namespace stubserver */ diff --git a/src/stubserver/SimulatedDevice.cpp b/src/stubserver/SimulatedDevice.cpp index c322c27..8533a66 100644 --- a/src/stubserver/SimulatedDevice.cpp +++ b/src/stubserver/SimulatedDevice.cpp @@ -72,7 +72,7 @@ namespace stubserver { //======================================================================================= -static VisualisationClient dummyVisualisationInstance; +static VisualizationClient dummyVisualisationInstance; //======================================================================================= @@ -378,8 +378,21 @@ DeviceFunctions *SimulatedDevice::setupFunctions() TEMPERATURE_IR_FUNCTION_SET_DEBOUNCE_PERIOD, TEMPERATURE_IR_FUNCTION_GET_DEBOUNCE_PERIOD, TEMPERATURE_IR_CALLBACK_AMBIENT_TEMPERATURE_REACHED); - sensor->setValueProvider(createValueProvider(getProperty("valueProvider", "linear min=-500,max=2800,step=5,interval=300"))); + sensor->setValueProvider(createValueProvider(getProperty("valueProviderA", "linear min=-500,max=2800,step=5,interval=300"))); sensor->setMinMax(-4000, 12500); + sensor->setInternalSensorNo(1); + functions = sensor; + + sensor = new DeviceSensor(TEMPERATURE_IR_FUNCTION_GET_OBJECT_TEMPERATURE, + TEMPERATURE_IR_FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD, TEMPERATURE_IR_CALLBACK_OBJECT_TEMPERATURE); + sensor->setRangeCallback(TEMPERATURE_IR_FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD, + TEMPERATURE_IR_FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD, + TEMPERATURE_IR_FUNCTION_SET_DEBOUNCE_PERIOD, + TEMPERATURE_IR_FUNCTION_GET_DEBOUNCE_PERIOD, + TEMPERATURE_IR_CALLBACK_OBJECT_TEMPERATURE_REACHED); + sensor->setValueProvider(createValueProvider(getProperty("valueProviderO", "linear min=-500,max=4500,step=1,interval=5"))); + sensor->setMinMax(-4000, 12500); + sensor->setOther(functions); functions = sensor; break; @@ -446,7 +459,7 @@ SimulatedDevice::SimulatedDevice(BrickStack *_brickStack, const char *_uidStr, u : brickStack(_brickStack) , properties(NULL) , functions(NULL) - , visualisationClient(&dummyVisualisationInstance) + , visualizationClient(&dummyVisualisationInstance) , deviceMutex() , uidStr(_uidStr) , uid(utils::base58Decode(_uidStr)) @@ -477,7 +490,7 @@ SimulatedDevice::SimulatedDevice(BrickStack *_brickStack, const char *_uidStr, c : brickStack(_brickStack) , properties(NULL) , functions(NULL) - , visualisationClient(&dummyVisualisationInstance) + , visualizationClient(&dummyVisualisationInstance) , deviceMutex() , uidStr(_uidStr) , uid(utils::base58Decode(_uidStr)) @@ -568,16 +581,16 @@ SimulatedDevice::SimulatedDevice(BrickStack *_brickStack, const char *_uidStr, c /** clear objects */ SimulatedDevice::~SimulatedDevice() { - visualisationClient->notify(VisibleDeviceState(VisibleDeviceState::DISCONNECT)); + visualizationClient->notify(VisibleDeviceState(VisibleDeviceState::DISCONNECT)); cleanup(); } /** - * Set one VisualisationClient which must exist as long as it is registered here! + * Set one VisualizationClient which must exist as long as it is registered here! */ -void SimulatedDevice::setVisualisationClient(VisualisationClient &client) const { - const_cast(this)->visualisationClient = &client; +void SimulatedDevice::setVisualizationClient(VisualizationClient &client) const { + const_cast(this)->visualizationClient = &client; VisibleDeviceState *state = dynamic_cast(functions); if (state) { @@ -587,10 +600,10 @@ void SimulatedDevice::setVisualisationClient(VisualisationClient &client) const } /** - * Clear a VisualisationClient set before using {@link setVisualisationClient(VisualisationClient)}. + * Clear a VisualizationClient set before using {@link setVisualizationClient(VisualizationClient)}. */ -void SimulatedDevice::clearVisualisationClient() const { - const_cast(this)->visualisationClient = &dummyVisualisationInstance; +void SimulatedDevice::clearVisualizationClient() const { + const_cast(this)->visualizationClient = &dummyVisualisationInstance; } @@ -661,7 +674,7 @@ void SimulatedDevice::checkCallbacks() { MutexLock lock(deviceMutex); if (functions) - functions->checkCallbacks(brickStack->getRelativeTimeMs(), uid, brickStack, *visualisationClient); + functions->checkCallbacks(brickStack->getRelativeTimeMs(), uid, brickStack, *visualizationClient); } /** @@ -716,7 +729,7 @@ bool SimulatedDevice::consumePacket(IOPacket &p, bool responseExpected) // if there is a function associated and consumed -> all OK // if not: if responseExpected=false, the packet is just consumed with a warning uint64_t time = brickStack->getRelativeTimeMs(); - if (functions && functions->consumeCommand(time, p, *visualisationClient)) + if (functions && functions->consumeCommand(time, p, *visualizationClient)) return true; if (!responseExpected) { diff --git a/src/stubserver/SimulatedDevice.h b/src/stubserver/SimulatedDevice.h index bb8da68..513ea95 100644 --- a/src/stubserver/SimulatedDevice.h +++ b/src/stubserver/SimulatedDevice.h @@ -41,7 +41,7 @@ class SimulatedDevice BrickStack *brickStack; utils::Properties *properties; DeviceFunctions *functions; - VisualisationClient *visualisationClient; // is always set, maybe a dummy instance + VisualizationClient *visualizationClient; // is always set, maybe a dummy instance // child devices e.g. of a MasterBrick: children are in the stack or at a port a..d std::vector children; @@ -125,14 +125,14 @@ class SimulatedDevice } /** - * Set one VisualisationClient which must exist as long as it is registered here! + * Set one VisualizationClient which must exist as long as it is registered here! */ - void setVisualisationClient(VisualisationClient &client) const; + void setVisualizationClient(VisualizationClient &client) const; /** - * Clear a VisualisationClient set before using {@link setVisualisationClient(VisualisationClient)}. + * Clear a VisualizationClient set before using {@link setVisualizationClient(VisualizationClient)}. */ - void clearVisualisationClient() const; + void clearVisualizationClient() const; /** * Is this device connected to the given brick? This is true if the device is diff --git a/src/stubserver/VisualisationClient.cpp b/src/stubserver/VisualizationClient.cpp similarity index 89% rename from src/stubserver/VisualisationClient.cpp rename to src/stubserver/VisualizationClient.cpp index 67c713a..608cd77 100644 --- a/src/stubserver/VisualisationClient.cpp +++ b/src/stubserver/VisualizationClient.cpp @@ -1,5 +1,5 @@ /* - * VisualisationClient.cpp + * VisualizationClient.cpp * * Copyright (C) 2015 Holger Grosenick * @@ -20,33 +20,33 @@ #include #include -#include "VisualisationClient.h" +#include "VisualizationClient.h" namespace stubserver { VisibleDeviceState::~VisibleDeviceState() { } -VisualisationClient::~VisualisationClient() { } +VisualizationClient::~VisualizationClient() { } /** * Do nothing. */ -void VisualisationClient::notify(const VisibleDeviceState &hint) { +void VisualizationClient::notify(const VisibleDeviceState &hint) { } /** * Default impl: return false. */ -bool VisualisationClient::useAsInputSource() const { +bool VisualizationClient::useAsInputSource(unsigned sn) const { return false; } /** * Default impl. */ -int64_t VisualisationClient::getInputState() const { +int64_t VisualizationClient::getInputState(unsigned sn) const { return 0; } diff --git a/src/stubserver/VisualisationClient.h b/src/stubserver/VisualizationClient.h similarity index 80% rename from src/stubserver/VisualisationClient.h rename to src/stubserver/VisualizationClient.h index 9fee700..eff79a8 100644 --- a/src/stubserver/VisualisationClient.h +++ b/src/stubserver/VisualizationClient.h @@ -1,5 +1,5 @@ /* - * VisualisationClient.h + * VisualizationClient.h * * Copyright (C) 2015 Holger Grosenick * @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#ifndef STUBSERVER_VISUALISATIONCLIENT_H_ -#define STUBSERVER_VISUALISATIONCLIENT_H_ +#ifndef STUBSERVER_VISUALIZATIONCLIENT_H_ +#define STUBSERVER_VISUALIZATIONCLIENT_H_ #include @@ -35,10 +35,10 @@ class VisibleDeviceState; * The client can be input and/or output: if {@link #useAsInputSource()} returns true * the value provider is ignored and the value is read via {@link #getInputState()}. */ -class VisualisationClient +class VisualizationClient { public: - virtual ~VisualisationClient(); + virtual ~VisualizationClient(); /** * This method is called per state change, it should not consume too much CPU @@ -48,35 +48,44 @@ class VisualisationClient /** * A simulated sensor needs simulated values which can come from a ValueProvider - * or from the visualisation, choose the source by this function. The default + * or from the visualization, choose the source by this function. The default * implementation returns false: use ValueProvider. + * + * @param sensorNo the internal sensor number for devices which have more than + * one internal sensor. E.g. temperature IR has ambient and object + * temperature: 2 internal sensors. */ - virtual bool useAsInputSource() const; + virtual bool useAsInputSource(unsigned sensorNo = 0) const; /** * Return a device specific state (0 in default impl). + * @param sensorNo the internal sensor number for devices which have more than one */ - virtual int64_t getInputState() const; + virtual int64_t getInputState(unsigned sensorNo = 0) const; }; /** * A short living object which will be destroyed immediately after the - * method {@link VisualisationClient::notify()} returns. + * method {@link VisualizationClient::notify()} returns. */ class VisibleDeviceState { unsigned changeCode; + unsigned internalSensorNo; public: explicit VisibleDeviceState(unsigned c) - : changeCode(c) { } + : changeCode(c), internalSensorNo(0) { } + + explicit VisibleDeviceState(unsigned c, unsigned sn) + : changeCode(c), internalSensorNo(sn) { } virtual ~VisibleDeviceState(); /** * If an event is triggered with this code, the object gets invalidated. - * If a VisualisationClient holds a reference to a StateChangeHint, it + * If a VisualizationClient holds a reference to a StateChangeHint, it * should clear this reference and may not use it any more. */ static const unsigned DISCONNECT = 0; @@ -95,7 +104,19 @@ class VisibleDeviceState return changeCode; } - void notify(VisualisationClient &client, unsigned code = VALUE_CHANGE) { + unsigned getInternalSensorNo() const { + return internalSensorNo; + } + + /** + * Change the internal sensor number for devices that have more than one. + * The default is 0 for the first (main) sensor. + */ + void setInternalSensorNo(unsigned sn) { + internalSensorNo = sn; + } + + void notify(VisualizationClient &client, unsigned code = VALUE_CHANGE) { changeCode = code; client.notify(*this); } @@ -259,4 +280,4 @@ class RelayState : public VisibleDeviceState } -#endif /* STUBSERVER_VISUALISATIONCLIENT_H_ */ +#endif /* STUBSERVER_VISUALIZATIONCLIENT_H_ */ diff --git a/src/stubserver/vp_sound_input2.txt b/src/stubserver/vp_sound_input2.txt new file mode 100644 index 0000000..5b545c6 --- /dev/null +++ b/src/stubserver/vp_sound_input2.txt @@ -0,0 +1,1041 @@ +# +# Sound input for homestation +# + +0 0 +offset 9000 +0 0 +# -- 2014-12-14 15:08:16 -- MIN 957 -- MAX 1991 -- AVG 1229.35 -- TIME 11973 -- +1 990 +40 1318 +80 1281 +120 1336 +160 1213 +200 1267 +240 1330 +280 1531 +320 1215 +360 1374 +400 1233 +440 1272 +480 1103 +520 1233 +560 1101 +600 1152 +640 1312 +680 1138 +720 1107 +760 1119 +800 1312 +840 1241 +880 1282 +920 1424 +960 1288 +1000 1513 +1040 1179 +1080 1112 +1120 1388 +1160 990 +1200 1304 +1240 1002 +1280 1075 +1320 1090 +1360 1098 +1400 1377 +1440 1016 +1480 1150 +1520 1036 +1560 1119 +1600 1275 +1640 1288 +1680 1308 +1720 1111 +1760 1248 +1800 1138 +1840 1310 +1880 1095 +1920 1372 +1960 1081 +2000 1121 +2040 1264 +2080 966 +2120 1214 +2160 964 +2200 1379 +2240 1325 +2280 1094 +2320 1158 +2361 1126 +2401 1332 +2441 1129 +2481 1253 +2521 1148 +2561 1133 +2601 1237 +2641 1183 +2681 1440 +2721 1190 +2761 1065 +2801 1299 +2845 1016 +2885 1506 +2925 1081 +2965 1330 +3005 1033 +3045 1187 +3085 1113 +3125 1284 +3165 1088 +3205 1150 +3245 1301 +3285 1060 +3325 1340 +3365 1256 +3405 1193 +3445 1129 +3485 1066 +3525 1346 +3565 1135 +3605 1205 +3645 1318 +3685 1260 +3725 1228 +3765 1023 +3805 1212 +3845 1148 +3885 1095 +3925 1319 +3965 1213 +4005 1270 +4045 1237 +4085 1180 +4125 1086 +4165 1228 +4205 1242 +4245 1093 +4285 1288 +4325 1279 +4365 1096 +4405 1225 +4446 1045 +4486 1206 +4526 1335 +4566 1086 +4606 1369 +4646 1991 +4686 1564 +4726 1351 +4766 1178 +4806 1308 +4846 1332 +4886 1201 +4926 1208 +4966 1428 +5006 1294 +5046 1016 +5086 1675 +5126 1105 +5166 1325 +5206 1238 +5246 1207 +5286 1413 +5326 1069 +5366 1271 +5406 1164 +5446 1052 +5486 1068 +5526 1538 +5566 1283 +5606 1007 +5646 1469 +5691 972 +5731 1500 +5772 957 +5812 1431 +5852 1229 +5892 1029 +5932 1234 +5972 1181 +6012 1183 +6052 1108 +6092 1297 +6132 1199 +6172 1310 +6212 1314 +6252 1237 +6292 1416 +6332 1205 +6372 1231 +6412 1282 +6452 991 +6492 1193 +6532 1254 +6572 1447 +6612 1331 +6652 1180 +6692 1293 +6732 1064 +6772 1268 +6812 1357 +6852 1234 +6892 1063 +6932 1408 +6972 1302 +7012 1330 +7052 1414 +7092 1102 +7132 1307 +7172 1211 +7212 1181 +7252 1170 +7292 1060 +7332 1193 +7372 1100 +7412 1193 +7452 1303 +7492 1100 +7532 1343 +7572 1199 +7612 1254 +7652 1302 +7692 1215 +7732 1032 +7772 1375 +7812 1243 +7852 1435 +7892 1110 +7932 1305 +7972 1076 +8012 1345 +8052 1351 +8092 1247 +8132 1372 +8172 1137 +8212 1305 +8252 1384 +8292 1337 +8332 962 +8372 1152 +8412 1271 +8452 1228 +8492 1134 +8532 1183 +8572 1414 +8612 1231 +8652 1302 +8692 1343 +8732 1292 +8772 1229 +8812 1332 +8852 1238 +8892 1162 +8932 1350 +8972 1363 +9012 1264 +9052 1337 +9092 1236 +9132 959 +9172 1314 +9212 1432 +9252 1396 +9292 1337 +9332 1157 +9372 1294 +9412 1406 +9452 1169 +9492 1309 +9532 1287 +9572 1140 +9612 1321 +9652 1171 +9692 1176 +9732 1206 +9772 1141 +9812 1195 +9852 1145 +9892 1219 +9932 1291 +9972 1245 +10012 1210 +10052 1109 +10092 1178 +10132 1265 +10172 1261 +10212 1215 +10252 1344 +10292 1153 +10332 1328 +10372 1182 +10412 1219 +10452 1127 +10492 1124 +10532 1122 +10572 1135 +10612 1258 +10652 1369 +10692 1248 +10732 1293 +10772 1331 +10812 1314 +10852 1288 +10892 1260 +10932 1414 +10972 1317 +11012 1228 +11052 1278 +11092 1403 +11132 1291 +11172 1130 +11212 977 +11252 1253 +11292 1258 +11332 1172 +11372 1161 +11412 1180 +11452 1309 +11492 991 +11532 1078 +11572 1177 +11612 1069 +11652 1387 +11692 1307 +11732 1337 +11772 1326 +11812 1422 +11852 1092 +11892 1274 +11932 1098 +11973 957 +offset 7000 +0 0 +# -- 2014-12-14 09:24:59 -- MIN 964 -- MAX 1832 -- AVG 1417.36 -- TIME 9817 -- +1 964 +40 1361 +80 1544 +120 1815 +160 1799 +200 1462 +240 1398 +280 1607 +320 1321 +360 1621 +400 1385 +440 1832 +480 1414 +520 1576 +560 1635 +600 1230 +640 1778 +680 1712 +720 1339 +760 1564 +800 1523 +840 1492 +880 1565 +920 1600 +960 1702 +1000 1322 +1040 1459 +1080 1198 +1120 1566 +1160 1454 +1200 1344 +1240 1388 +1280 1502 +1320 1314 +1360 1795 +1400 1821 +1440 1453 +1480 1494 +1520 1557 +1560 1395 +1600 1209 +1640 1364 +1680 1234 +1720 1292 +1760 1264 +1800 1573 +1840 1474 +1880 1287 +1920 1396 +1960 1471 +2000 1357 +2040 1229 +2080 1382 +2120 1427 +2160 1299 +2200 1520 +2240 1391 +2280 1247 +2320 1680 +2360 1513 +2400 1529 +2440 1392 +2480 1350 +2520 1460 +2560 1494 +2600 1649 +2640 1370 +2680 1264 +2720 1519 +2760 1589 +2800 1513 +2840 1099 +2880 1414 +2920 1561 +2960 1231 +3000 1106 +3040 1648 +3080 1520 +3120 1479 +3200 1639 +3240 1332 +3280 1497 +3320 1502 +3360 1356 +3400 1369 +3440 1556 +3480 1455 +3520 1508 +3560 1224 +3600 1391 +3640 1420 +3680 1499 +3720 1457 +3760 1046 +3800 1203 +3840 1333 +3880 1422 +3920 1255 +3960 1283 +4000 1576 +4040 1192 +4080 1311 +4120 1634 +4160 1347 +4200 1246 +4240 1526 +4280 1431 +4320 1430 +4360 1539 +4400 1325 +4440 1207 +4480 1389 +4520 1522 +4560 1174 +4601 1504 +4640 1427 +4680 1274 +4720 1204 +4760 1358 +4800 1185 +4840 1171 +4880 1312 +4920 1345 +4960 1498 +5000 1263 +5040 1338 +5080 1442 +5120 1471 +5160 1649 +5200 1279 +5240 1134 +5283 1255 +5323 1750 +5363 1392 +5403 1240 +5443 1602 +5483 1208 +5524 1469 +5563 1455 +5603 1347 +5643 1193 +5683 1250 +5723 1343 +5763 1376 +5803 1216 +5843 1459 +5886 1507 +5923 1239 +5963 1430 +6003 1333 +6044 1438 +6083 1380 +6123 1559 +6163 1648 +6203 1461 +6243 1295 +6283 1513 +6323 1566 +6363 1386 +6403 1624 +6443 1277 +6483 1747 +6523 1308 +6564 1534 +6603 1381 +6643 1346 +6683 1574 +6723 1527 +6763 1547 +6803 1545 +6843 1318 +6886 1413 +6923 1451 +6963 1318 +7003 1143 +7043 1463 +7084 1538 +7123 1480 +7163 1449 +7203 1345 +7243 1310 +7283 1519 +7323 1436 +7363 1435 +7403 1656 +7443 1548 +7483 1453 +7523 1430 +7563 1415 +7604 1273 +7643 1419 +7683 1320 +7723 1332 +7763 1530 +7803 1110 +7843 1276 +7886 1476 +7923 1528 +7963 1577 +8003 1556 +8043 1330 +8083 1385 +8124 1580 +8163 1423 +8203 1407 +8243 1371 +8283 1313 +8323 1668 +8363 1450 +8403 1573 +8443 1446 +8483 1618 +8523 1362 +8563 1353 +8603 1452 +8644 1353 +8683 1327 +8723 1534 +8763 1382 +8803 1527 +8843 1417 +8886 1366 +8923 1476 +8963 1295 +9003 1482 +9043 1530 +9083 1568 +9123 1514 +9164 1246 +9203 1407 +9243 1331 +9283 1173 +9323 981 +9396 966 +9638 1084 +9817 1022 +9900 800 +10000 0 +offset 8000 +0 0 +# -- 2014-12-14 07:47:05 -- MIN 955 -- MAX 1529 -- AVG 1173.11 -- TIME 19543 -- +1 964 +43 967 +83 1360 +123 1118 +163 1310 +203 1285 +243 1114 +283 1273 +323 1262 +363 1141 +403 1050 +443 1059 +485 976 +525 1087 +565 1138 +605 1139 +645 1032 +685 1273 +725 1212 +765 1213 +805 1084 +845 1184 +885 1248 +925 1317 +965 1295 +1005 1073 +1045 1061 +1088 1070 +1128 1190 +1168 1270 +1208 1254 +1248 1064 +1288 982 +1328 1331 +1368 1229 +1408 1137 +1448 1151 +1488 1218 +1528 1321 +1568 1121 +1608 1064 +1648 999 +1688 1095 +1728 1221 +1768 1153 +1808 1164 +1848 1174 +1889 1074 +1929 1158 +1969 1181 +2009 1145 +2049 1178 +2089 1074 +2129 1157 +2169 1129 +2209 1068 +2249 976 +2289 1251 +2329 1151 +2369 1126 +2409 978 +2449 1151 +2489 1213 +2529 1147 +2569 1117 +2609 1058 +2649 1036 +2689 1049 +2729 961 +2769 1185 +2809 1290 +2849 1388 +2889 1237 +2929 971 +2969 1254 +3049 1292 +3089 1081 +3129 1130 +3169 1158 +3209 1236 +3289 1254 +3330 1122 +3370 1003 +3410 1120 +3450 1245 +3490 1221 +3530 1163 +3570 1019 +3610 1067 +3650 1044 +3690 1098 +3730 1026 +3770 1193 +3810 1093 +3850 1142 +3890 1221 +3930 1217 +3970 1044 +4010 1137 +4050 1329 +4090 1169 +4130 1092 +4170 1324 +4210 1297 +4250 1093 +4290 1123 +4330 1269 +4370 1144 +4410 1286 +4450 1128 +4490 1213 +4530 1291 +4570 1259 +4610 1023 +4651 1194 +4690 1257 +4730 1116 +4770 1130 +4810 1213 +4850 1261 +4890 1158 +4930 1209 +4970 1206 +5010 1082 +5050 1210 +5090 1216 +5130 1127 +5170 984 +5211 1172 +5251 1115 +5291 1358 +5331 1146 +5371 1274 +5411 1161 +5451 1130 +5491 1202 +5531 1259 +5571 1164 +5611 1006 +5651 1141 +5691 1159 +5731 1157 +5772 1176 +5812 1007 +5852 1075 +5892 1063 +5932 1095 +5977 1046 +6020 994 +6060 1124 +6104 1038 +6144 1070 +6224 1214 +6264 973 +6304 1180 +6344 1144 +6384 1212 +6424 1127 +6464 1300 +6504 1178 +6547 960 +6587 1215 +6627 1145 +6667 1287 +6707 1322 +6747 1154 +6787 1213 +6827 1241 +6867 1196 +6907 1109 +6947 1236 +6987 1217 +7027 1029 +7067 1046 +7107 1052 +7147 961 +7187 1093 +7227 1256 +7267 1165 +7307 1094 +7347 1008 +7387 1203 +7427 1270 +7467 1216 +7507 1115 +7547 1241 +7587 1145 +7628 1108 +7667 1153 +7707 1005 +7747 1094 +7787 1026 +7827 1279 +7867 1199 +7907 1242 +7947 1191 +7987 1169 +8032 1069 +8072 1217 +8112 1333 +8152 1189 +8192 1065 +8232 1237 +8272 1130 +8312 1148 +8352 1223 +8392 1221 +8432 1205 +8472 1154 +8512 1223 +8552 979 +8592 1080 +8632 1111 +8672 983 +8712 1026 +8752 1194 +8792 1304 +8832 1152 +8872 1264 +8912 1236 +8952 1209 +8993 1196 +9032 972 +9072 1066 +9112 1174 +9152 1266 +9192 1248 +9232 1269 +9272 1078 +9312 1214 +9352 1331 +9392 1085 +9432 1120 +9472 1024 +9513 1241 +9552 1251 +9592 1082 +9632 1231 +9672 985 +9712 1125 +9752 1222 +9792 1240 +9832 1422 +9872 1508 +9912 1179 +9952 1038 +9992 1292 +10033 1298 +10072 1180 +10112 1073 +10152 1325 +10192 1218 +10232 1147 +10272 955 +10312 1304 +10352 1200 +10392 1269 +10432 1066 +10472 1234 +10512 1134 +10553 1209 +10592 1259 +10632 1336 +10672 1309 +10712 1235 +10752 1201 +10792 1164 +10832 973 +10872 1156 +10912 1102 +10952 1075 +10992 1150 +11032 1231 +11073 1171 +11112 1124 +11152 1309 +11192 1305 +11232 1262 +11272 1146 +11312 1051 +11352 1266 +11392 1192 +11432 1272 +11472 1317 +11512 1279 +11552 1044 +11593 1186 +11632 1260 +11672 1269 +11712 1221 +11752 1345 +11792 1160 +11832 1315 +11872 1022 +11912 1197 +11952 1064 +11992 1214 +12032 1221 +12072 1156 +12113 1244 +12152 1100 +12192 1268 +12232 1220 +12273 1065 +12313 1144 +12352 1217 +12392 1111 +12432 1231 +12472 1051 +12512 1312 +12552 1019 +12592 1196 +12633 1273 +12672 1097 +12712 1320 +12752 1124 +12792 1064 +12832 1363 +12872 1303 +12912 1227 +12952 1130 +12992 1187 +13032 1090 +13072 1216 +13112 1173 +13153 1352 +13192 1056 +13232 1179 +13273 1310 +13313 1333 +13352 1053 +13392 1215 +13432 1060 +13472 1216 +13512 1300 +13552 1113 +13592 1216 +13632 1329 +13673 1234 +13712 1259 +13752 1518 +13792 1132 +13832 1219 +13872 1052 +13912 1293 +13952 1250 +13992 1139 +14032 1060 +14072 1171 +14113 1038 +14152 1098 +14193 1215 +14232 1128 +14273 1174 +14313 1342 +14352 1135 +14392 1529 +14432 1057 +14472 1229 +14512 1391 +14552 1204 +14592 1263 +14632 1378 +14672 1302 +14713 1271 +14752 1125 +14792 1199 +14832 1200 +14872 1249 +14912 1284 +14952 1193 +14992 1247 +15032 1121 +15073 1277 +15112 1220 +15156 989 +15196 1055 +15236 1259 +15277 1213 +15317 1329 +15356 1181 +15396 1289 +15436 1073 +15476 1256 +15516 1325 +15556 1248 +15597 1143 +15636 1284 +15676 1166 +15716 1140 +15756 1240 +15796 1312 +15836 1172 +15876 1250 +15917 1255 +15956 1075 +15996 1008 +16036 1159 +16079 1002 +16119 1290 +16159 1096 +16199 1273 +16239 1242 +16280 1371 +16319 1117 +16359 1060 +16400 1087 +16443 1072 +16481 974 +16520 1042 +16560 1262 +16600 1235 +16640 998 +16681 1190 +16720 1220 +16761 1222 +16801 1249 +16841 1330 +16881 1245 +16921 1169 +16961 1090 +17001 1130 +17041 1078 +17081 1172 +17121 1234 +17161 960 +17201 1228 +17241 1171 +17281 1191 +17321 1177 +17361 1062 +17401 1148 +17443 1194 +17481 1216 +17521 1246 +17561 1220 +17601 1234 +17641 1221 +17681 1294 +17721 1180 +17761 1208 +17801 1178 +17841 1000 +17881 1178 +17921 1147 +17961 957 +18001 1258 +18041 1246 +18081 1098 +18121 1082 +18161 1293 +18206 1103 +18254 1113 +18294 1006 +18334 1027 +18374 1201 +18414 1259 +18454 1104 +18496 1122 +18534 1243 +18574 1188 +18614 1246 +18654 1272 +18694 1171 +18734 1173 +18774 1352 +18814 1126 +18854 1026 +18894 1078 +18934 1079 +18974 1140 +19014 1208 +19054 1094 +19094 1314 +19134 1231 +19174 1075 +19214 1286 +19254 1281 +19294 1157 +19334 1161 +19374 1312 +19414 1314 +19454 1251 +19496 1302 +19543 1038 +19593 500 +20030 0 +offset 5000 +0 0