Skip to content

Commit

Permalink
autogen update
Browse files Browse the repository at this point in the history
  • Loading branch information
Perry committed Nov 26, 2016
1 parent 0674d42 commit 27c59e7
Show file tree
Hide file tree
Showing 29 changed files with 2,297 additions and 2,048 deletions.
301 changes: 134 additions & 167 deletions ArduinoMsgCodec.h
Original file line number Diff line number Diff line change
@@ -1,178 +1,145 @@
#ifndef ArduinoMsgCodec_h
#define ArduinoMsgCodec_h
#ifndef ArduinoMsgCodec_h
#define ArduinoMsgCodec_h

/*******************************************************************
* MRLCOMM FUNCTION GENERATED INTERFACE
* this file was generated by ArduinoMsgCodec and ArduinoMsgCodec.h.template
* these defines are generated with :
* arduinoMsgs.schema
* ArduinoMsgGenerator
* src\resource\Arduino\generate\ArduinoMsgCodec.template.h
*/

///// INO GENERATED DEFINITION BEGIN //////
// {publishMRLCommError Integer}
#define PUBLISH_MRLCOMM_ERROR 1
// {getVersion}
#define GET_VERSION 2
// {publishVersion Integer}
#define PUBLISH_VERSION 3
// {analogWrite int int}
#define ANALOG_WRITE 4
// {controllerAttach Arduino int}
#define CONTROLLER_ATTACH 5
// {createI2cDevice I2CControl int int}
#define CREATE_I2C_DEVICE 6
// {customMsg int[]}
#define CUSTOM_MSG 7
// {deviceAttach DeviceControl Object[]}
#define DEVICE_ATTACH 8
// {deviceDetach DeviceControl}
#define DEVICE_DETACH 9
// {digitalWrite int int}
#define DIGITAL_WRITE 10
// {disableBoardStatus}
#define DISABLE_BOARD_STATUS 11
// {disablePin int}
#define DISABLE_PIN 12
// {disablePins}
#define DISABLE_PINS 13
// {enableBoardStatus int}
#define ENABLE_BOARD_STATUS 14
// {enablePin int}
#define ENABLE_PIN 15
// {getMrlPinType PinDefinition}
#define GET_MRL_PIN_TYPE 16
// {heartbeat}
#define HEARTBEAT 17
// {i2cRead I2CControl int int byte[] int}
#define I2C_READ 18
// {i2cReturnData SensorData}
#define I2C_RETURN_DATA 19
// {i2cWrite I2CControl int int byte[] int}
#define I2C_WRITE 20
// {i2cWriteRead I2CControl int int byte[] int byte[] int}
#define I2C_WRITE_READ 21
// {intsToString int[] int int}
#define INTS_TO_STRING 22
// {isAttached}
#define IS_ATTACHED 23
// {motorMove MotorControl}
#define MOTOR_MOVE 24
// {motorMoveTo MotorControl}
#define MOTOR_MOVE_TO 25
// {motorReset MotorControl}
#define MOTOR_RESET 26
// {motorStop MotorControl}
#define MOTOR_STOP 27
// {msgRoute}
#define MSG_ROUTE 28
// {neoPixelSetAnimation NeoPixel int int int int int}
#define NEO_PIXEL_SET_ANIMATION 29
// {neoPixelWriteMatrix NeoPixel List}
#define NEO_PIXEL_WRITE_MATRIX 30
// {onSensorData SensorData}
#define ON_SENSOR_DATA 31
// {pinMode int String}
#define PIN_MODE 32
// {publishAttachedDevice String}
#define PUBLISH_ATTACHED_DEVICE 33
// {publishBoardInfo BoardInfo}
#define PUBLISH_BOARD_INFO 34
// {publishBoardStatus BoardStatus}
#define PUBLISH_BOARD_STATUS 35
// {publishCustomMsg int[]}
#define PUBLISH_CUSTOM_MSG 36
// {publishDebug String}
#define PUBLISH_DEBUG 37
// {publishMessageAck}
#define PUBLISH_MESSAGE_ACK 38
// {publishPin PinData}
#define PUBLISH_PIN 39
// {publishPinArray PinData[]}
#define PUBLISH_PIN_ARRAY 40
// {publishPinDefinition PinDefinition}
#define PUBLISH_PIN_DEFINITION 41
// {publishPulse Long}
#define PUBLISH_PULSE 42
// {publishPulseStop Integer}
#define PUBLISH_PULSE_STOP 43
// {publishSensorData SensorData}
#define PUBLISH_SENSOR_DATA 44
// {publishServoEvent Integer}
#define PUBLISH_SERVO_EVENT 45
// {publishTrigger Pin}
#define PUBLISH_TRIGGER 46
// {pulse int int int int}
#define PULSE 47
// {pulseStop}
#define PULSE_STOP 48
// {read int}
#define READ 49
// {releaseI2cDevice I2CControl int int}
#define RELEASE_I2C_DEVICE 50
// {sensorActivate SensorControl Object[]}
#define SENSOR_ACTIVATE 51
// {sensorDeactivate SensorControl}
#define SENSOR_DEACTIVATE 52
// {sensorPollingStart String}
#define SENSOR_POLLING_START 53
// {sensorPollingStop String}
#define SENSOR_POLLING_STOP 54
// {servoAttach ServoControl int}
#define SERVO_ATTACH 55
// {servoDetach ServoControl}
#define SERVO_DETACH 56
// {servoSetMaxVelocity ServoControl}
#define SERVO_SET_MAX_VELOCITY 57
// {servoSetVelocity ServoControl}
#define SERVO_SET_VELOCITY 58
// {servoSweepStart ServoControl}
#define SERVO_SWEEP_START 59
// {servoSweepStop ServoControl}
#define SERVO_SWEEP_STOP 60
// {servoWrite ServoControl}
#define SERVO_WRITE 61
// {servoWriteMicroseconds ServoControl int}
#define SERVO_WRITE_MICROSECONDS 62
// {setBoardMegaADK}
#define SET_BOARD_MEGA_ADK 63
// {setDebounce int}
#define SET_DEBOUNCE 64
// {setDebug boolean}
#define SET_DEBUG 65
// {setDigitalTriggerOnly Boolean}
#define SET_DIGITAL_TRIGGER_ONLY 66
// {setPWMFrequency Integer Integer}
#define SET_PWMFREQUENCY 67
// {setSampleRate int}
#define SET_SAMPLE_RATE 68
// {setSerialRate int}
#define SET_SERIAL_RATE 69
// {setTrigger int int int}
#define SET_TRIGGER 70
// {softReset}
#define SOFT_RESET 71
// {write int int}
#define WRITE 72
///// INO GENERATED DEFINITION END //////


