diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eb78b4..fa09d5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,8 @@ if(NO_PYTHON) add_compile_definitions(NO_PYTHON) list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/PythonController.cpp) else() - include_directories(/usr/include/python3.10) + find_package(Python3 COMPONENTS Development REQUIRED) + include_directories(${Python3_INCLUDE_DIRS}) endif() add_executable(${PROJECT_NAME} ${sources}) @@ -31,6 +32,10 @@ if(NO_CANLIB) add_compile_definitions(NO_CANLIB) endif() +if(NO_INFLUX) + MESSAGE(STATUS "InfluxDB is not used") + add_compile_definitions(NO_INFLUX) +endif() if(UNIX AND NOT APPLE) set(LINUX TRUE) @@ -43,7 +48,7 @@ if(LINUX) target_link_libraries(${PROJECT_NAME} PRIVATE -lcanlib) endif() if(NOT NO_PYTHON) - target_link_libraries(${PROJECT_NAME} PRIVATE -lpython3.10) + target_link_libraries(${PROJECT_NAME} PRIVATE ${Python3_LIBRARIES}) endif() else() target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) diff --git a/README.md b/README.md index ebfb063..2d60968 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ - [Installation](#installation) - [Build options](#build-options) - [Supported CAN Drivers](#supported-can-drivers) +- [Development Setup](#development-setup) - [CAN Protocol](#can-protocol) - [The importance of States](#the-importance-of-states) - [Events](#events) @@ -109,6 +110,98 @@ Currently two drivers are supported namely the preferred driver can be selected inside the [config.json](#configjson). The Dockerfile also installs all required kvaser canlib library files automatically. +## Development Setup +The LLServer is meant to be used in conjuction with a can-bus and an influxdb logging server. +For local development the following setup is recommended: + +### can interface +The LLServer still requires a can interface to be present on the system to function. +You can create a dummy can interface with the following commands: +```bash +sudo modprobe vcan +sudo ip link add dev vcan0 type vcan +sudo ip link set up vcan0 +``` + +### Building the LLServer +Use the following cmake variables to run the LLServer in Dev Mode: +```bash +mkdir build && cd build +cmake -D NO_PYTHON=true -D NO_CANLIB=true -D NO_INFLUX=true .. -o ./ +make -j +``` +This disables the python bindings, the canbus interface and the influxdb logging. + +### Running the LLServer +The LLServer requires a `config.json` and a `mapping.json` file to run. You can find examples in the `config` folder. + +To run the LLServer with the example config files, use the following command: +```bash + ECUI_CONFIG_PATH=$(dirname "$PWD")/sample_config ./llserver_ecui_houbolt +``` + +Please note that without the CAN Bus none of the commands will work. You can crudely some for testing like this in the LLInterface::init: + +```c++ + auto doStuff = [](std::vector &data, bool flag) { + std::string str = [&data] { + std::ostringstream oss; + std::copy(data.begin(), data.end(), std::ostream_iterator(oss, " ")); + return oss.str(); + }(); + Debug::print("doStuff flag: %d values: %s", flag, str.c_str()); + }; + + eventManager->AddCommands({{"doStuff", {doStuff, {}}}}); + +``` + + + +### Emulating the ECUI +The LLServer communicates over a TCP-Socket with the [ECUI](https://github.com/SpaceTeam/web_ecui_houbolt). +To emulate this one can use the [ECUIEmulator.py](scripts/ECUIEmulator.py) script. +You have to set the message `type` and `data` and it will send it to the LLServer. +Responses are logged to the console. + +Eg. Starting a sequence: +```bash +python3 scripts/ECUIEmulator.py +Starting JSON socket server. +Enter your message type(one of sequence-start, send-postseq-comment, abort, auto-abort-change, states-load, states-get, states-set, states-start, states-stop, gui-mapping-load, commands-load, commands-set): +sequence-start +Enter your JSON message (send with `END` in a new line): +{ + "globals": { + "endTime": 10, + "interpolation": { + "doStuff": "none" + }, + "interval": 0.01, + "startTime": -3 + }, + "data": [ + { + "timestamp": "START", + "name": "start", + "desc": "start", + "actions": [ + { + "timestamp": 0.0, + "doStuff": [ + 2 + ] + } + ] + } + + ] +} +END +Message sent. + +``` + ## CAN Protocol As many terms from the [CAN Protocol](https://github.com/SpaceTeam/can_houbolt) are also used to describe many functionalities diff --git a/include/can/CANMapping.h b/include/can/CANMapping.h index 89db8ed..c849934 100644 --- a/include/can/CANMapping.h +++ b/include/can/CANMapping.h @@ -5,7 +5,7 @@ #ifndef LLSERVER_ECUI_HOUBOLT_CANMAPPING_H #define LLSERVER_ECUI_HOUBOLT_CANMAPPING_H -#include "utility/JSONMapping.h" +#include "../utility/JSONMapping.h" class CANMappingObj { diff --git a/include/can/Node.h b/include/can/Node.h index 81f4b62..8ec77fc 100644 --- a/include/can/Node.h +++ b/include/can/Node.h @@ -8,7 +8,7 @@ #include #include -#include "common.h" +#include "../common.h" typedef struct { @@ -23,12 +23,12 @@ typedef struct __attribute__((__packed__)) uint8_t channel_data[60]; } SensorMsg_t; -#include "can/Channel.h" +#include "channels/Channel.h" #include "CANDriverKvaser.h" -#include "can_houbolt/channels/generic_channel_def.h" -#include "logging/InfluxDbLogger.h" +#include "../can_houbolt/channels/generic_channel_def.h" +#include "../logging/InfluxDbLogger.h" -#include "utility/Config.h" +#include "../utility/Config.h" class Node : public Channel { @@ -57,6 +57,8 @@ class Node : public Channel SensorData_t *latestSensorBuffer; size_t latestSensorBufferLength = 0; std::mutex bufferMtx; + std::vector> nameValueMap; + void InitChannels(NodeInfoMsg_t &nodeInfo, std::map>> &channelInfo); diff --git a/include/can/ADC16.h b/include/can/channels/ADC16.h similarity index 98% rename from include/can/ADC16.h rename to include/can/channels/ADC16.h index 540edab..4461ed6 100644 --- a/include/can/ADC16.h +++ b/include/can/channels/ADC16.h @@ -7,7 +7,7 @@ #include "common.h" -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/adc16_channel_def.h" diff --git a/include/can/ADC16Single.h b/include/can/channels/ADC16Single.h similarity index 98% rename from include/can/ADC16Single.h rename to include/can/channels/ADC16Single.h index ef0d8af..5234c14 100644 --- a/include/can/ADC16Single.h +++ b/include/can/channels/ADC16Single.h @@ -7,7 +7,7 @@ #include "common.h" -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/adc16_single_channel_def.h" diff --git a/include/can/ADC24.h b/include/can/channels/ADC24.h similarity index 98% rename from include/can/ADC24.h rename to include/can/channels/ADC24.h index b5e399a..387b3c1 100644 --- a/include/can/ADC24.h +++ b/include/can/channels/ADC24.h @@ -9,7 +9,7 @@ #include "common.h" -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/adc24_channel_def.h" diff --git a/include/can/channels/CANMonitor.h b/include/can/channels/CANMonitor.h new file mode 100644 index 0000000..ce56b1d --- /dev/null +++ b/include/can/channels/CANMonitor.h @@ -0,0 +1,42 @@ +// +// Created by raffael on 31.03.25. +// + +#ifndef CANMONITOR_H +#define CANMONITOR_H + + +#include "can/channels/Channel.h" +#include "../Node.h" +#include "channels/can_monitor_channel_def.hpp" + +class CANMonitor : public Channel, public NonNodeChannel +{ + static const std::vector states; + static const std::map> scalingMap; + static const std::map variableMap; + +public: + CANMonitor(uint8_t channelID, std::string channelName, Node *parent); + + void GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, std::vector> &nameValueMap) override; + + //-------------------------------RECEIVE Functions-------------------------------// + + void ProcessCANCommand(Can_MessageData_t *canMsg, uint32_t &canMsgLength, uint64_t ×tamp) override; + std::vector GetStates() override; + + //-------------------------------SEND Functions-------------------------------// + + void SetRefreshDivider(std::vector ¶ms, bool testOnly); + void GetRefreshDivider(std::vector ¶ms, bool testOnly); + + //-------------------------------Utility Functions-------------------------------// + + void RequestCurrentState() override; + +}; + + + +#endif //CANMONITOR_H diff --git a/include/can/Channel.h b/include/can/channels/Channel.h similarity index 98% rename from include/can/Channel.h rename to include/can/channels/Channel.h index 9872774..e859393 100644 --- a/include/can/Channel.h +++ b/include/can/channels/Channel.h @@ -17,7 +17,7 @@ #include "StateController.h" #include "can_houbolt/cmds.h" -#include "CANDriver.h" +#include "../CANDriver.h" #include "EventManager.h" class Channel @@ -172,7 +172,7 @@ class Channel virtual const std::string GetChannelTypeName(); - virtual void GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, double &value); + virtual void GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, std::vector> &nameValueMap); virtual uint8_t GetChannelID() { return this->channelID; }; diff --git a/include/can/Control.h b/include/can/channels/Control.h similarity index 98% rename from include/can/Control.h rename to include/can/channels/Control.h index 0a18bcf..60e8c2e 100644 --- a/include/can/Control.h +++ b/include/can/channels/Control.h @@ -5,7 +5,7 @@ #ifndef LLSERVER_ECUI_HOUBOLT_CONTROL_H #define LLSERVER_ECUI_HOUBOLT_CONTROL_H -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/control_channel_def.h" diff --git a/include/can/DATA32.h b/include/can/channels/DATA32.h similarity index 97% rename from include/can/DATA32.h rename to include/can/channels/DATA32.h index a5df59a..8a4a209 100644 --- a/include/can/DATA32.h +++ b/include/can/channels/DATA32.h @@ -7,7 +7,7 @@ #include "common.h" -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/data32_channel_def.h" diff --git a/include/can/DigitalOut.h b/include/can/channels/DigitalOut.h similarity index 98% rename from include/can/DigitalOut.h rename to include/can/channels/DigitalOut.h index 12ad44c..658e902 100644 --- a/include/can/DigitalOut.h +++ b/include/can/channels/DigitalOut.h @@ -7,7 +7,7 @@ #include -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/digital_out_channel_def.h" diff --git a/include/can/IMU.h b/include/can/channels/IMU.h similarity index 98% rename from include/can/IMU.h rename to include/can/channels/IMU.h index c939c24..1316c63 100644 --- a/include/can/IMU.h +++ b/include/can/channels/IMU.h @@ -7,7 +7,7 @@ #include "common.h" -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/imu_channel_def.h" diff --git a/include/can/PIControl.h b/include/can/channels/PIControl.h similarity index 98% rename from include/can/PIControl.h rename to include/can/channels/PIControl.h index b1e250a..36b9602 100644 --- a/include/can/PIControl.h +++ b/include/can/channels/PIControl.h @@ -5,7 +5,7 @@ #ifndef LLSERVER_ECUI_HOUBOLT_PI_CONTROL_H #define LLSERVER_ECUI_HOUBOLT_PI_CONTROL_H -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/pi_control_channel_def.h" diff --git a/include/can/PneumaticValve.h b/include/can/channels/PneumaticValve.h similarity index 98% rename from include/can/PneumaticValve.h rename to include/can/channels/PneumaticValve.h index 20cc761..6301483 100644 --- a/include/can/PneumaticValve.h +++ b/include/can/channels/PneumaticValve.h @@ -5,7 +5,7 @@ #ifndef LLSERVER_ECUI_HOUBOLT_PNEUMATIC_VALVE_H #define LLSERVER_ECUI_HOUBOLT_PNEUMATIC_VALVE_H -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/pneumatic_valve_channel_def.h" diff --git a/include/can/Rocket.h b/include/can/channels/Rocket.h similarity index 98% rename from include/can/Rocket.h rename to include/can/channels/Rocket.h index 133babd..49bb305 100644 --- a/include/can/Rocket.h +++ b/include/can/channels/Rocket.h @@ -5,7 +5,7 @@ #ifndef LLSERVER_ECUI_HOUBOLT_ROCKET_H #define LLSERVER_ECUI_HOUBOLT_ROCKET_H -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/rocket_channel_def.h" diff --git a/include/can/Servo.h b/include/can/channels/Servo.h similarity index 99% rename from include/can/Servo.h rename to include/can/channels/Servo.h index 7d3370c..2b59d99 100644 --- a/include/can/Servo.h +++ b/include/can/channels/Servo.h @@ -5,7 +5,7 @@ #ifndef LLSERVER_ECUI_HOUBOLT_SERVO_H #define LLSERVER_ECUI_HOUBOLT_SERVO_H -#include "can/Channel.h" +#include "can/channels/Channel.h" #include "can/Node.h" #include "can_houbolt/channels/servo_channel_def.h" diff --git a/include/can_houbolt b/include/can_houbolt index 1e5a2ef..10f94ae 160000 --- a/include/can_houbolt +++ b/include/can_houbolt @@ -1 +1 @@ -Subproject commit 1e5a2ef28e63694ed6ec2c6c5626a4745c90b262 +Subproject commit 10f94ae375510bf34ee6c37987294f7702c9dc0e diff --git a/sample_config/config.json b/sample_config/config.json new file mode 100644 index 0000000..7f2e398 --- /dev/null +++ b/sample_config/config.json @@ -0,0 +1,111 @@ +{ + "version": "1.3.1@Lamarr", + "autoabort": false, + "pyenv": "/home/.local/lib/python3.8/site-packages", + "auto_start": true, + "DEBUG": { + "printWarnings": true, + "printInfos": true + }, + "socket_msg_size": 65536, + "LOGGING": { + "post_sequence_script": "scripts/plot.sh" + }, + "use_lora": false, + "LORA": { + "ip": "192.168.100.5", + "port": 5001, + "nodeIDsRef": [ + 33, + 31, + 32, + 29 + ], + "nodeIDs": [ + 13, + 11, + 12, + 19 + ], + "canMsgSizes": [ + 48, + 48, + 48, + 39 + ] + }, + "CAN": { + "node_count": 0, + "blocking_timeout": 2048, + "BUS": { + "ARBITRATION": { + "bitrate": 1000000, + "time_segment_1": 23, + "time_segment_2": 16, + "sync_jump_width": 1, + "no_sampling_points": 1 + }, + "DATA": { + "bitrate": 4000000, + "time_segment_1": 7, + "time_segment_2": 2, + "sync_jump_width": 2 + } + }, + "DRIVER": "SocketCAN", + "DEVICE": [ + "vcan0" + ], + "BUS_EXTRA": { + "1": { + "ARBITRATION": { + "bitrate": 1000000, + "time_segment_1": 7, + "time_segment_2": 2, + "sync_jump_width": 1, + "no_sampling_points": 1 + }, + "DATA": { + "bitrate": 8000000, + "time_segment_1": 7, + "time_segment_2": 2, + "sync_jump_width": 1 + } + } + }, + "canBusChannelIDs": [ + 0, + 1, + 2, + 3 + ] + }, + "LLSERVER": { + "sensor_state_sampling_rate": 10.0 + }, + "WEBSERVER": { + "ip": "127.0.0.1", + "port": 8080, + "state_transmission_rate": 10.0, + "timer_sync_rate": 10, + "sensors_smoothing_factor": 0.3 + }, + "INFLUXDB": { + "database_ip": "192.168.100.2", + "database_port": 8086, + "database_name": "gse", + "debug_measurement": "debug", + "state_measurement": "states", + "fast_sensor_measurement": "sensors", + "buffer_size": 2048, + "fast_sensor_buffer_size": 65536, + "enable_fast_sensor_logging": true + }, + "THRUST": { + "alpha": 0.785398, + "beta": 0.785398, + "gamma": 0.785398, + "d": 0.28, + "r": 0.14 + } +} diff --git a/sample_config/mapping.json b/sample_config/mapping.json new file mode 100644 index 0000000..2ced6b6 --- /dev/null +++ b/sample_config/mapping.json @@ -0,0 +1,1447 @@ +{ + "CANMapping": { + "3": { + "0": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "blmb_valve" + }, + "1": { + "stringID": "blmb_unused_unused_pressure" + }, + "2": { + "stringID": "blmb_unused_unused_what" + }, + "stringID": "blmb" + }, + "31": { + "0": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "fuel_tank_pressure" + }, + "1": { + "offset": -100, + "slope": 0.125885, + "stringID": "fuel_pressurant_pressure" + }, + "10": { + "stringID": "fuel_igniter_1" + }, + "11": { + "stringID": "fuel_igniter_1_cont" + }, + "12": { + "stringID": "fuel_igniter_2" + }, + "13": { + "stringID": "fuel_igniter_2_cont" + }, + "14": { + "stringID": "fuel_igniter_3" + }, + "15": { + "stringID": "fuel_igniter_3_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "fuel_pi_controller" + }, + "17": { + "stringID": "fuel_rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "fuel_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "fuel_sense_12V" + }, + "2": { + "offset": -100, + "slope": 0.125885, + "stringID": "fuel_pressure_2" + }, + "20": { + "slope": 0.008921110838, + "stringID": "fuel_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "fuel_pressure_3" + }, + "4": { + "offset": -313, + "slope": 0.0188, + "stringID": "fuel_temp_0" + }, + "5": { + "offset": -313, + "slope": 0.0188, + "stringID": "fuel_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "fuel_pressurant_valve" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "fuel_servo_1" + }, + "8": { + "stringID": "fuel_vent" + }, + "9": { + "stringID": "fuel_vent_cont" + }, + "stringID": "fuel_ecu" + }, + "32": { + "0": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "ox_tank_pressure" + }, + "1": { + "offset": -100, + "slope": 0.125885, + "stringID": "ox_pressurant_pressure" + }, + "10": { + "stringID": "ox_igniter_1" + }, + "11": { + "stringID": "ox_igniter_1_cont" + }, + "12": { + "stringID": "ox_igniter_2" + }, + "13": { + "stringID": "ox_igniter_2_cont" + }, + "14": { + "stringID": "ox_igniter_3" + }, + "15": { + "stringID": "ox_igniter_3_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "ox_pi_controller" + }, + "17": { + "stringID": "ox_rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "ox_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "ox_sense_12V" + }, + "2": { + "offset": -100, + "slope": 0.125885, + "stringID": "ox_pressure_2" + }, + "20": { + "slope": 0.008921110838, + "stringID": "ox_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "ox_pressure_3" + }, + "4": { + "offset": -313, + "slope": 0.0188, + "stringID": "ox_temp_0" + }, + "5": { + "offset": -308, + "slope": 0.0188, + "stringID": "ox_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "ox_pressurant_valve" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "ox_servo_1" + }, + "8": { + "stringID": "ox_vent" + }, + "9": { + "stringID": "ox_vent_cont" + }, + "stringID": "ox_ecu" + }, + "33": { + "0": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "fuel_venturi_pressure" + }, + "1": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "ox_venturi_pressure" + }, + "10": { + "stringID": "internal_igniter_1" + }, + "11": { + "stringID": "internal_igniter_1_cont" + }, + "12": { + "stringID": "internal_igniter_2" + }, + "13": { + "stringID": "internal_igniter_2_cont" + }, + "14": { + "stringID": "engine_igniter_3" + }, + "15": { + "stringID": "engine_igniter_3_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "engine_ox_main_pi_controller" + }, + "17": { + "stringID": "rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "engine_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "engine_sense_12V" + }, + "2": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "chamber_pressure" + }, + "20": { + "slope": 0.008921110838, + "stringID": "engine_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "engine_pressure_3" + }, + "4": { + "stringID": "engine_temp_0" + }, + "5": { + "stringID": "engine_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "fuel_main_valve" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "ox_main_valve" + }, + "8": { + "stringID": "engine_igniter_0" + }, + "9": { + "stringID": "engine_igniter_0_cont" + }, + "stringID": "engine_ecu" + }, + "34": { + "0": { + "offset": 2200, + "slope": -2, + "stringID": "pressurant_tanking_valve_feedback" + }, + "1": { + "offset": 2200, + "slope": -2, + "stringID": "pressurant_vent_valve_feedback" + }, + "10": { + "stringID": "pressurant_vent_valve" + }, + "11": { + "stringID": "pressurant_vent_valve_cont" + }, + "12": { + "stringID": "ox_tanking_valve" + }, + "13": { + "stringID": "ox_tanking_valve_cont" + }, + "14": { + "stringID": "holddown" + }, + "15": { + "stringID": "holddown_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "gse_pneu_unused_pi_controller" + }, + "17": { + "stringID": "gse_pneu_unused_rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "gse_pneu_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "gse_pneu_sense_12V" + }, + "2": { + "offset": 2200, + "slope": -2, + "stringID": "ox_tanking_valve_feedback" + }, + "20": { + "slope": 0.008921110838, + "stringID": "gse_pneu_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "ox_decoupler_feedback" + }, + "4": { + "stringID": "gse_pneu_temp_0" + }, + "5": { + "stringID": "gse_pneu_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "gse_pneu_servo_0" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "gse_pneu_servo_1" + }, + "8": { + "stringID": "pressurant_tanking_valve" + }, + "9": { + "stringID": "pressurant_tanking_valve_cont" + }, + "stringID": "gse_pneu_ecu" + }, + "35": { + "0": { + "offset": -100, + "slope": 0.125885, + "stringID": "pressurant_tanking_pressure" + }, + "1": { + "offset": 0, + "slope": 1, + "stringID": "gse_elec_press_1" + }, + "10": { + "stringID": "strongback" + }, + "11": { + "stringID": "strongback_cont" + }, + "12": { + "stringID": "dewar_pressurize_solenoid" + }, + "13": { + "stringID": "dewar_pressurize_solenoid_cont" + }, + "14": { + "stringID": "gse_igniter_3" + }, + "15": { + "stringID": "gse_igniter_3_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "gse_elec_unused_pi_controller" + }, + "17": { + "stringID": "gse_elec_unused_rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "gse_elec_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "gse_elec_sense_12V" + }, + "2": { + "offset": 0, + "slope": 1, + "stringID": "gse_elec_press_2" + }, + "20": { + "slope": 0.008921110838, + "stringID": "gse_elec_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "gse_elec_press_3" + }, + "4": { + "stringID": "gse_elec_temp_0" + }, + "5": { + "stringID": "gse_elec_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "gse_elec_servo_0" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "gse_elec_servo_1" + }, + "8": { + "stringID": "ox_decoupler" + }, + "9": { + "stringID": "ox_decoupler_cont" + }, + "stringID": "gse_elec_ecu" + }, + "8": { + "0": { + "offset": -18.935077, + "slope": 5.32e-06, + "stringID": "rocket_weight" + }, + "1": { + "offset": -37.171132400000005, + "slope": -1.48e-05, + "stringID": "dewar_weight" + }, + "2": { + "offset": -10.2876298, + "slope": 5.32e-06, + "stringID": "fuel_weight" + }, + "3": { + "offset": -14.20285865926, + "slope": 5.57269e-06, + "stringID": "ox_weight" + }, + "4": { + "offset": -0.23615210499999995, + "slope": 4.46075e-05, + "stringID": "unused_lcb_force_4" + }, + "5": { + "offset": -1794695.0, + "slope": 1.0, + "stringID": "unused_lcb_force_5" + }, + "6": { + "offset": -452668.0, + "slope": 1.0, + "stringID": "unused_lcb_force_6" + }, + "7": { + "offset": -1360714.0, + "slope": 1.0, + "stringID": "unused_lcb_force_7" + }, + "stringID": "teststand_lcb" + }, + "29": { + "18": { + "slope": 0.001622020152, + "stringID": "engine_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "engine_sense_12V" + }, + "0": { + "offset": 0, + "slope": 0.001622020152, + "stringID": "rcu_5V_voltage" + }, + "1": { + "offset": 0, + "slope": 0.00535, + "stringID": "rcu_12V_voltage" + }, + "10": { + "offset": 0, + "slope": 0.0000001, + "stringID": "gps_latitude" + }, + "11": { + "offset": 0, + "slope": 1.0, + "stringID": "gps_altitude" + }, + "2": { + "offset": 0, + "slope": 0.00024414, + "stringID": "rcu_barometer" + }, + "3": { + "offset": -16, + "slope": 0.0078125, + "stringID": "rcu_accel_x" + }, + "4": { + "offset": -16, + "slope": 0.0078125, + "stringID": "rcu_accel_y" + }, + "5": { + "offset": -16, + "slope": 0.0078125, + "stringID": "rcu_accel_z" + }, + "6": { + "offset": -2000, + "slope": 0.97656, + "stringID": "rcu_gyro_x" + }, + "7": { + "offset": -2000, + "slope": 0.97656, + "stringID": "rcu_gyro_y" + }, + "8": { + "offset": -2000, + "slope": 0.97656, + "stringID": "rcu_gyro_z" + }, + "9": { + "offset": 0, + "slope": 0.0000001, + "stringID": "gps_longitude" + }, + "12": { + "offset": 0, + "slope": 1.0, + "stringID": "gps_status" + }, + "13": { + "offset": 0, + "slope": 1.0, + "stringID": "rcu_out_0" + }, + "14": { + "offset": 0, + "slope": 1.0, + "stringID": "camera_1" + }, + "15": { + "offset": 0, + "slope": 1.0, + "stringID": "camera_2" + }, + "16": { + "offset": 0, + "slope": 1.0, + "stringID": "rcu_out_3" + }, + "stringID": "rcu" + }, + "11": { + "0": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "lora:fuel_tank_pressure" + }, + "1": { + "offset": -100, + "slope": 0.125885, + "stringID": "lora:fuel_pressurant_pressure" + }, + "10": { + "stringID": "lora:fuel_igniter_1" + }, + "11": { + "stringID": "lora:fuel_igniter_1_cont" + }, + "12": { + "stringID": "lora:fuel_igniter_2" + }, + "13": { + "stringID": "lora:fuel_igniter_2_cont" + }, + "14": { + "stringID": "lora:fuel_igniter_3" + }, + "15": { + "stringID": "lora:fuel_igniter_3_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "lora:fuel_pi_controller" + }, + "17": { + "stringID": "lora:fuel_rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "lora:fuel_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "lora:fuel_sense_12V" + }, + "2": { + "offset": -100, + "slope": 0.125885, + "stringID": "lora:fuel_pressure_2" + }, + "20": { + "slope": 0.008921110838, + "stringID": "lora:fuel_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "lora:fuel_pressure_3" + }, + "4": { + "offset": -313, + "slope": 0.0188, + "stringID": "lora:fuel_temp_0" + }, + "5": { + "offset": -313, + "slope": 0.0188, + "stringID": "lora:fuel_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "lora:fuel_pressurant_valve" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "lora:fuel_servo_1" + }, + "8": { + "stringID": "lora:fuel_vent" + }, + "9": { + "stringID": "lora:fuel_vent_cont" + }, + "stringID": "lora:fuel_ecu" + }, + "12": { + "0": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "lora:ox_tank_pressure" + }, + "1": { + "offset": -100, + "slope": 0.125885, + "stringID": "lora:ox_pressurant_pressure" + }, + "10": { + "stringID": "lora:ox_igniter_1" + }, + "11": { + "stringID": "lora:ox_igniter_1_cont" + }, + "12": { + "stringID": "lora:ox_igniter_2" + }, + "13": { + "stringID": "lora:ox_igniter_2_cont" + }, + "14": { + "stringID": "lora:ox_igniter_3" + }, + "15": { + "stringID": "lora:ox_igniter_3_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "lora:ox_pi_controller" + }, + "17": { + "stringID": "lora:ox_rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "lora:ox_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "lora:ox_sense_12V" + }, + "2": { + "offset": -100, + "slope": 0.125885, + "stringID": "lora:ox_pressure_2" + }, + "20": { + "slope": 0.008921110838, + "stringID": "lora:ox_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "lora:ox_pressure_3" + }, + "4": { + "offset": -313, + "slope": 0.0188, + "stringID": "lora:ox_temp_0" + }, + "5": { + "offset": -308, + "slope": 0.0188, + "stringID": "lora:ox_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "lora:ox_pressurant_valve" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "lora:ox_servo_1" + }, + "8": { + "stringID": "lora:ox_vent" + }, + "9": { + "stringID": "lora:ox_vent_cont" + }, + "stringID": "lora:ox_ecu" + }, + "13": { + "0": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "lora:fuel_venturi_pressure" + }, + "1": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "lora:ox_venturi_pressure" + }, + "10": { + "stringID": "lora:internal_igniter_1" + }, + "11": { + "stringID": "lora:internal_igniter_1_cont" + }, + "12": { + "stringID": "lora:internal_igniter_2" + }, + "13": { + "stringID": "lora:internal_igniter_2_cont" + }, + "14": { + "stringID": "lora:engine_igniter_3" + }, + "15": { + "stringID": "lora:engine_igniter_3_cont" + }, + "16": { + "slope": 0.001525879, + "stringID": "lora:engine_ox_main_pi_controller" + }, + "17": { + "stringID": "lora:rocket" + }, + "18": { + "slope": 0.001622020152, + "stringID": "lora:engine_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "lora:engine_sense_12V" + }, + "2": { + "offset": -15, + "slope": 0.01888275146, + "stringID": "lora:chamber_pressure" + }, + "20": { + "slope": 0.008921110838, + "stringID": "lora:engine_sense_12VA" + }, + "3": { + "offset": 0, + "slope": 1, + "stringID": "lora:engine_pressure_3" + }, + "4": { + "stringID": "lora:engine_temp_0" + }, + "5": { + "stringID": "lora:engine_temp_1" + }, + "6": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "lora:fuel_main_valve" + }, + "7": { + "offset": 0.0, + "slope": 0.00152590219, + "stringID": "lora:ox_main_valve" + }, + "8": { + "stringID": "lora:engine_igniter_0" + }, + "9": { + "stringID": "lora:engine_igniter_0_cont" + }, + "stringID": "lora:engine_ecu" + }, + "19": { + "18": { + "slope": 0.001622020152, + "stringID": "lora:engine_sense_5V" + }, + "19": { + "slope": 0.008921110838, + "stringID": "lora:engine_sense_12V" + }, + "0": { + "offset": 0, + "slope": 0.001622020152, + "stringID": "lora:rcu_5V_voltage" + }, + "1": { + "offset": 0, + "slope": 0.00535, + "stringID": "lora:rcu_12V_voltage" + }, + "10": { + "offset": 0, + "slope": 0.0000001, + "stringID": "lora:gps_latitude" + }, + "11": { + "offset": 0, + "slope": 1.0, + "stringID": "lora:gps_altitude" + }, + "2": { + "offset": 0, + "slope": 0.00024414, + "stringID": "lora:rcu_barometer" + }, + "3": { + "offset": -16, + "slope": 0.0078125, + "stringID": "lora:rcu_accel_x" + }, + "4": { + "offset": -16, + "slope": 0.0078125, + "stringID": "lora:rcu_accel_y" + }, + "5": { + "offset": -16, + "slope": 0.0078125, + "stringID": "lora:rcu_accel_z" + }, + "6": { + "offset": -2000, + "slope": 0.97656, + "stringID": "lora:rcu_gyro_x" + }, + "7": { + "offset": -2000, + "slope": 0.97656, + "stringID": "lora:rcu_gyro_y" + }, + "8": { + "offset": -2000, + "slope": 0.97656, + "stringID": "lora:rcu_gyro_z" + }, + "9": { + "offset": 0, + "slope": 0.0000001, + "stringID": "lora:gps_longitude" + }, + "12": { + "offset": 0, + "slope": 1.0, + "stringID": "lora:gps_status" + }, + "13": { + "offset": 0, + "slope": 1.0, + "stringID": "lora:rcu_out_0" + }, + "14": { + "offset": 0, + "slope": 1.0, + "stringID": "lora:camera_1" + }, + "15": { + "offset": 0, + "slope": 1.0, + "stringID": "lora:camera_2" + }, + "16": { + "offset": 0, + "slope": 1.0, + "stringID": "lora:rcu_out_3" + }, + "stringID": "lora:rcu" + } + }, + "DefaultEventMapping": { + "DigitalOut": [ + { + "command": "DigitalOut:SetState", + "parameters": [ + "DigitalOut" + ] + } + ], + "Servo": [ + { + "command": "Servo:SetTargetPosition", + "parameters": [ + "Servo" + ] + } + ] + }, + "EventMapping": { + "engine_ecu:FlashStatus": [ + { + "state": "gui:Flash:Clear", + "triggerType": "!=", + "triggerValue": 0, + "value": 0 + } + ], + "ox_ecu:FlashStatus": [ + { + "state": "gui:Flash:Clear", + "triggerType": "!=", + "triggerValue": 0, + "value": 0 + } + ], + "fuel_ecu:FlashStatus": [ + { + "state": "gui:Flash:Clear", + "triggerType": "!=", + "triggerValue": 0, + "value": 0 + } + ], + "rcu:FlashStatus": [ + { + "state": "gui:Flash:Clear", + "triggerType": "!=", + "triggerValue": 0, + "value": 0 + } + ], + "gui:Flash:Clear": [ + { + "command": "engine_ecu:RequestFlashClear", + "parameters": [] + }, + { + "command": "ox_ecu:RequestFlashClear", + "parameters": [] + }, + { + "command": "fuel_ecu:RequestFlashClear", + "parameters": [] + }, + { + "command": "rcu:RequestFlashClear", + "parameters": [] + } + ], + "gui:FlushDatabase": [ + { + "command": "FlushDatabase", + "parameters": [] + } + ], + "gui:Logging": [ + { + "command": "engine_ecu:SetLoggingEnabled", + "parameters": [ + "gui:Logging" + ] + }, + { + "command": "ox_ecu:SetLoggingEnabled", + "parameters": [ + "gui:Logging" + ] + }, + { + "command": "fuel_ecu:SetLoggingEnabled", + "parameters": [ + "gui:Logging" + ] + }, + { + "command": "rcu:SetLoggingEnabled", + "parameters": [ + "gui:Logging" + ] + } + ], + "gui:LoraEnabled": [ + { + "command": "rcu:SetLoraEnabled", + "parameters": [ + "gui:LoraEnabled" + ] + } + ], + "gui:dewar_weight:Tare": [ + { + "command": "Tare", + "parameters": [ + 8, + 1, + "dewar_weight:sensor" + ] + } + ], + "gui:fuel_pi_controller:GetI_NEG": [ + { + "command": "fuel_pi_controller:GetI_NEG", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetI_POS": [ + { + "command": "fuel_pi_controller:GetI_POS", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetOperatingPoint": [ + { + "command": "fuel_pi_controller:GetOperatingPoint", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetP_NEG": [ + { + "command": "fuel_pi_controller:GetP_NEG", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetP_POS": [ + { + "command": "fuel_pi_controller:GetP_POS", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetSensorChannelID": [ + { + "command": "fuel_pi_controller:GetSensorChannelID", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetSensorOffset": [ + { + "command": "fuel_pi_controller:GetSensorOffset", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetSensorSlope": [ + { + "command": "fuel_pi_controller:GetSensorSlope", + "parameters": [] + } + ], + "gui:fuel_pi_controller:GetTarget": [ + { + "command": "fuel_pi_controller:GetTarget", + "parameters": [] + } + ], + "gui:fuel_weight:Tare": [ + { + "command": "Tare", + "parameters": [ + 8, + 2, + "fuel_weight:sensor" + ] + } + ], + "gui:holddown:sensor": [ + { + "command": "holddown:SetState", + "parameters": [ + 0 + ], + "triggerType": "==", + "triggerValue": 0 + }, + { + "command": "holddown:SetState", + "parameters": [ + 1 + ], + "triggerType": "==", + "triggerValue": 1 + } + ], + "gui:ox_pi_controller:GetI_NEG": [ + { + "command": "ox_pi_controller:GetI_NEG", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetI_POS": [ + { + "command": "ox_pi_controller:GetI_POS", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetOperatingPoint": [ + { + "command": "ox_pi_controller:GetOperatingPoint", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetP_NEG": [ + { + "command": "ox_pi_controller:GetP_NEG", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetP_POS": [ + { + "command": "ox_pi_controller:GetP_POS", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetSensorChannelID": [ + { + "command": "ox_pi_controller:GetSensorChannelID", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetSensorOffset": [ + { + "command": "ox_pi_controller:GetSensorOffset", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetSensorSlope": [ + { + "command": "ox_pi_controller:GetSensorSlope", + "parameters": [] + } + ], + "gui:ox_pi_controller:GetTarget": [ + { + "command": "ox_pi_controller:GetTarget", + "parameters": [] + } + ], + "gui:ox_weight:Tare": [ + { + "command": "Tare", + "parameters": [ + 8, + 3, + "ox_weight:sensor" + ] + } + ], + "gui:pressure_control:GetHysteresis": [ + { + "command": "pressure_control:GetHysteresis", + "parameters": [] + } + ], + "gui:pressure_control:SetEnabled": [ + { + "command": "pressure_control:SetEnabled", + "parameters": [ + "gui:pressure_control:SetEnabled" + ] + } + ], + "gui:pressure_control:SetHysteresis": [ + { + "command": "pressure_control:SetHysteresis", + "parameters": [ + "gui:pressure_control:SetHysteresis" + ] + } + ], + "gui:pressure_control:SetTarget": [ + { + "command": "pressure_control:SetTarget", + "parameters": [ + "gui:pressure_control:SetTarget" + ] + } + ], + "gui:rocket:Abort": [ + { + "command": "rocket:Abort", + "parameters": [] + } + ], + "gui:rocket:AutoCheck": [ + { + "command": "rocket:AutoCheck", + "parameters": [] + } + ], + "gui:rocket:EndOfFlight": [ + { + "command": "rocket:EndOfFlight", + "parameters": [] + } + ], + "gui:rocket:InternalControl": [ + { + "command": "rocket:ActivateInternalControl", + "parameters": [] + } + ], + "gui:rocket:ReleaseHolddown": [ + { + "command": "rocket:SetRocketState", + "parameters": [ + 4 + ] + }, + { + "command": "holddown:SetTargetPosition", + "parameters": [ + 65535 + ] + } + ], + "gui:rocket:RequestResetSettings": [ + { + "command": "rocket:RequestResetSettings", + "parameters": [] + } + ], + "gui:rocket:ResetStateMachine": [ + { + "command": "rocket:SetRocketState", + "parameters": [ + 0 + ] + } + ], + "gui:rocket:SetHolddownTimeout": [ + { + "command": "rocket:SetHolddownTimeout", + "parameters": [ + "gui:rocket:SetHolddownTimeout" + ] + } + ], + "gui:rocket:SetMinimumChamberPressure": [ + { + "command": "rocket:SetMinimumChamberPressure", + "parameters": [ + "gui:rocket:SetMinimumChamberPressure" + ] + } + ], + "gui:rocket:SetMinimumFuelPressure": [ + { + "command": "rocket:SetMinimumFuelPressure", + "parameters": [ + "gui:rocket:SetMinimumFuelPressure" + ] + } + ], + "gui:rocket:SetMinimumOxPressure": [ + { + "command": "rocket:SetMinimumOxPressure", + "parameters": [ + "gui:rocket:SetMinimumOxPressure" + ] + } + ], + "gui:rocket_weight:Tare": [ + { + "command": "Tare", + "parameters": [ + 8, + 0, + "rocket_weight:sensor" + ] + } + ], + "gui:thrust:Tare": [ + { + "command": "Tare", + "parameters": [ + 8, + 0, + "thrust:sensor" + ] + } + ], + "gui:venturi_weight:Tare": [ + { + "command": "Tare", + "parameters": [ + 9, + 1, + "venturi_weight:sensor" + ] + } + ], + "fuel_rocket:GetRocketState": [ + { + "state": "fuel_rocket:GetRocketState", + "parameters": [] + } + ], + "ox_rocket:GetRocketState": [ + { + "state": "ox_rocket:GetRocketState", + "parameters": [] + } + ], + "rocket:sensor": [ + { + "state": "rocket:PadIdle", + "triggerType": "==", + "triggerValue": 0, + "value": 1 + }, + { + "state": "rocket:PadIdle", + "triggerType": "!=", + "triggerValue": 0, + "value": 0 + }, + { + "state": "rocket:AutoCheck", + "triggerType": "==", + "triggerValue": 1, + "value": 1 + }, + { + "state": "rocket:AutoCheck", + "triggerType": "!=", + "triggerValue": 1, + "value": 0 + }, + { + "state": "rocket:IgnitionSequence", + "triggerType": "==", + "triggerValue": 2, + "value": 1 + }, + { + "state": "rocket:IgnitionSequence", + "triggerType": "!=", + "triggerValue": 2, + "value": 0 + }, + { + "state": "rocket:HoldDown", + "triggerType": "==", + "triggerValue": 3, + "value": 1 + }, + { + "state": "rocket:HoldDown", + "triggerType": "!=", + "triggerValue": 3, + "value": 0 + }, + { + "state": "rocket:PoweredAscent", + "triggerType": "==", + "triggerValue": 4, + "value": 1 + }, + { + "state": "rocket:PoweredAscent", + "triggerType": "!=", + "triggerValue": 4, + "value": 0 + }, + { + "state": "rocket:UnpoweredAscent", + "triggerType": "==", + "triggerValue": 5, + "value": 1 + }, + { + "state": "rocket:UnpoweredAscent", + "triggerType": "!=", + "triggerValue": 5, + "value": 0 + }, + { + "state": "rocket:Depress", + "triggerType": "==", + "triggerValue": 6, + "value": 1 + }, + { + "state": "rocket:Depress", + "triggerType": "!=", + "triggerValue": 6, + "value": 0 + }, + { + "state": "rocket:AbortFlowChart", + "triggerType": "==", + "triggerValue": 7, + "value": 1 + }, + { + "state": "rocket:AbortFlowChart", + "triggerType": "!=", + "triggerValue": 7, + "value": 0 + } + ] + }, + "GUIMapping": [], + "GUIMappingAdvanced": {} +} diff --git a/sample_config/sample_sequence.json b/sample_config/sample_sequence.json new file mode 100644 index 0000000..dde36be --- /dev/null +++ b/sample_config/sample_sequence.json @@ -0,0 +1,51 @@ +{ + "globals": { + "endTime": 10, + "interpolation": { + "doStuff": "none" + }, + "interval": 0.01, + "startTime": -3 + }, + "data": [ + { + "timestamp": "START", + "name": "start", + "desc": "start", + "actions": [ + { + "timestamp": 0.0, + "doStuff": [ + 2 + ] + } + ] + }, + { + "timestamp": 4.0, + "name": "start", + "desc": "start", + "actions": [ + { + "timestamp": 0.0, + "doStuff": [ + 10 + ] + } + ] + }, + { + "timestamp": "END", + "name": "end", + "desc": "end", + "actions": [ + { + "timestamp": 0.0, + "doStuff": [ + 15 + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/scripts/ECUIEmulator.py b/scripts/ECUIEmulator.py new file mode 100644 index 0000000..19e8c0f --- /dev/null +++ b/scripts/ECUIEmulator.py @@ -0,0 +1,91 @@ +import socket +import threading +import json + + +HOST = '127.0.0.1' # localhost +PORT = 8080 # Port to listen on + +# Store connected clients +clients = [] +MAX_MSG_LENGTH = 65536-1 + +# Function to handle client connections +def handle_client(conn, addr): + print(f"Connected by {addr}") + clients.append(conn) + try: + while True: + data = conn.recv(1024) + if not data: + break + print(f"Received from client: {data}") + except Exception as e: + print(f"Connection error: {e}") + finally: + conn.close() + clients.remove(conn) + print(f"Connection with {addr} closed.") + +def start_server(): + server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server.bind((HOST, PORT)) + server.listen(5) + print(f"Server listening on {HOST}:{PORT}") + + while True: + conn, addr = server.accept() + threading.Thread(target=handle_client, args=(conn, addr),daemon=True).start() + +# Function to send JSON messages to all clients, with a custom header +def send_message_to_all_clients(type,message): + msg = { + "type": type, + "content": [message,"",""] + } + + str_msg = json.dumps(msg) + '\n' + str_msg_len = len(str_msg) + + if str_msg_len <= MAX_MSG_LENGTH: + lsb = str_msg_len & 0x00FF + msb = str_msg_len >> 8 + + header = bytes([msb, lsb]) + msg_buffer = header + str_msg.encode('ascii') + + for client in clients: + try: + client.sendall(msg_buffer) + except Exception as e: + print(f"Error sending message to a client: {e}") + +if __name__ == "__main__": + print("Starting JSON socket server.") + threading.Thread(target=start_server, daemon=True).start() + while True: + try: + print("Enter your message type(one of sequence-start, send-postseq-comment, abort, auto-abort-change, states-load, states-get, states-set, states-start, states-stop, gui-mapping-load, commands-load, commands-set):") + type = input() + print("Enter your JSON message (send with `END` in a new line):") + lines = [] + while True: + line = input() + if line.strip() == "END": + break + lines.append(line) + + # Join the lines and parse as JSON + json_data = json.loads("\n".join(lines)) + + # Send the JSON data to all connected clients + send_message_to_all_clients(type,json_data) + print("Message sent.") + except json.JSONDecodeError: + print("Invalid JSON. Please try again.") + except KeyboardInterrupt: + print("Server shutting down.") + break + except Exception as e: + print(f"Unexpected error: {e}") diff --git a/src/SequenceManager.cpp b/src/SequenceManager.cpp index 59ccbcf..1b1eda5 100644 --- a/src/SequenceManager.cpp +++ b/src/SequenceManager.cpp @@ -138,6 +138,9 @@ void SequenceManager::SetupLogging() strftime(dateTime_string, 100, "%Y_%m_%d__%H_%M_%S", curr_tm); currentDirPath = "logs/" + std::string(dateTime_string); + std::experimental::filesystem::create_directory("logs"); + std::experimental::filesystem::create_directory(currentDirPath); + this->lastDir = currentDirPath; logFileName = std::string(dateTime_string) + ".csv"; std::experimental::filesystem::create_directory(currentDirPath); @@ -199,10 +202,14 @@ bool SequenceManager::LoadSequence(nlohmann::json jsonSeq) { if (sensorsIt.value().type() == nlohmann::json::value_t::array && sensorsIt.value().size() == 2) { - sensorsNominalRangeMap[sensorsIt.key()][timestampMicros][0] = sensorsIt.value()[0]; - sensorsNominalRangeMap[sensorsIt.key()][timestampMicros][1] = sensorsIt.value()[1]; - sensorsNominalRangeTimeMap[timestampMicros][sensorsIt.key()][0] = sensorsIt.value()[0]; - sensorsNominalRangeTimeMap[timestampMicros][sensorsIt.key()][1] = sensorsIt.value()[1]; + if(jsonSeq["globals"]["ranges"].contains(sensorsIt.key())) { + sensorsNominalRangeMap[sensorsIt.key()][timestampMicros][0] = sensorsIt.value()[0]; + sensorsNominalRangeMap[sensorsIt.key()][timestampMicros][1] = sensorsIt.value()[1]; + sensorsNominalRangeTimeMap[timestampMicros][sensorsIt.key()][0] = sensorsIt.value()[0]; + sensorsNominalRangeTimeMap[timestampMicros][sensorsIt.key()][1] = sensorsIt.value()[1]; + } else{ + Debug::warning("Sensor Ranges set for %s but not defined in globals", sensorsIt.key().c_str()); + } } else { @@ -248,19 +255,11 @@ void SequenceManager::StartSequence(nlohmann::json jsonSeq, nlohmann::json jsonA // } // msg += "Status;"; msg += "SequenceTime;"; - for (auto rangeName : jsonSeq["globals"]["ranges"]) + for (const auto& rangeName: sensorsNominalRangeMap) { - Debug::info("Sensor nominal range found: %s", ((std::string) rangeName).c_str()); - if (rangeName.type() == nlohmann::json::value_t::string) - { - msg += (std::string) rangeName + "Min;"; - msg += (std::string) rangeName + "Max;"; - } - else - { - Debug::error("range name in sequence globals not a string"); - } - + Debug::info("Sensor nominal range found: %s", ((std::string) rangeName.first).c_str()); + msg += rangeName.first + "Min;"; + msg += rangeName.first + "Max;"; } for (auto &item : deviceMap) { @@ -403,7 +402,7 @@ void SequenceManager::sequenceLoop(int64_t interval_us) if(sequenceTime_us >= nextTimePrint_us) { Debug::info("Sequence Time: %dus", sequenceTime_us); - nextTimePrint_us += 500000; + nextTimePrint_us += 300000; } static int32_t nextTimerSync_us = startTime_us; @@ -417,7 +416,8 @@ void SequenceManager::sequenceLoop(int64_t interval_us) syncMtx.lock(); //log nominal ranges - for (const auto &sensor : sensorsNominalRangeMap) + + for (const auto &sensor : sensorsNominalRangeMap) { msg += std::to_string(sensor.second.begin()->second[0]) + ";"; msg += std::to_string(sensor.second.begin()->second[1]) + ";"; diff --git a/src/StateController.cpp b/src/StateController.cpp index e80fdef..4fb70c0 100644 --- a/src/StateController.cpp +++ b/src/StateController.cpp @@ -18,13 +18,14 @@ void StateController::Init(std::function onSt if (!initialized) { this->onStateChangeCallback = std::move(onStateChangeCallback); +#ifndef NO_INFLUX logger = new InfluxDbLogger(); logger->Init(config["/INFLUXDB/database_ip"], config["/INFLUXDB/database_port"], config["/INFLUXDB/database_name"], config["/INFLUXDB/state_measurement"], MICROSECONDS, config["/INFLUXDB/buffer_size"]); - +#endif initialized = true; } } @@ -121,7 +122,9 @@ void StateController::SetState(std::string stateName, double value, uint64_t tim std::get<1>(*state) = timestamp; std::get<2>(*state) = true; //Debug::print("%zd: %s, %zd", count, stateName.c_str(), count); +#ifndef NO_INFLUX logger->log(stateName, value, timestamp); +#endif if(timestamp != 0) { count++; } diff --git a/src/can/Node.cpp b/src/can/Node.cpp index 88990cc..379a640 100644 --- a/src/can/Node.cpp +++ b/src/can/Node.cpp @@ -1,25 +1,27 @@ -#include "can/Node.h" +#include "../../include/can/Node.h" #include #include #include #include #include -#include "utility/Config.h" -#include "can/DigitalOut.h" -#include "can/ADC16.h" -#include "can/ADC16Single.h" -#include "can/ADC24.h" -#include "can/DATA32.h" -#include "can/Servo.h" -#include "can/PneumaticValve.h" -#include "can/Control.h" -#include "can/PIControl.h" -#include "can/IMU.h" -#include "can/Rocket.h" -#include "StateController.h" +#include "../../include/utility/Config.h" +#include "../../include/can/channels/DigitalOut.h" +#include "../../include/can/channels/ADC16.h" +#include "../../include/can/channels/ADC16Single.h" +#include "../../include/can/channels/ADC24.h" +#include "../../include/can/channels/DATA32.h" +#include "../../include/can/channels/Servo.h" +#include "../../include/can/channels/PneumaticValve.h" +#include "../../include/can/channels/Control.h" +#include "../../include/can/channels/PIControl.h" +#include "../../include/can/channels/IMU.h" +#include "../../include/can/channels/Rocket.h" +#include "../../include/StateController.h" #include +#include "can/channels/CANMonitor.h" + const std::vector Node::states = { "Bus1Voltage", @@ -90,6 +92,7 @@ Node::Node(uint8_t nodeID, std::string nodeChannelName, NodeInfoMsg_t& nodeInfo, if (logger == nullptr) { Debug::info("%d, %s, %d, %s, %s, %d", enableFastLogging, influxIP.c_str(), influxPort, databaseName.c_str(), measurementName.c_str(), influxBufferSize); +#ifndef NO_INFLUX if (enableFastLogging) { Debug::print("Fast logging enabled"); @@ -102,8 +105,12 @@ Node::Node(uint8_t nodeID, std::string nodeChannelName, NodeInfoMsg_t& nodeInfo, } else { +#endif Debug::print("Fast logging disabled"); +#ifndef NO_INFLUX } +#endif + } commandMap = { @@ -198,6 +205,9 @@ void Node::InitChannels(NodeInfoMsg_t &nodeInfo, std::map(channelInfo[channelID]), std::get<1>(channelInfo[channelID]), this); break; + case CHANNEL_TYPE_CAN_MONITOR: + ch = new CANMonitor(channelID, std::get<0>(channelInfo[channelID]), this); + break; default: throw std::runtime_error("channel type not recognized"); // TODO: default case for unknown channel types that logs (DB) @@ -368,7 +378,8 @@ void Node::ProcessSensorDataAndWriteToRingBuffer(Can_MessageData_t *canMsg, uint } ch = channelMap[channelID]; - ch->GetSensorValue(valuePtr, currValueLength, currValue); + ch->GetSensorValue(valuePtr, currValueLength, nameValueMap); + // Debug::print("Hello chid %d, value %f", channelID, currValue); if (currValueLength <= 0) { @@ -376,16 +387,22 @@ void Node::ProcessSensorDataAndWriteToRingBuffer(Can_MessageData_t *canMsg, uint } { - std::lock_guard lock(bufferMtx); + std::lock_guard lock(bufferMtx); - latestSensorBuffer[channelID] = {currValue, timestamp}; + latestSensorBuffer[channelID] = {nameValueMap[0].second, timestamp}; +#ifndef NO_INFLUX if (enableFastLogging) { - std::lock_guard lock(loggerMtx); - logger->log(ch->GetSensorName(), currValue, timestamp); + std::lock_guard loglock(loggerMtx); + for (auto it = nameValueMap.begin(); it != nameValueMap.end();) { + logger->log(it->first, it->second, timestamp); + nameValueMap.erase(it); + } + //logger->flush(); } +#endif //buffer.push_back(sensor); //TODO: uncomment if implemented } diff --git a/src/can/ADC16.cpp b/src/can/channels/ADC16.cpp similarity index 98% rename from src/can/ADC16.cpp rename to src/can/channels/ADC16.cpp index 90065e1..3ff50bd 100644 --- a/src/can/ADC16.cpp +++ b/src/can/channels/ADC16.cpp @@ -2,8 +2,8 @@ // Created by Markus on 31.03.21. // -#include "can/ADC16.h" -#include "StateController.h" +#include "can/channels/ADC16.h" +#include "../../../include/StateController.h" #include diff --git a/src/can/ADC16Single.cpp b/src/can/channels/ADC16Single.cpp similarity index 99% rename from src/can/ADC16Single.cpp rename to src/can/channels/ADC16Single.cpp index 86a8dd2..06acbd0 100644 --- a/src/can/ADC16Single.cpp +++ b/src/can/channels/ADC16Single.cpp @@ -2,8 +2,8 @@ // Created by Markus on 31.03.21. // -#include "can/ADC16Single.h" -#include "StateController.h" +#include "can/channels/ADC16Single.h" +#include "../../../include/StateController.h" #include diff --git a/src/can/ADC24.cpp b/src/can/channels/ADC24.cpp similarity index 99% rename from src/can/ADC24.cpp rename to src/can/channels/ADC24.cpp index 0811156..58cb906 100644 --- a/src/can/ADC24.cpp +++ b/src/can/channels/ADC24.cpp @@ -2,7 +2,7 @@ // Created by Markus on 31.03.21. // -#include "can/ADC24.h" +#include "can/channels/ADC24.h" const std::vector ADC24::states = { diff --git a/src/can/channels/CANMonitor.cpp b/src/can/channels/CANMonitor.cpp new file mode 100644 index 0000000..d4fd048 --- /dev/null +++ b/src/can/channels/CANMonitor.cpp @@ -0,0 +1,141 @@ +// +// Created by raffael on 31.03.25. +// + +#include "can/channels/CANMonitor.h" + +#include + + +CANMonitor::CANMonitor(uint8_t channelID, std::string channelName, Node *parent) + : Channel("CANMonitor", channelID, std::move(channelName),sensorScaling, parent, CAN_MONITOR_DATA_N_BYTES), NonNodeChannel(parent) { + commandMap = { + {"SetRefreshDivider", {std::bind(&CANMonitor::SetRefreshDivider, this, std::placeholders::_1, std::placeholders::_2), {"Value"}}}, + {"GetRefreshDivider", {std::bind(&CANMonitor::GetRefreshDivider, this, std::placeholders::_1, std::placeholders::_2), {}}}, + }; + +} + + +const std::vector CANMonitor::states = + { + "RefreshDivider", + }; + +const std::map> CANMonitor::scalingMap = + { + {"RefreshDivider", {1.0, 0.0}}, + }; + +const std::map CANMonitor::variableMap = + { + {CAN_MONITOR_REFRESH_DIVIDER, "RefreshDivider"}, + }; + +//---------------------------------------------------------------------------------------// +//-------------------------------GETTER & SETTER Functions-------------------------------// +//---------------------------------------------------------------------------------------// + +std::vector CANMonitor::GetStates() +{ + std::vector states = CANMonitor::states; + for (auto &state : states) + { + state = GetStatePrefix() + state; + } + return states; +} + +void CANMonitor::GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, std::vector> &nameValueMap) { + valueLength = this->typeSize; + auto* valuePtr64 = reinterpret_cast(valuePtr); + nameValueMap.emplace_back(this->GetSensorName(), FDCAN_StatusRegisters::ECR.get(*valuePtr64)); + + nameValueMap.emplace_back(this->GetStatePrefix() + "TEC", FDCAN_StatusRegisters::ECR_Fields::TEC.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "REC", FDCAN_StatusRegisters::ECR_Fields::REC.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "RP", FDCAN_StatusRegisters::ECR_Fields::RP.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "CEL", FDCAN_StatusRegisters::ECR_Fields::CEL.get(*valuePtr64)); + + nameValueMap.emplace_back(this->GetStatePrefix() + "LEC", FDCAN_StatusRegisters::PSR_Fields::LEC.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "ACT", FDCAN_StatusRegisters::PSR_Fields::ACT.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "EP", FDCAN_StatusRegisters::PSR_Fields::EP.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "EW", FDCAN_StatusRegisters::PSR_Fields::EW.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "DLEC", FDCAN_StatusRegisters::PSR_Fields::DLEC.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "RESI", FDCAN_StatusRegisters::PSR_Fields::RESI.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "RBRS", FDCAN_StatusRegisters::PSR_Fields::RBRS.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "REDL", FDCAN_StatusRegisters::PSR_Fields::REDL.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "PXE", FDCAN_StatusRegisters::PSR_Fields::PXE.get(*valuePtr64)); + nameValueMap.emplace_back(this->GetStatePrefix() + "TDCV", FDCAN_StatusRegisters::PSR_Fields::TDCV.get(*valuePtr64)); +} + + +//-------------------------------------------------------------------------------// +//-------------------------------RECEIVE Functions-------------------------------// +//-------------------------------------------------------------------------------// + +void CANMonitor::ProcessCANCommand(Can_MessageData_t *canMsg, uint32_t &canMsgLength, uint64_t ×tamp) +{ + try + { + switch (canMsg->bit.cmd_id) + { + case CAN_MONITOR_RES_GET_VARIABLE: + case CAN_MONITOR_RES_SET_VARIABLE: + GetSetVariableResponse(canMsg, canMsgLength, timestamp, variableMap, scalingMap); + break; + case CAN_MONITOR_RES_STATUS: + StatusResponse(canMsg, canMsgLength, timestamp); + break; + case CAN_MONITOR_REQ_STATUS: + case CAN_MONITOR_REQ_SET_VARIABLE: + case CAN_MONITOR_REQ_GET_VARIABLE: + throw std::runtime_error("request message type has been received, major fault in protocol"); + break; + default: + throw std::runtime_error("CANMonitor specific command with command id not supported: " + std::to_string(canMsg->bit.cmd_id)); + } + } + catch (std::exception &e) + { + throw std::runtime_error("CANMonitor '" + this->channelName + "' - ProcessCANCommand: " + std::string(e.what())); + } +} + +//----------------------------------------------------------------------------// +//-------------------------------SEND Functions-------------------------------// +//----------------------------------------------------------------------------// + +void CANMonitor::SetRefreshDivider(std::vector ¶ms, bool testOnly) +{ + std::vector scalingParams = scalingMap.at("RefreshDivider"); + + try + { + SetVariable(CAN_MONITOR_REQ_SET_VARIABLE, parent->GetNodeID(), CAN_MONITOR_REFRESH_DIVIDER, + scalingParams, params, parent->GetCANBusChannelID(), parent->GetCANDriver(), testOnly); + } + catch (std::exception &e) + { + throw std::runtime_error("CANMonitor - SetRefreshDivider: " + std::string(e.what())); + } +} + +void CANMonitor::GetRefreshDivider(std::vector ¶ms, bool testOnly) +{ + try + { + GetVariable(CAN_MONITOR_REQ_GET_VARIABLE, parent->GetNodeID(), CAN_MONITOR_REFRESH_DIVIDER, + params, parent->GetCANBusChannelID(), parent->GetCANDriver(), testOnly); + } + catch (std::exception &e) + { + throw std::runtime_error("CANMonitor - GetRefreshDivider: " + std::string(e.what())); + } +} + +void CANMonitor::RequestCurrentState() +{ + std::vector params; + + GetRefreshDivider(params, false); +} \ No newline at end of file diff --git a/src/can/Channel.cpp b/src/can/channels/Channel.cpp similarity index 95% rename from src/can/Channel.cpp rename to src/can/channels/Channel.cpp index 97d5f4e..70cc81b 100644 --- a/src/can/Channel.cpp +++ b/src/can/channels/Channel.cpp @@ -2,11 +2,11 @@ // Created by Markus on 10.04.21. // -#include "can/Channel.h" +#include "can/channels/Channel.h" #include -#include "can_houbolt/can_cmds.h" +#include "../../../include/can_houbolt/can_cmds.h" const std::vector Channel::states = {}; const std::map> Channel::sensorScalingMap = {}; @@ -86,9 +86,10 @@ void Channel::ResetSettingsResponse(Can_MessageData_t *canMsg, uint32_t &canMsgL * assumes pointer has valid data!!! * @param valuePtr points to array which includes value data * @param valueLength returns number of bytes used for value - * @param value + * @param nameValueMap returns name/value pairs for sensor values. Expects the vector to be empty + * the first item is the main channelSensor */ -void Channel::GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, double &value) +void Channel::GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, std::vector> &nameValueMap) { valueLength = this->typeSize; int32_t intValue = 0; @@ -114,7 +115,7 @@ void Channel::GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, double &va default: throw std::logic_error("Channel - GetSensorValue: channel type has more than 4 bytes\n\tgood luck if this exception happens"); } - value = (double)(intValue); + double value = (intValue); scalingMtx.lock(); double slope = sensorScaling[0]; @@ -122,6 +123,7 @@ void Channel::GetSensorValue(uint8_t *valuePtr, uint8_t &valueLength, double &va scalingMtx.unlock(); value = ScaleSensor(value, slope, offset); + nameValueMap.push_back(std::make_pair(this->GetSensorName(), value)); } void Channel::SendStandardCommand(uint8_t nodeID, uint8_t cmdID, uint8_t *command, uint32_t commandLength, diff --git a/src/can/Control.cpp b/src/can/channels/Control.cpp similarity index 99% rename from src/can/Control.cpp rename to src/can/channels/Control.cpp index ef626bf..9d220e5 100644 --- a/src/can/Control.cpp +++ b/src/can/channels/Control.cpp @@ -2,7 +2,7 @@ // Created by Markus on 03.09.21. // -#include "can/Control.h" +#include "can/channels/Control.h" const std::vector Control::states = { diff --git a/src/can/DATA32.cpp b/src/can/channels/DATA32.cpp similarity index 98% rename from src/can/DATA32.cpp rename to src/can/channels/DATA32.cpp index 55d4f1e..2fa8d90 100644 --- a/src/can/DATA32.cpp +++ b/src/can/channels/DATA32.cpp @@ -2,8 +2,8 @@ // Created by Markus on 31.03.21. // -#include "can/DATA32.h" -#include "StateController.h" +#include "can/channels/DATA32.h" +#include "../../../include/StateController.h" #include diff --git a/src/can/DigitalOut.cpp b/src/can/channels/DigitalOut.cpp similarity index 99% rename from src/can/DigitalOut.cpp rename to src/can/channels/DigitalOut.cpp index 5b3ae37..0615578 100644 --- a/src/can/DigitalOut.cpp +++ b/src/can/channels/DigitalOut.cpp @@ -2,7 +2,7 @@ // Created by Markus on 31.03.21. // -#include "can/DigitalOut.h" +#include "can/channels/DigitalOut.h" const std::vector DigitalOut::states = { diff --git a/src/can/IMU.cpp b/src/can/channels/IMU.cpp similarity index 98% rename from src/can/IMU.cpp rename to src/can/channels/IMU.cpp index 0b5356a..0769565 100644 --- a/src/can/IMU.cpp +++ b/src/can/channels/IMU.cpp @@ -2,8 +2,8 @@ // Created by Markus on 31.03.21. // -#include "can/IMU.h" -#include "StateController.h" +#include "can/channels/IMU.h" +#include "../../../include/StateController.h" #include diff --git a/src/can/PIControl.cpp b/src/can/channels/PIControl.cpp similarity index 99% rename from src/can/PIControl.cpp rename to src/can/channels/PIControl.cpp index 760eca7..1172b74 100644 --- a/src/can/PIControl.cpp +++ b/src/can/channels/PIControl.cpp @@ -2,7 +2,7 @@ // Created by Markus on 03.09.21. // -#include "can/PIControl.h" +#include "can/channels/PIControl.h" const std::vector PIControl::states = { diff --git a/src/can/PneumaticValve.cpp b/src/can/channels/PneumaticValve.cpp similarity index 99% rename from src/can/PneumaticValve.cpp rename to src/can/channels/PneumaticValve.cpp index 24e3499..6bd789a 100644 --- a/src/can/PneumaticValve.cpp +++ b/src/can/channels/PneumaticValve.cpp @@ -2,7 +2,7 @@ // Created by Markus on 03.09.21. // -#include "can/PneumaticValve.h" +#include "can/channels/PneumaticValve.h" const std::vector PneumaticValve::states = { diff --git a/src/can/Rocket.cpp b/src/can/channels/Rocket.cpp similarity index 99% rename from src/can/Rocket.cpp rename to src/can/channels/Rocket.cpp index 4029306..f120180 100644 --- a/src/can/Rocket.cpp +++ b/src/can/channels/Rocket.cpp @@ -2,7 +2,7 @@ // Created by Markus on 31.08.21. // -#include "can/Rocket.h" +#include "can/channels/Rocket.h" const std::vector Rocket::states = { diff --git a/src/can/Servo.cpp b/src/can/channels/Servo.cpp similarity index 99% rename from src/can/Servo.cpp rename to src/can/channels/Servo.cpp index c78173c..a3ec9fa 100644 --- a/src/can/Servo.cpp +++ b/src/can/channels/Servo.cpp @@ -2,7 +2,7 @@ // Created by Markus on 31.08.21. // -#include "can/Servo.h" +#include "can/channels/Servo.h" const std::vector Servo::states = { diff --git a/src/drivers/PythonController.cpp b/src/drivers/PythonController.cpp index a2b6954..751ea3e 100644 --- a/src/drivers/PythonController.cpp +++ b/src/drivers/PythonController.cpp @@ -231,7 +231,7 @@ void PythonController::RunPyScript(std::string scriptPath) PythonController::SetupImports(); std::wstring path = std::wstring(scriptPath.begin(), scriptPath.end()); - FILE *fp = _Py_wfopen(path.c_str(), L"r"); + FILE *fp = fopen(reinterpret_cast(path.c_str()), "r"); StateController::Instance() -> SetState((std::string) "python_running", 1, utils::getCurrentTimestamp()); @@ -272,7 +272,7 @@ void PythonController::RunPyScriptWithArgvWChar(std::string scriptPath, int pyAr PySys_SetArgv(pyArgc, pyArgv); std::wstring path = std::wstring(scriptPath.begin(), scriptPath.end()); - FILE *fp = _Py_wfopen(path.c_str(), L"r"); + FILE *fp = fopen(reinterpret_cast(path.c_str()), "r"); StateController::Instance() -> SetState((std::string) "python_running", 1, utils::getCurrentTimestamp()); diff --git a/src/utility/Debug.cpp b/src/utility/Debug.cpp index 7f3be49..c2afd29 100644 --- a/src/utility/Debug.cpp +++ b/src/utility/Debug.cpp @@ -27,13 +27,15 @@ void Debug::Init(Config &config) if (!initialized) { printWarnings = config["/DEBUG/printWarnings"]; printInfos = config["/DEBUG/printInfos"]; +#ifndef NO_INFLUX logger.reset(new InfluxDbLogger()); logger->Init(config["/INFLUXDB/database_ip"], config["/INFLUXDB/database_port"], config["/INFLUXDB/database_name"], config["/INFLUXDB/debug_measurement"], MILLISECONDS, config["/INFLUXDB/buffer_size"]); - initialized = true; +#endif + initialized = true; } } @@ -172,7 +174,10 @@ void Debug::close() info("in Debug close: log output file is not open yet, try Debug::changeOutputFile"); } if (initialized) { +#ifndef NO_INFLUX + logger->flush(); +#endif } } @@ -190,7 +195,9 @@ void Debug::flush() } if (initialized) { +#ifndef NO_INFLUX logger->flush(); +#endif } }