Skip to content

Commit

Permalink
Improved GUI support (not in archive), Temperature_IR
Browse files Browse the repository at this point in the history
  • Loading branch information
PlayWithIt committed Feb 23, 2015
1 parent 2e97cce commit 86dbfde
Show file tree
Hide file tree
Showing 26 changed files with 1,226 additions and 146 deletions.
12 changes: 6 additions & 6 deletions src/stubserver/DeviceBarometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/stubserver/DeviceBarometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <utils/ValueProvider.h>

#include "DeviceFunctions.h"
#include "VisualisationClient.h"
#include "VisualizationClient.h"

namespace stubserver {

Expand Down
34 changes: 17 additions & 17 deletions src/stubserver/DeviceFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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);
}


Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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 */
11 changes: 5 additions & 6 deletions src/stubserver/DeviceFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
#include <string.h>
#include <utils/ValueProvider.h>

#include "PacketTypes.h"
#include "CallbackData.h"
#include "VisualisationClient.h"
#include "VisualizationClient.h"

typedef std::lock_guard<std::mutex> MutexLock;

Expand Down Expand Up @@ -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;


/**
Expand Down
12 changes: 6 additions & 6 deletions src/stubserver/DeviceHallEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/stubserver/DeviceHallEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define STUBSERVER_DEVICEHALLEFFECT_H_

#include "DeviceFunctions.h"
#include "VisualisationClient.h"
#include "VisualizationClient.h"

namespace stubserver {

Expand Down
20 changes: 10 additions & 10 deletions src/stubserver/DeviceInOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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)
{

}
Expand All @@ -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 */
Loading

0 comments on commit 86dbfde

Please sign in to comment.