/*******************************************************************
* serial protocol functions
*/
#define MAGIC_NUMBER 170 // 10101010
#define MAX_MSG_SIZE 64


// < publishMRLCommError/str errorMsg
#define PUBLISH_MRLCOMM_ERROR 1
// > getBoardInfo
#define GET_BOARD_INFO 2
// < publishBoardInfo/version/boardType
#define PUBLISH_BOARD_INFO 3
// > enableBoardStatus/bool enabled
#define ENABLE_BOARD_STATUS 4
// > enablePin/address/type/b16 rate
#define ENABLE_PIN 5
// > setDebug/bool enabled
#define SET_DEBUG 6
// > setSerialRate/b32 rate
#define SET_SERIAL_RATE 7
// > softReset
#define SOFT_RESET 8
// > enableAck/bool enabled
#define ENABLE_ACK 9
// < publishAck/function
#define PUBLISH_ACK 10
// > enableHeartbeat/bool enabled
#define ENABLE_HEARTBEAT 11
// > heartbeat
#define HEARTBEAT 12
// < publishHeartbeat
#define PUBLISH_HEARTBEAT 13
// > echo/bu32 sInt
#define ECHO 14
// < publishEcho/bu32 sInt
#define PUBLISH_ECHO 15
// > controllerAttach/serialPort
#define CONTROLLER_ATTACH 16
// > customMsg/[] msg
#define CUSTOM_MSG 17
// < publishCustomMsg/[] msg
#define PUBLISH_CUSTOM_MSG 18
// > deviceDetach/deviceId
#define DEVICE_DETACH 19
// > i2cBusAttach/deviceId/i2cBus
#define I2C_BUS_ATTACH 20
// > i2cRead/deviceId/deviceAddress/size
#define I2C_READ 21
// > i2cWrite/deviceId/deviceAddress/[] data
#define I2C_WRITE 22
// > i2cWriteRead/deviceId/deviceAddress/readSize/writeValue
#define I2C_WRITE_READ 23
// < publishI2cData/deviceId/[] data
#define PUBLISH_I2C_DATA 24
// > neoPixelAttach/deviceId/pin/b32 numPixels
#define NEO_PIXEL_ATTACH 25
// > neoPixelSetAnimation/deviceId/animation/red/green/blue/b16 speed
#define NEO_PIXEL_SET_ANIMATION 26
// > neoPixelWriteMatrix/deviceId/[] buffer
#define NEO_PIXEL_WRITE_MATRIX 27
// > analogWrite/pin/value
#define ANALOG_WRITE 28
// > digitalWrite/pin/value
#define DIGITAL_WRITE 29
// > disablePin/pin
#define DISABLE_PIN 30
// > disablePins
#define DISABLE_PINS 31
// > pinMode/pin/mode
#define PIN_MODE 32
// < publishAttachedDevice/deviceId/str deviceName
#define PUBLISH_ATTACHED_DEVICE 33
// < publishBoardStatus/b16 microsPerLoop/b16 sram/[] deviceSummary
#define PUBLISH_BOARD_STATUS 34
// < publishDebug/str debugMsg
#define PUBLISH_DEBUG 35
// < publishPinArray/[] data
#define PUBLISH_PIN_ARRAY 36
// > setTrigger/pin/triggerValue
#define SET_TRIGGER 37
// > setDebounce/pin/delay
#define SET_DEBOUNCE 38
// > servoAttach/deviceId/pin/initPos/b16 initVelocity
#define SERVO_ATTACH 39
// > servoEnablePwm/deviceId/pin
#define SERVO_ENABLE_PWM 40
// > servoDisablePwm/deviceId
#define SERVO_DISABLE_PWM 41
// > servoSetMaxVelocity/deviceId/b16 maxVelocity
#define SERVO_SET_MAX_VELOCITY 42
// > servoSetVelocity/deviceId/b16 velocity
#define SERVO_SET_VELOCITY 43
// > servoSweepStart/deviceId/min/max/step
#define SERVO_SWEEP_START 44
// > servoSweepStop/deviceId
#define SERVO_SWEEP_STOP 45
// > servoWrite/deviceId/target
#define SERVO_WRITE 46
// > servoWriteMicroseconds/deviceId/b16 ms
#define SERVO_WRITE_MICROSECONDS 47
// > serialAttach/deviceId/relayPin
#define SERIAL_ATTACH 48
// > serialRelay/deviceId/[] data
#define SERIAL_RELAY 49
// < publishSerialData/deviceId/[] data
#define PUBLISH_SERIAL_DATA 50
// > ultrasonicSensorAttach/deviceId/triggerPin/echoPin
#define ULTRASONIC_SENSOR_ATTACH 51
// > ultrasonicSensorStartRanging/deviceId/b32 timeout
#define ULTRASONIC_SENSOR_START_RANGING 52
// > ultrasonicSensorStopRanging/deviceId
#define ULTRASONIC_SENSOR_STOP_RANGING 53
// < publishUltrasonicSensorData/deviceId/b16 echoTime
#define PUBLISH_ULTRASONIC_SENSOR_DATA 54



/*******************************************************************
* BOARD TYPE
*/
#define BOARD_TYPE_ID_UNKNOWN 0
#define BOARD_TYPE_ID_MEGA 1
#define BOARD_TYPE_ID_UNO 2

#if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_ADK)
#define BOARD BOARD_TYPE_ID_MEGA
#elif defined(ARDUINO_AVR_UNO)
#define BOARD BOARD_TYPE_ID_UNO
#else
#define BOARD BOARD_TYPE_ID_UNKNOWN
#endif


/*******************************************************************
* BOARD TYPE
*/
#define BOARD_TYPE_ID_UNKNOWN 0
#define BOARD_TYPE_ID_MEGA 1
#define BOARD_TYPE_ID_UNO 2

#if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_ADK)
#define BOARD BOARD_TYPE_ID_MEGA
#elif defined(ARDUINO_AVR_UNO)
#define BOARD BOARD_TYPE_ID_UNO
#else
#define BOARD BOARD_TYPE_ID_UNKNOWN
#endif

#endif
16 changes: 4 additions & 12 deletions Device.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
#include "Msg.h"
#include "Device.h"

Device::Device(int deviceType) {
Device::Device(byte deviceId, byte deviceType) {
id = deviceId;
type = deviceType;
msg = Msg::getInstance();
}

void Device::attachDevice() {
id = nextDeviceId;
nextDeviceId++;
}

int Device::nextDeviceId=1; // device 0 is Arduino

bool Device::deviceAttach(unsigned char[], int) {
return false;
}
20 changes: 14 additions & 6 deletions Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
// TODO: consider rename to DEVICE_TYPE_UNKNOWN ? currently this isn't called anywhere
#define DEVICE_TYPE_NOT_FOUND 0

#define DEVICE_TYPE_ARDUINO 1
#define DEVICE_TYPE_ARDUINO 1
#define DEVICE_TYPE_ULTRASONIC 4
#define DEVICE_TYPE_STEPPER 5
#define DEVICE_TYPE_MOTOR 6
#define DEVICE_TYPE_SERVO 7
#define DEVICE_TYPE_I2C 8
#define DEVICE_TYPE_NEOPIXEL 9
#define DEVICE_TYPE_SERIAL 10

class Msg;

/**
* GLOBAL DEVICE TYPES END
Expand All @@ -40,22 +42,28 @@

class Device {
public:
Device(int deviceType);
// deviceId is supplied by a parameter in an 'attach' message
// deviceType is supplied by the device class as a form of runtime
// class identification (rtti)
Device(byte deviceId, byte deviceType);
virtual ~Device(){
// default destructor for the device class.
// destructor is set as virtual to call the destructor of the subclass.
// destructor should be done in the subclass level
}

int id; // the all important id of the sensor - equivalent to the "name" - used in callbacks
int type; // what type of device is this?
int state; // state - single at the moment to handle all the finite states of the sensors (todo maybe this moves into the subclasses?)
// GroG - I think its good here - a uniform state description across all devices is if they are DEVICE_STATE_ACTIVE or DEVICE_STATE_DEACTIVE
// subclasses can/should define their os substate - eg ULTRASONIC_STATE_WAITING_PULSE etc..
virtual void update() {}; // all devices must implement this to update their state.
// the universal attach - follows Java-Land Controller.deviceAttach method
virtual bool deviceAttach(unsigned char[], int);
static int nextDeviceId;
// virtual bool deviceAttach(const unsigned char[], const int);

// Msg is the generated interface for all communication
Msg* msg;

protected:

void attachDevice();
};

Expand Down
1 change: 0 additions & 1 deletion LinkedList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define LinkedList_cpp

#include "LinkedList.h"
#include "Arduino.h"

// Initialize LinkedList with false values
template<typename T>
Expand Down
Loading

0 comments on commit 27c59e7

Please sign in to comment.