diff --git a/CMakeLists.txt b/CMakeLists.txt index 64ab4ef..ea19ad1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(fastcat LANGUAGES C CXX ) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9883ff9..3fa54c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,75 +1,57 @@ ####### Fastcat COG Autocoding ####### -add_custom_command( - OUTPUT - ${CMAKE_BINARY_DIR}/include/fastcat/types.h - COMMAND - cog -d -D cog_yaml_file=fcgen/fastcat_types.yaml - -o ${CMAKE_BINARY_DIR}/include/fastcat/types.h - ${CMAKE_CURRENT_LIST_DIR}/fcgen/types.h.cog - DEPENDS - ${CMAKE_CURRENT_LIST_DIR}/fcgen/fastcat_types.yaml - ${CMAKE_CURRENT_LIST_DIR}/fcgen/types.h.cog - WORKING_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR} - COMMENT - "running fcgen - types" - VERBATIM - ) -add_custom_command( - OUTPUT - ${CMAKE_BINARY_DIR}/fastcat/autogen/signal_handling.cc - COMMAND - cog -d -D cog_yaml_file=fcgen/fastcat_types.yaml - -o ${CMAKE_BINARY_DIR}/fastcat/autogen/signal_handling.cc - ${CMAKE_CURRENT_LIST_DIR}/fcgen/signal_handling.cc.cog - DEPENDS - ${CMAKE_BINARY_DIR}/include/fastcat/types.h - ${CMAKE_CURRENT_LIST_DIR}/fcgen/signal_handling.cc.cog - WORKING_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR} - COMMENT - "running fcgen - signals" - VERBATIM - ) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/autogen) -add_custom_command( +function(run_fcgen fc_input_file fc_output_file) + add_custom_command( OUTPUT - ${CMAKE_BINARY_DIR}/fastcat/autogen/fastcat_devices/commander.cc + ${fc_output_file} COMMAND - cog -d -D cog_yaml_file=fcgen/fastcat_types.yaml - -o ${CMAKE_BINARY_DIR}/fastcat/autogen/fastcat_devices/commander.cc - ${CMAKE_CURRENT_LIST_DIR}/fcgen/commander.cc.cog + cog -d + -D cog_yaml_file=fcgen/templates/${fc_input_file} + -D command_yaml=fcgen/fastcat_commands.yaml + -D device_yaml=fcgen/fastcat_devices.yaml + -D enum_yaml=fcgen/fastcat_enums.yaml + -D manager_yaml=fcgen/fastcat_manager_config.yaml + -o ${fc_output_file} + fcgen/templates/${fc_input_file} DEPENDS - ${CMAKE_BINARY_DIR}/include/fastcat/types.h - ${CMAKE_CURRENT_LIST_DIR}/fcgen/commander.cc.cog + fcgen/fastcat_commands.yaml + fcgen/fastcat_devices.yaml + fcgen/fastcat_enums.yaml + fcgen/fastcat_manager_config.yaml + fcgen/templates/${fc_input_file} WORKING_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_CURRENT_LIST_DIR} COMMENT - "running fcgen - commander" + "fcgen: ${fc_input_file} -> ${fc_output_file}" VERBATIM ) +endfunction() -add_custom_target(fcgen - DEPENDS +run_fcgen("types.h.cog" "${CMAKE_BINARY_DIR}/include/fastcat/types.h") +run_fcgen("device_includes.h.cog" "${CMAKE_BINARY_DIR}/include/fastcat/device_includes.h") +run_fcgen("signal_handling.cc.cog" "${CMAKE_BINARY_DIR}/autogen/signal_handling.cc") +run_fcgen("commander.cc.cog" "${CMAKE_BINARY_DIR}/autogen/commander.cc") + +add_custom_target(fcgen DEPENDS ${CMAKE_BINARY_DIR}/include/fastcat/types.h - ${CMAKE_BINARY_DIR}/fastcat/autogen/signal_handling.cc - ${CMAKE_BINARY_DIR}/fastcat/autogen/fastcat_devices/commander.cc + ${CMAKE_BINARY_DIR}/include/fastcat/device_includes.h ) -# Build a library regardless of BUILD_TESTS flag add_library(fastcat STATIC + ${CMAKE_BINARY_DIR}/autogen/signal_handling.cc + ${CMAKE_BINARY_DIR}/autogen/commander.cc trap.c device_base.cc manager.cc yaml_parser.cc - ${CMAKE_BINARY_DIR}/fastcat/autogen/signal_handling.cc transform_utils.cc - jsd/jsd_device_base.cc + + # JSD Devices jsd/actuator.cc jsd/actuator_fsm_helpers.cc - jsd/ati_fts.cc jsd/egd.cc jsd/el3208.cc @@ -82,10 +64,9 @@ add_library(fastcat STATIC jsd/el3318.cc jsd/gold_actuator.cc jsd/ild1900.cc - jsd/jed0101.cc - jsd/jed0200.cc jsd/platinum_actuator.cc + # Offline Devices jsd/ati_fts_offline.cc jsd/egd_offline.cc jsd/el2124_offline.cc @@ -98,11 +79,9 @@ add_library(fastcat STATIC jsd/el3318_offline.cc jsd/ild1900_offline.cc jsd/gold_actuator_offline.cc - jsd/jed0101_offline.cc - jsd/jed0200_offline.cc jsd/platinum_actuator_offline.cc - ${CMAKE_BINARY_DIR}/fastcat/autogen/fastcat_devices/commander.cc + # Fastcat Devices fastcat_devices/signal_generator.cc fastcat_devices/function.cc fastcat_devices/conditional.cc diff --git a/src/fastcat_devices/conditional.cc b/src/fastcat_devices/conditional.cc index 7cb67a9..cd9fdb9 100644 --- a/src/fastcat_devices/conditional.cc +++ b/src/fastcat_devices/conditional.cc @@ -9,10 +9,10 @@ #include "fastcat/yaml_parser.h" #include "jsd/jsd_print.h" -fastcat::ConditionalType fastcat::ConditionalTypeFromString( +fastcat::ConditionalOperatorType fastcat::ConditionalTypeFromString( std::string cond_type) { - ConditionalType type; + ConditionalOperatorType type; if (cond_type.compare("<") == 0) { type = LT; @@ -28,7 +28,7 @@ fastcat::ConditionalType fastcat::ConditionalTypeFromString( type = NE; } else { - type = BAD_CONDITIONAL_TYPE; + type = BAD_CONDITIONAL_OPERATOR_TYPE; ERROR("%s is not a known ConditionalType", cond_type.c_str()); } @@ -38,7 +38,7 @@ fastcat::ConditionalType fastcat::ConditionalTypeFromString( fastcat::Conditional::Conditional() { state_ = std::make_shared(); - state_->type = CONDITIONAL_STATE; + state_->type = CONDITIONAL_DEVICE; } bool fastcat::Conditional::ConfigFromYaml(YAML::Node node) @@ -53,7 +53,7 @@ bool fastcat::Conditional::ConfigFromYaml(YAML::Node node) } conditional_type_ = ConditionalTypeFromString(conditional_type_string_); - if (conditional_type_ == BAD_CONDITIONAL_TYPE) { + if (conditional_type_ == BAD_CONDITIONAL_OPERATOR_TYPE) { return false; } diff --git a/src/fastcat_devices/conditional.h b/src/fastcat_devices/conditional.h index f24658d..63ba563 100644 --- a/src/fastcat_devices/conditional.h +++ b/src/fastcat_devices/conditional.h @@ -10,17 +10,8 @@ namespace fastcat { -enum ConditionalType { - LT, // < - LE, // <= - GT, // > - GE, // >= - EQ, // ==, limited use for double types - NE, // !=, limited use for double types - BAD_CONDITIONAL_TYPE -}; -ConditionalType ConditionalTypeFromString(std::string cond_type); +ConditionalOperatorType ConditionalTypeFromString(std::string cond_type); class Conditional : public DeviceBase { @@ -30,9 +21,9 @@ class Conditional : public DeviceBase bool Read() override; protected: - std::string conditional_type_string_; - enum ConditionalType conditional_type_; - double compare_rhs_value_{0}; + std::string conditional_type_string_; + ConditionalOperatorType conditional_type_; + double compare_rhs_value_{0}; }; } // namespace fastcat diff --git a/src/fastcat_devices/faulter.cc b/src/fastcat_devices/faulter.cc index 0e1daf4..759daed 100644 --- a/src/fastcat_devices/faulter.cc +++ b/src/fastcat_devices/faulter.cc @@ -12,7 +12,7 @@ fastcat::Faulter::Faulter() { state_ = std::make_shared(); - state_->type = FAULTER_STATE; + state_->type = FAULTER_DEVICE; } bool fastcat::Faulter::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/filter.cc b/src/fastcat_devices/filter.cc index 311a948..8710531 100644 --- a/src/fastcat_devices/filter.cc +++ b/src/fastcat_devices/filter.cc @@ -98,7 +98,7 @@ fastcat::FilterType fastcat::FilterTypeFromString(std::string str) fastcat::Filter::Filter() { state_ = std::make_shared(); - state_->type = FILTER_STATE; + state_->type = FILTER_DEVICE; } bool fastcat::Filter::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/filter.h b/src/fastcat_devices/filter.h index 31a767f..29e5e4c 100644 --- a/src/fastcat_devices/filter.h +++ b/src/fastcat_devices/filter.h @@ -35,8 +35,6 @@ class DigitalABFilter std::vector B_; }; -enum FilterType { MOVING_AVERAGE, DIGITAL_AB, BAD_FILTER_TYPE }; - FilterType FilterTypeFromString(std::string str); class Filter : public DeviceBase diff --git a/src/fastcat_devices/fts.cc b/src/fastcat_devices/fts.cc index 31f330a..712cdf0 100644 --- a/src/fastcat_devices/fts.cc +++ b/src/fastcat_devices/fts.cc @@ -12,7 +12,7 @@ fastcat::Fts::Fts() { state_ = std::make_shared(); - state_->type = FTS_STATE; + state_->type = FTS_DEVICE; } bool fastcat::Fts::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/function.cc b/src/fastcat_devices/function.cc index e0d2a05..e629fee 100644 --- a/src/fastcat_devices/function.cc +++ b/src/fastcat_devices/function.cc @@ -12,7 +12,7 @@ fastcat::Function::Function() { state_ = std::make_shared(); - state_->type = FUNCTION_STATE; + state_->type = FUNCTION_DEVICE; } fastcat::FunctionType fastcat::FunctionTypeFromString( diff --git a/src/fastcat_devices/function.h b/src/fastcat_devices/function.h index d5612c0..8222f06 100644 --- a/src/fastcat_devices/function.h +++ b/src/fastcat_devices/function.h @@ -10,15 +10,6 @@ namespace fastcat { -enum FunctionType { - POLYNOMIAL, - SUMMATION, - MULTIPLICATION, - POWER, - EXPONENTIAL, - SIGMOID, - BAD_FUNCTION_TYPE -}; FunctionType FunctionTypeFromString(const std::string&); typedef struct { diff --git a/src/fastcat_devices/linear_interpolation.cc b/src/fastcat_devices/linear_interpolation.cc index f5156f9..8e020b1 100644 --- a/src/fastcat_devices/linear_interpolation.cc +++ b/src/fastcat_devices/linear_interpolation.cc @@ -14,7 +14,7 @@ fastcat::LinearInterpolation::LinearInterpolation() { state_ = std::make_shared(); - state_->type = LINEAR_INTERPOLATION_STATE; + state_->type = LINEAR_INTERPOLATION_DEVICE; } bool fastcat::LinearInterpolation::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/pid.cc b/src/fastcat_devices/pid.cc index 0a36d69..02213a2 100644 --- a/src/fastcat_devices/pid.cc +++ b/src/fastcat_devices/pid.cc @@ -12,7 +12,7 @@ fastcat::Pid::Pid() { state_ = std::make_shared(); - state_->type = PID_STATE; + state_->type = PID_DEVICE; } bool fastcat::Pid::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/saturation.cc b/src/fastcat_devices/saturation.cc index a381dd1..f91cf7e 100644 --- a/src/fastcat_devices/saturation.cc +++ b/src/fastcat_devices/saturation.cc @@ -12,7 +12,7 @@ fastcat::Saturation::Saturation() { state_ = std::make_shared(); - state_->type = SATURATION_STATE; + state_->type = SATURATION_DEVICE; } bool fastcat::Saturation::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/schmitt_trigger.cc b/src/fastcat_devices/schmitt_trigger.cc index 7c7e1be..1f90ea3 100644 --- a/src/fastcat_devices/schmitt_trigger.cc +++ b/src/fastcat_devices/schmitt_trigger.cc @@ -12,7 +12,7 @@ fastcat::SchmittTrigger::SchmittTrigger() { state_ = std::make_shared(); - state_->type = SCHMITT_TRIGGER_STATE; + state_->type = SCHMITT_TRIGGER_DEVICE; } bool fastcat::SchmittTrigger::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/signal_generator.cc b/src/fastcat_devices/signal_generator.cc index 089587b..c59ba94 100644 --- a/src/fastcat_devices/signal_generator.cc +++ b/src/fastcat_devices/signal_generator.cc @@ -30,7 +30,7 @@ fastcat::SignalGenerator::SignalGenerator() MSG_DEBUG("Constructed SignalGenerator"); state_ = std::make_shared(); - state_->type = SIGNAL_GENERATOR_STATE; + state_->type = SIGNAL_GENERATOR_DEVICE; } bool fastcat::SignalGenerator::ConfigFromYaml(YAML::Node node) diff --git a/src/fastcat_devices/signal_generator.h b/src/fastcat_devices/signal_generator.h index 6bdf637..03f7b26 100644 --- a/src/fastcat_devices/signal_generator.h +++ b/src/fastcat_devices/signal_generator.h @@ -12,14 +12,6 @@ namespace fastcat { -enum SignalGeneratorType { - SINE_WAVE, - SAW_TOOTH, - GAUSSIAN_RANDOM, - UNIFORM_RANDOM, - BAD_SIGNAL_GENERATOR_TYPE -}; - SignalGeneratorType SignalGeneratorTypeFromString(const std::string&); typedef struct { @@ -60,7 +52,7 @@ class SignalGenerator : public DeviceBase protected: std::string signal_generator_type_string_; - enum SignalGeneratorType signal_generator_type_; + SignalGeneratorType signal_generator_type_; double start_time_ = 0; std::default_random_engine generator_; diff --git a/src/fastcat_devices/virtual_fts.cc b/src/fastcat_devices/virtual_fts.cc index 3a8127f..376e6da 100644 --- a/src/fastcat_devices/virtual_fts.cc +++ b/src/fastcat_devices/virtual_fts.cc @@ -12,7 +12,7 @@ fastcat::VirtualFts::VirtualFts() { state_ = std::make_shared(); - state_->type = FTS_STATE; + state_->type = FTS_DEVICE; } bool fastcat::VirtualFts::ConfigFromYaml(YAML::Node node) diff --git a/src/fcgen/README.md b/src/fcgen/README.md deleted file mode 100644 index 31ffbbd..0000000 --- a/src/fcgen/README.md +++ /dev/null @@ -1,23 +0,0 @@ -This tool uses Python cogapp to auto generate class definitions and boilerplate code - -You absolutely do not need to use this to generate new class definitions, but given the scope of -fastcat covers ~20 devices and 3 implementations, this tool could be a big time saver - -To install cogapp: - -```bash - sudo pip install cogapp -``` - -To use this tool, follow these steps - -1) define the input file, use the el2124 example file -1) invoke the cog program with the following command, changing the path to your YAML file accordingly - -```bash -cog -d -D yaml_file=/home/dev/src/fastcat/fastcat_device/tools/cog_workspace/input/el2124_slave.yaml @cog_in.txt -``` -1) copy the output/ac_class.h/.cc files to the proper locations -1) copy-paste the snippet code to the proper locations -1) make sure it compiles -1) fill out the application-specific device Read() and Write() functions diff --git a/src/fcgen/fastcat_commands.yaml b/src/fcgen/fastcat_commands.yaml new file mode 100644 index 0000000..19eaa52 --- /dev/null +++ b/src/fcgen/fastcat_commands.yaml @@ -0,0 +1,326 @@ +# use snake_case for all variable and device names +commands: + - name: commander_enable + fields: + - name: duration + type: double + comment: duration in seconds, duration <= 0 indefinite + + - name: commander_disable + fields: + - name: dummy + type: bool + + - name: egd_csp + fields: + - name: target_position + type: int32_t + - name: position_offset + type: int32_t + - name: velocity_offset + type: int32_t + - name: torque_offset_amps + type: double + + - name: egd_csv + fields: + - name: target_velocity + type: int32_t + - name: velocity_offset + type: int32_t + - name: torque_offset_amps + type: double + + - name: egd_cst + fields: + - name: target_torque_amps + type: int32_t + - name: torque_offset_amps + type: double + + - name: egd_set_gain_scheduling_index + fields: + - name: gain_scheduling_index + type: uint16_t + + - name: egd_prof_pos + fields: + - name: target_position + type: int32_t + - name: profile_velocity + type: uint32_t + - name: end_velocity + type: uint32_t + - name: profile_accel + type: uint32_t + - name: profile_decel + type: uint32_t + - name: relative + type: uint8_t + + - name: egd_prof_vel + fields: + - name: target_velocity + type: int32_t + - name: profile_accel + type: uint32_t + - name: profile_decel + type: uint32_t + + - name: egd_prof_torque + fields: + - name: target_torque_amps + type: double + + - name: egd_reset + fields: + - name: dummy + type: bool + comment: unused + + - name: egd_halt + fields: + - name: dummy + type: bool + comment: unused + + - name: egd_sdo_set_drive_pos + fields: + - name: drive_position + type: int32_t + - name: app_id + type: uint16_t + + - name: egd_sdo_set_unit_mode + fields: + - name: unit_mode + type: int32_t + - name: app_id + type: uint16_t + + - name: egd_sdo_disable_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: egd_sdo_enable_speed_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: egd_sdo_enable_position_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: egd_sdo_enable_manual_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: fts_tare + fields: + - name: dummy + type: bool + comment: unused + + - name: fts_enable_guard_fault + fields: + - name: enable + type: bool + + - name: el2124_write_channel + fields: + - name: channel + type: uint8_t + - name: level + type: uint8_t + + - name: el2124_write_all_channels + fields: + - name: channel_ch1 + type: uint8_t + - name: channel_ch2 + type: uint8_t + - name: channel_ch3 + type: uint8_t + - name: channel_ch4 + type: uint8_t + + - name: el4102_write_channel + fields: + - name: channel + type: uint8_t + - name: voltage_output + type: double + + - name: el4102_write_all_channels + fields: + - name: voltage_output_ch1 + type: double + - name: voltage_output_ch2 + type: double + + - name: actuator_csp + fields: + - name: target_position + type: double + - name: position_offset + type: double + - name: velocity_offset + type: double + - name: torque_offset_amps + type: double + + - name: actuator_csv + fields: + - name: target_velocity + type: double + - name: velocity_offset + type: double + - name: torque_offset_amps + type: double + + - name: actuator_cst + fields: + - name: target_torque_amps + type: double + - name: torque_offset_amps + type: double + + - name: actuator_set_gain_scheduling_index + fields: + - name: gain_scheduling_index + type: uint16_t + + - name: actuator_prof_pos + fields: + - name: target_position + type: double + - name: profile_velocity + type: double + - name: end_velocity + type: double + - name: profile_accel + type: double + - name: relative + type: uint8_t + + - name: actuator_prof_vel + fields: + - name: target_velocity + type: double + - name: profile_accel + type: double + - name: max_duration + type: double + + - name: actuator_prof_torque + fields: + - name: target_torque_amps + type: double + - name: max_duration + type: double + + - name: actuator_reset + fields: + - name: dummy + type: bool + comment: unused + + - name: actuator_halt + fields: + - name: dummy + type: bool + comment: unused + + - name: actuator_set_output_position + fields: + - name: position + type: double + + - name: actuator_calibrate + fields: + - name: velocity + type: double + - name: accel + type: double + - name: max_current + type: double + + - name: actuator_set_max_current + fields: + - name: current + type: double + comment: Corresponds to the PL[1] or Peak current setting + + - name: actuator_sdo_set_unit_mode + fields: + - name: mode + type: int32_t + comment: UM[1] = 5 by default for pos, vel, and current command modes + - name: app_id + type: uint16_t + + - name: actuator_sdo_disable_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: actuator_sdo_enable_speed_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: actuator_sdo_enable_position_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: actuator_sdo_enable_manual_gain_scheduling + fields: + - name: app_id + type: uint16_t + + - name: faulter_enable + fields: + - name: enable + type: bool + comment: if true, faulter will trigger a fault when the specified signal is received. + + - name: pid_activate + fields: + - name: setpoint + type: double + - name: deadband + type: double + - name: persistence_duration + type: double + - name: max_duration + type: double + + - name: async_sdo_write + comment: "async_sdo commands are not available for use by the fastcat commander device" + fields: + - name: sdo_index + type: uint16_t + - name: sdo_subindex + type: uint8_t + - name: data + type: jsd_sdo_data_t + - name: data_type + type: jsd_sdo_data_type_t + - name: app_id + type: uint16_t + + - name: async_sdo_read + comment: "async_sdo commands are not available for use by the fastcat commander device" + fields: + - name: sdo_index + type: uint16_t + - name: sdo_subindex + type: uint8_t + - name: data_type + type: jsd_sdo_data_type_t + - name: app_id + type: uint16_t diff --git a/src/fcgen/fastcat_devices.yaml b/src/fcgen/fastcat_devices.yaml new file mode 100644 index 0000000..dc6ba48 --- /dev/null +++ b/src/fcgen/fastcat_devices.yaml @@ -0,0 +1,766 @@ +# use snake_case for all variable and device names +# if a config variable has a default value, it is assumed to be optional +# all parameters must have a default value +devices: + - name: commander + type: fastcat_device + state: + - name: enable + type: bool + comment: "If true, commander will emit fastcat commands" + config: + - name: start_enabled + type: bool + comment: "If true, starts issuing commands immediately after initialization" + - name: skip_n_loops + type: uint16_t + comment: "The number of loops between issuing commands when enabled" + - name: device_command_name + type: std::string + comment: "The name of the device commander sends commands" + - name: device_cmd_type + type: DeviceCmdType + comment: "The command type to send to device_command_name" + + - name: conditional + type: fastcat_device + state: + - name: output + type: bool + config: "bool output = (double)signal_value (double)compare_rhs_value" + config: + - name: conditional_type + type: ConditionalOperatorType + comment: "Comparison operator valid inputs: {<, <=, >, >=, ==, !=}" + - name: compare_rhs_value + type: double + comment: "The right-hand side value of the comparison test" + + - name: faulter + type: fastcat_device + state: + - name: enable + type: bool + comment: "If true, the faulter is currently monitoring the fastcat signal for faults" + - name: fault_active + type: bool + comment: "If true, the conditions for raising a fault are met" + config: + - name: start_enabled + type: bool + comment: "If true, starts monitoring the input signal immediately after initialization" + + + - name: filter + type: fastcat_device + state: + - name: output + type: double + comment: "Filtered output value" + config: + - name: filter_type + type: FilterType + comment: "The type of filter" + - name: A + type: std::vector + default: {0} + comment: "Digital-AB: The A coefficients" + - name: B + type: std::vector + default: {0} + comment: "Digital-AB: The B coefficients" + - name: buffer_size + type: uint16_t + default: 1 + comment: "Moving-average: The number of samples which to average over" + + - name: fts + type: fastcat_device + state: + - name: raw_fx + type: double + - name: raw_fy + type: double + - name: raw_fz + type: double + - name: raw_tx + type: double + - name: raw_ty + type: double + - name: raw_tz + type: double + - name: tared_fx + type: double + - name: tared_fy + type: double + - name: tared_fz + type: double + - name: tared_tx + type: double + - name: tared_ty + type: double + - name: tared_tz + type: double + config: + - name: calibration_matrix + type: std::vector + comment: "Must be NxN elements long arranged row-wise, where N is the number of input signals (N=6 typically)" + parameters: + - name: max_force_x + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_y + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_z + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_torque_x + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_y + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_z + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + + - name: function + type: fastcat_device + state: + - name: output + type: double + config: + - name: function_type + type: FunctionType + - name: poly_order + type: uint8_t + default: 0 + comment: "Polynomial: Order of polynominal" + - name: poly_coefficients + type: std::vector + default: {0} + comment: "Polynomial: Order of polynominal" + - name: power_exponent + type: double + default: 0 + comment: "Power: the constant power term i.e input^power_exponent" + - name: exponential_base + type: double + default: e + comment: "Exponential: the base term i.e. exponential_base^input" + + - name: linear_interpolation + type: fastcat_device + state: + - name: output + type: double + - name: is_saturated + type: bool + config: + - name: domain + type: std::vector + comment: "Variable-length domain of linear interpolation table. Must match length of range" + - name: range + type: std::vector + comment: "Variable-length range of linear interpolation table. Must match length of domain" + - name: enable_output_bounds_fault + type: bool + default: true + comment: "If true, emits a fault if the input signal lies outside the (min,max) of the domain" + + - name: pid + type: fastcat_device + state: + - name: active + type: bool + - name: output + type: double + - name: kp_term + type: double + - name: ki_term + type: double + - name: kd_term + type: double + config: + - name: kp + type: double + comment: "Proportional Gain" + - name: ki + type: double + comment: "Integral Gain" + - name: kd + type: double + comment: "Derivative Gain" + - name: windup_limit + type: double + comment: "The Max contribution of the integral term i.e. (ki*error)" + + - name: saturation + type: fastcat_device + state: + - name: output + type: double + config: + - name: lower_limit + type: double + comment: "Lower clipping value" + - name: upper_limit + type: double + comment: "Upper clipping value" + + - name: schmitt_trigger + type: fastcat_device + state: + - name: output + type: bool + config: + - name: low_threshold + type: double + comment: "Lower threshold for turning output on" + - name: high_threshold + type: double + comment: "Upper threshold for turning output off" + + - name: signal_generator + type: fastcat_device + state: + - name: output + type: double + config: + - name: signal_generator_type + type: SignalGeneratorType + comment: "Controls which type of generator to use to create periodic output signal" + - name: sine_wave_angular_frequency + type: double + default: 0 + - name: sine_wave_phase + type: double + default: 0 + - name: sine_wave_offset + type: double + default: 0 + - name: saw_tooth_max + type: double + default: 0 + - name: saw_tooth_min + type: double + default: 0 + - name: saw_tooth_slope + type: double + default: 0 + - name: gaussian_random_mean + type: double + default: 0 + - name: gaussian_random_sigma + type: double + default: 0 + - name: gaussian_random_seed + type: uint32_t + default: 1 + - name: uniform_random_max + type: double + default: 0 + - name: uniform_random_min + type: double + default: 0 + - name: uniform_random_seed + type: uint32_t + default: 1 + + - name: virtual_fts + type: fastcat_device + state: + - name: raw_fx + type: double + - name: raw_fy + type: double + - name: raw_fz + type: double + - name: raw_tx + type: double + - name: raw_ty + type: double + - name: raw_tz + type: double + - name: tared_fx + type: double + - name: tared_fy + type: double + - name: tared_fz + type: double + - name: tared_tx + type: double + - name: tared_ty + type: double + - name: tared_tz + type: double + config: + - name: calibration_matrix + type: std::vector + comment: "Must be 6xN elements long arranged row-wise, where N is the number of input signals (N=6 typically)" + - name: position + type: std::array + comment: "Translation of the original sensor to this virtual sensor" + - name: quaternion + type: std::array + default: [NAN, NAN, NAN, NAN] + comment: "The preferred method for specifying orientation from real to virtual fts in [u,x,y,z] order" + - name: euler + type: std::array + default: [NAN, NAN, NAN] + comment: "The secondary method for specifying orientation from real to virtual fts in [roll, pitch, yaw] + order but computed in the standard absolute Z-Y-X order" + parameters: + - name: max_force_x + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_y + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_z + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_torque_x + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_y + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_z + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + + + - name: ati_fts + type: jsd_device + state: + - name: raw_fx + type: double + - name: raw_fy + type: double + - name: raw_fz + type: double + - name: raw_tx + type: double + - name: raw_ty + type: double + - name: raw_tz + type: double + - name: tared_fx + type: double + - name: tared_fy + type: double + - name: tared_fz + type: double + - name: tared_tx + type: double + - name: tared_ty + type: double + - name: tared_tz + type: double + config: + - name: max_force_x + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_y + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_z + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_torque_x + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_y + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_z + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + + - name: gold_actuator + type: jsd_device + state: + - name: actual_position + type: double + - name: actual_velocity + type: double + - name: actual_current + type: double + - name: faulted + type: bool + - name: cmd_position + type: double + - name: cmd_velocity + type: double + - name: cmd_current + type: double + - name: cmd_max_current + type: double + - name: elmo_state_machine_state + type: uint32_t + comment: "From jsd_elmo_state_machine_state_t" + - name: elmo_mode_of_operation + type: uint32_t + comment: "From jsd_elmo_mode_of_operation_t" + - name: sto_engaged + type: uint8_t + - name: hall_state + type: uint8_t + - name: target_reached + type: uint8_t + - name: motor_on + type: uint8_t + - name: servo_enabled + type: uint8_t + - name: jsd_fault_code + type: uint32_t + comment: "From jsd_elmo_fault_code_t" + - name: fastcat_fault_code + type: uint32_t + - name: emcy_error_code + type: uint16_t + - name: bus_voltage + type: double + - name: drive_temperature + type: uint32_t + - name: elmo_actual_position + type: int32_t + - name: elmo_cmd_position + type: int32_t + - name: actuator_state_machine_state + type: uint32_t + comment: "From jsd_elmo_State_machine_state_t" + - name: power + type: double + + - name: platinum_actuator + type: jsd_device + state: + - name: actual_position + type: double + - name: actual_velocity + type: double + - name: actual_current + type: double + - name: faulted + type: bool + - name: cmd_position + type: double + - name: cmd_velocity + type: double + - name: cmd_current + type: double + - name: cmd_prof_velocity + type: double + comment: "Commanded velocity in Position Profiled mode." + - name: cmd_prof_end_velocity + type: double + comment: "Commanded end velocity in Position Profiled mode." + - name: cmd_prof_accel + type: double + comment: "Commanded acceleration/deceleration in Position and Velocity Profiled modes." + - name: cmd_max_current + type: double + - name: elmo_state_machine_state + type: uint32_t + comment: "From jsd_elmo_state_machine_state_t" + - name: elmo_mode_of_operation + type: uint32_t + comment: "From jsd_epd_mode_of_operation_t" + - name: sto_engaged + type: uint8_t + - name: hall_state + type: uint8_t + - name: target_reached + type: uint8_t + - name: setpoint_ack_rise + type: bool + - name: motor_on + type: uint8_t + - name: servo_enabled + type: uint8_t + - name: jsd_fault_code + type: uint32_t + comment: "From jsd_epd_fault_code_t" + - name: fastcat_fault_code + type: uint32_t + - name: emcy_error_code + type: uint16_t + - name: bus_voltage + type: double + - name: drive_temperature + type: double + - name: elmo_actual_position + type: int32_t + - name: elmo_cmd_position + type: int32_t + - name: actuator_state_machine_state + type: uint32_t + - name: power + type: double + + + - name: egd + type: jsd_device + state: + - name: actual_position + type: int32_t + - name: actual_velocity + type: int32_t + - name: actual_current + type: double + - name: faulted + type: bool + - name: cmd_position + type: int32_t + - name: cmd_velocity + type: int32_t + - name: cmd_current + type: double + - name: cmd_max_current + type: double + - name: cmd_ff_position + type: int32_t + - name: cmd_ff_velocity + type: int32_t + - name: cmd_ff_current + type: double + - name: actual_state_machine_state + type: uint32_t + comment: "From jsd_egd_state_machine_state_t" + - name: actual_mode_of_operation + type: uint32_t + comment: "From jsd_egd_mode_of_operation_t" + - name: sto_engaged + type: uint8_t + - name: hall_state + type: uint8_t + - name: in_motion + type: uint8_t + - name: warning + type: uint8_t + - name: target_reached + type: uint8_t + - name: motor_on + type: uint8_t + - name: servo_enabled + type: uint8_t + - name: fault_code + type: uint32_t + comment: "From jsd_egd_fault_code_t" + - name: emcy_error_code + type: uint16_t + - name: bus_voltage + type: double + - name: analog_input_voltage + type: double + - name: digital_input_ch1 + type: uint8_t + - name: digital_input_ch2 + type: uint8_t + - name: digital_input_ch3 + type: uint8_t + - name: digital_input_ch4 + type: uint8_t + - name: digital_input_ch5 + type: uint8_t + - name: digital_input_ch6 + type: uint8_t + - name: digital_output_cmd_ch1 + type: uint8_t + - name: digital_output_cmd_ch2 + type: uint8_t + - name: digital_output_cmd_ch3 + type: uint8_t + - name: digital_output_cmd_ch4 + type: uint8_t + - name: digital_output_cmd_ch5 + type: uint8_t + - name: digital_output_cmd_ch6 + type: uint8_t + - name: drive_temperature + type: uint32_t + + - name: el3602 + type: jsd_device + state: + - name: voltage_ch1 + type: double + - name: adc_value_ch1 + type: int32_t + - name: voltage_ch2 + type: double + - name: adc_value_ch2 + type: int32_t + + - name: el2124 + type: jsd_device + state: + - name: level_ch1 + type: uint8_t + - name: level_ch2 + type: uint8_t + - name: level_ch3 + type: uint8_t + - name: level_ch4 + type: uint8_t + + - name: el4102 + type: jsd_device + state: + - name: voltage_output_ch1 + type: double + - name: voltage_output_ch2 + type: double + + - name: el3208 + type: jsd_device + state: + - name: output_ch1 + type: double + - name: adc_value_ch1 + type: int16_t + - name: output_ch2 + type: double + - name: adc_value_ch2 + type: int16_t + - name: output_ch3 + type: double + - name: adc_value_ch3 + type: int16_t + - name: output_ch4 + type: double + - name: adc_value_ch4 + type: int16_t + - name: output_ch5 + type: double + - name: adc_value_ch5 + type: int16_t + - name: output_ch6 + type: double + - name: adc_value_ch6 + type: int16_t + - name: output_ch7 + type: double + - name: adc_value_ch7 + type: int16_t + - name: output_ch8 + type: double + - name: adc_value_ch8 + type: int16_t + + - name: el3162 + type: jsd_device + state: + - name: voltage_ch1 + type: double + - name: adc_value_ch1 + type: int16_t + - name: voltage_ch2 + type: double + - name: adc_value_ch2 + type: int16_t + + - name: el3104 + type: jsd_device + state: + - name: voltage_ch1 + type: double + - name: adc_value_ch1 + type: int16_t + - name: voltage_ch2 + type: double + - name: adc_value_ch2 + type: int16_t + - name: voltage_ch3 + type: double + - name: adc_value_ch3 + type: int16_t + - name: voltage_ch4 + type: double + - name: adc_value_ch4 + type: int16_t + + - name: el3202 + type: jsd_device + state: + - name: output_eu_ch1 + type: double + - name: adc_value_ch1 + type: int16_t + - name: output_eu_ch2 + type: double + - name: adc_value_ch2 + type: int16_t + + - name: el3318 + type: jsd_device + state: + - name: output_eu_ch1 + type: double + - name: adc_value_ch1 + type: int16_t + - name: output_eu_ch2 + type: double + - name: adc_value_ch2 + type: int16_t + - name: output_eu_ch3 + type: double + - name: adc_value_ch3 + type: int16_t + - name: output_eu_ch4 + type: double + - name: adc_value_ch4 + type: int16_t + - name: output_eu_ch5 + type: double + - name: adc_value_ch5 + type: int16_t + - name: output_eu_ch6 + type: double + - name: adc_value_ch6 + type: int16_t + - name: output_eu_ch7 + type: double + - name: adc_value_ch7 + type: int16_t + - name: output_eu_ch8 + type: double + - name: adc_value_ch8 + type: int16_t + + - name: ild1900 + type: jsd_device + state: + - name: distance_m + type: double + - name: intensity + type: double + - name: distance_raw + type: uint32_t + - name: timestamp_us + type: uint32_t + - name: counter + type: uint32_t + - name: error + type: uint8_t diff --git a/src/fcgen/fastcat_enums.yaml b/src/fcgen/fastcat_enums.yaml new file mode 100644 index 0000000..142ca2d --- /dev/null +++ b/src/fcgen/fastcat_enums.yaml @@ -0,0 +1,38 @@ +# use snake_case for type-name and UPPER for value +# if string is not supplied, it will be taken as the value +enumerations: + - name: conditional_operator_type + entries: + - string: "<" + value: LT + - string: "<=" + value: LE + - string: ">" + value: GT + - string: ">=" + value: GE + - string: "==" + value: EQ + - string: "!=" + value: NE + + - name: filter_type + entries: + - value: DIGITAL_AB + - value: MOVING_AVERAGE + + - name: function_type + entries: + - value: POLYNOMIAL + - value: SUMMATION + - value: MULTIPLICATION + - value: POWER + - value: EXPONENTIAL + - value: SIGMOID + + - name: signal_generator_type + entries: + - value: SINE_WAVE + - value: SAW_TOOTH + - value: GAUSSIAN_RANDOM + - value: UNIFORM_RANDOM diff --git a/src/fcgen/fastcat_types.yaml b/src/fcgen/fastcat_manager_config.yaml similarity index 58% rename from src/fcgen/fastcat_types.yaml rename to src/fcgen/fastcat_manager_config.yaml index 79d0d7f..28ecb18 100644 --- a/src/fcgen/fastcat_types.yaml +++ b/src/fcgen/fastcat_manager_config.yaml @@ -1,43 +1,238 @@ +# use snake_case for type-name and UPPER for value +# if string is not supplied, it will be taken as the value +enumerations: + - name: conditional_operator_type + entries: + - string: "<" + value: LT + - string: "<=" + value: LE + - string: ">" + value: GT + - string: ">=" + value: GE + - string: "==" + value: EQ + - string: "!=" + value: NE + - name: filter_type + entries: + - value: DIGITAL_AB + - value: MOVING_AVERAGE + - name: function_type + entries: + - value: POLYNOMIAL + - value: SUMMATION + - value: MULTIPLICATION + - value: POWER + - value: EXPONENTIAL + - value: SIGMOID + - name: signal_generator_type + entries: + - value: SINE_WAVE + - value: SAW_TOOTH + - value: GAUSSIAN_RANDOM + - value: UNIFORM_RANDOM + +# use snake_case for all variables +manager_config: + - name: target_loop_rate_hz + type: double + comment: "Target loop rate the application will run the process loop" + - name: zero_latency_required + type: bool + default: true + comment: "If zero-latency is required in order to properly initialize" + - name: actuator_position_directory + type: std::string + default: /tmp/ + comment: "Location of the fastcat saved position file for incremental feedback sensors" + - name: actuator_fault_on_missing_pos_file + type: bool + default: true + comment: "If true, fails to initialize if this file is not present. + Otherwise, fastcat creates this file." + # use snake_case for all variable and device names -states: +# if a config variable has a default value, it is assumed to be optional +# all parameters must have a default value +devices: - name: commander - fields: + type: fastcat_device + state: - name: enable type: bool - comment: if true, commander will emit fastcat commands + comment: "If true, commander will emit fastcat commands" + config: + - name: start_enabled + type: bool + comment: "If true, starts issuing commands immediately after initialization" + - name: skip_n_loops + type: uint16_t + comment: "The number of loops between issuing commands when enabled" + - name: device_command_name + type: std::string + comment: "The name of the device commander sends commands" + - name: device_cmd_type + type: DeviceCmdType + comment: "The command type to send to device_command_name" - - name: signal_generator - fields: + - name: conditional + type: fastcat_device + state: - name: output + type: bool + config: "bool output = (double)signal_value (double)compare_rhs_value" + config: + - name: conditional_type + type: ConditionalOperatorType + comment: "Comparison operator valid inputs: {<, <=, >, >=, ==, !=}" + - name: compare_rhs_value type: double + comment: "The right-hand side value of the comparison test" - - name: function - fields: + - name: faulter + type: fastcat_device + state: + - name: enable + type: bool + comment: "If true, the faulter is currently monitoring the fastcat signal for faults" + - name: fault_active + type: bool + comment: "If true, the conditions for raising a fault are met" + config: + - name: start_enabled + type: bool + comment: "If true, starts monitoring the input signal immediately after initialization" + + + - name: filter + type: fastcat_device + state: - name: output type: double + comment: "Filtered output value" + config: + - name: filter_type + type: FilterType + comment: "The type of filter" + - name: A + type: std::vector + default: {0} + comment: "Digital-AB: The A coefficients" + - name: B + type: std::vector + default: {0} + comment: "Digital-AB: The B coefficients" + - name: buffer_size + type: uint16_t + default: 1 + comment: "Moving-average: The number of samples which to average over" - - name: conditional - fields: - - name: output - type: bool + - name: fts + type: fastcat_device + state: + - name: raw_fx + type: double + - name: raw_fy + type: double + - name: raw_fz + type: double + - name: raw_tx + type: double + - name: raw_ty + type: double + - name: raw_tz + type: double + - name: tared_fx + type: double + - name: tared_fy + type: double + - name: tared_fz + type: double + - name: tared_tx + type: double + - name: tared_ty + type: double + - name: tared_tz + type: double + config: + - name: calibration_matrix + type: std::vector + comment: "Must be NxN elements long arranged row-wise, where N is the number of input signals (N=6 typically)" + parameters: + - name: max_force_x + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_y + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_z + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_torque_x + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_y + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_z + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" - - name: schmitt_trigger - fields: - - name: output - type: bool - - - name: saturation - fields: + - name: function + type: fastcat_device + state: - name: output type: double + config: + - name: function_type + type: FunctionType + - name: poly_order + type: uint8_t + default: 0 + comment: "Polynomial: Order of polynominal" + - name: poly_coefficients + type: std::vector + default: {0} + comment: "Polynomial: Order of polynominal" + - name: power_exponent + type: double + default: 0 + comment: "Power: the constant power term i.e input^power_exponent" + - name: exponential_base + type: double + default: e + comment: "Exponential: the base term i.e. exponential_base^input" - - name: filter - fields: + - name: linear_interpolation + type: fastcat_device + state: - name: output type: double + - name: is_saturated + type: bool + config: + - name: domain + type: std::vector + comment: "Variable-length domain of linear interpolation table. Must match length of range" + - name: range + type: std::vector + comment: "Variable-length range of linear interpolation table. Must match length of domain" + - name: enable_output_bounds_fault + type: bool + default: true + comment: "If true, emits a fault if the input signal lies outside the (min,max) of the domain" - name: pid - fields: + type: fastcat_device + state: - name: active type: bool - name: output @@ -48,9 +243,165 @@ states: type: double - name: kd_term type: double + config: + - name: kp + type: double + comment: "Proportional Gain" + - name: ki + type: double + comment: "Integral Gain" + - name: kd + type: double + comment: "Derivative Gain" + - name: windup_limit + type: double + comment: "The Max contribution of the integral term i.e. (ki*error)" - - name: fts - fields: + - name: saturation + type: fastcat_device + state: + - name: output + type: double + config: + - name: lower_limit + type: double + comment: "Lower clipping value" + - name: upper_limit + type: double + comment: "Upper clipping value" + + - name: schmitt_trigger + type: fastcat_device + state: + - name: output + type: bool + config: + - name: low_threshold + type: double + comment: "Lower threshold for turning output on" + - name: high_threshold + type: double + comment: "Upper threshold for turning output off" + + - name: signal_generator + type: fastcat_device + state: + - name: output + type: double + config: + - name: signal_generator_type + type: SignalGeneratorType + comment: "Controls which type of generator to use to create periodic output signal" + - name: sine_wave_angular_frequency + type: double + default: 0 + - name: sine_wave_phase + type: double + default: 0 + - name: sine_wave_offset + type: double + default: 0 + - name: saw_tooth_max + type: double + default: 0 + - name: saw_tooth_min + type: double + default: 0 + - name: saw_tooth_slope + type: double + default: 0 + - name: gaussian_random_mean + type: double + default: 0 + - name: gaussian_random_sigma + type: double + default: 0 + - name: gaussian_random_seed + type: uint32_t + default: 1 + - name: uniform_random_max + type: double + default: 0 + - name: uniform_random_min + type: double + default: 0 + - name: uniform_random_seed + type: uint32_t + default: 1 + + - name: virtual_fts + type: fastcat_device + state: + - name: raw_fx + type: double + - name: raw_fy + type: double + - name: raw_fz + type: double + - name: raw_tx + type: double + - name: raw_ty + type: double + - name: raw_tz + type: double + - name: tared_fx + type: double + - name: tared_fy + type: double + - name: tared_fz + type: double + - name: tared_tx + type: double + - name: tared_ty + type: double + - name: tared_tz + type: double + config: + - name: calibration_matrix + type: std::vector + comment: "Must be 6xN elements long arranged row-wise, where N is the number of input signals (N=6 typically)" + - name: position + type: std::array + comment: "Translation of the original sensor to this virtual sensor" + - name: quaternion + type: std::array + default: [NAN, NAN, NAN, NAN] + comment: "The preferred method for specifying orientation from real to virtual fts in [u,x,y,z] order" + - name: euler + type: std::array + default: [NAN, NAN, NAN] + comment: "The secondary method for specifying orientation from real to virtual fts in [roll, pitch, yaw] + order but computed in the standard absolute Z-Y-X order" + parameters: + - name: max_force_x + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_y + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_z + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_torque_x + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_y + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_z + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + + + - name: ati_fts + type: jsd_device + state: - name: raw_fx type: double - name: raw_fy @@ -75,9 +426,35 @@ states: type: double - name: tared_tz type: double + config: + - name: max_force_x + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_y + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_force_z + type: double + default: 1.0e-6 + comment: "Absolute-value force above which a fault will be raised" + - name: max_torque_x + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_y + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" + - name: max_torque_z + type: double + default: 1.0e-6 + comment: "Absolute-value torque above which a fault will be raised" - name: gold_actuator - fields: + type: jsd_device + state: - name: actual_position type: double - name: actual_velocity @@ -99,7 +476,7 @@ states: comment: "From jsd_elmo_state_machine_state_t" - name: elmo_mode_of_operation type: uint32_t - comment: "From jsd_egd_mode_of_operation_t" + comment: "From jsd_elmo_mode_of_operation_t" - name: sto_engaged type: uint8_t - name: hall_state @@ -112,7 +489,7 @@ states: type: uint8_t - name: jsd_fault_code type: uint32_t - comment: "From jsd_egd_fault_code_t" + comment: "From jsd_elmo_fault_code_t" - name: fastcat_fault_code type: uint32_t - name: emcy_error_code @@ -127,11 +504,13 @@ states: type: int32_t - name: actuator_state_machine_state type: uint32_t + comment: "From jsd_elmo_State_machine_state_t" - name: power type: double - name: platinum_actuator - fields: + type: jsd_device + state: - name: actual_position type: double - name: actual_velocity @@ -195,25 +574,10 @@ states: - name: power type: double - - name: faulter - fields: - - name: enable - type: bool - comment: if true, the faulter is monitoring the fastcat signal for faults - - name: fault_active - type: bool - comment: "if true, the conditions for faulting are met - - on rising edge, the faulter will trigger all devices to fault." - - - name: linear_interpolation - fields: - - name: output - type: double - - name: is_saturated - type: bool - name: egd - fields: + type: jsd_device + state: - name: actual_position type: int32_t - name: actual_velocity @@ -293,7 +657,8 @@ states: type: uint32_t - name: el3602 - fields: + type: jsd_device + state: - name: voltage_ch1 type: double - name: adc_value_ch1 @@ -304,7 +669,8 @@ states: type: int32_t - name: el2124 - fields: + type: jsd_device + state: - name: level_ch1 type: uint8_t - name: level_ch2 @@ -315,14 +681,16 @@ states: type: uint8_t - name: el4102 - fields: + type: jsd_device + state: - name: voltage_output_ch1 type: double - name: voltage_output_ch2 type: double - name: el3208 - fields: + type: jsd_device + state: - name: output_ch1 type: double - name: adc_value_ch1 @@ -357,7 +725,8 @@ states: type: int16_t - name: el3162 - fields: + type: jsd_device + state: - name: voltage_ch1 type: double - name: adc_value_ch1 @@ -368,7 +737,8 @@ states: type: int16_t - name: el3104 - fields: + type: jsd_device + state: - name: voltage_ch1 type: double - name: adc_value_ch1 @@ -387,7 +757,8 @@ states: type: int16_t - name: el3202 - fields: + type: jsd_device + state: - name: output_eu_ch1 type: double - name: adc_value_ch1 @@ -398,7 +769,8 @@ states: type: int16_t - name: el3318 - fields: + type: jsd_device + state: - name: output_eu_ch1 type: double - name: adc_value_ch1 @@ -433,7 +805,8 @@ states: type: int16_t - name: ild1900 - fields: + type: jsd_device + state: - name: distance_m type: double - name: intensity @@ -447,56 +820,7 @@ states: - name: error type: uint8_t - - name: jed0101 - fields: - - name: status - type: uint16_t - - name: cmd - type: uint16_t - - name: w_raw - type: uint32_t - - name: x_raw - type: uint32_t - - name: y_raw - type: uint32_t - - name: z_raw - type: uint32_t - - name: w - type: double - - name: x - type: double - - name: y - type: double - - name: z - type: double - - - name: jed0200 - fields: - - name: status - type: uint16_t - - name: cmd - type: uint16_t - - name: ticks - type: uint32_t - - name: voltage_hv - type: float - - name: voltage_lv - type: float - - name: voltage_12v - type: float - - name: temp_ambient - type: float - - name: temp_actuator - type: float - - name: humidity - type: float - - name: pressure - type: float - - name: brake_current - type: uint16_t - - name: brake_cc_val - type: uint16_t - +# use snake_case for all variable and device names commands: - name: commander_enable fields: @@ -786,16 +1110,6 @@ commands: type: bool comment: if true, faulter will trigger a fault when the specified signal is received. - - name: jed0101_set_cmd_value - fields: - - name: cmd - type: uint16_t - - - name: jed0200_set_cmd_value - fields: - - name: cmd - type: uint16_t - - name: pid_activate fields: - name: setpoint diff --git a/src/fcgen/commander.cc.cog b/src/fcgen/templates/commander.cc.cog similarity index 93% rename from src/fcgen/commander.cc.cog rename to src/fcgen/templates/commander.cc.cog index 29a0644..7b42a13 100644 --- a/src/fcgen/commander.cc.cog +++ b/src/fcgen/templates/commander.cc.cog @@ -5,7 +5,10 @@ import re def snake2camel(str): return ''.join(x.capitalize() or '_' for x in str.split('_')) -data = yaml.load(open(cog_yaml_file, 'r'), Loader=yaml.Loader) +cmd_data = yaml.load(open(command_yaml, 'r'), Loader=yaml.Loader) +device_data = yaml.load(open(device_yaml, 'r'), Loader=yaml.Loader) +enum_data = yaml.load(open(enum_yaml, 'r'), Loader=yaml.Loader) +manager_data = yaml.load(open(manager_yaml, 'r'), Loader=yaml.Loader) cog.outl('// This file is autogenerated from: %s' % cog_yaml_file) cog.outl('// using the python cog tool.') @@ -33,7 +36,7 @@ fastcat::Commander::Commander() { MSG_DEBUG("Constructed Commander"); state_ = std::make_shared(); - state_->type = COMMANDER_STATE; + state_->type = COMMANDER_DEVICE; } @@ -75,7 +78,7 @@ bool fastcat::Commander::ConfigFromYaml(YAML::Node node) switch (device_cmd_.type) { [[[cog - for cmd in data['commands']: + for cmd in cmd_data['commands']: if cmd['name'] == "async_sdo_write" or cmd['name'] == "async_sdo_read": continue cog.outl('case %s_CMD:' % cmd['name'].upper()) @@ -144,7 +147,7 @@ bool fastcat::Commander::Read() switch (device_cmd_.type) { [[[cog - for cmd in data['commands']: + for cmd in cmd_data['commands']: if cmd['name'] == "async_sdo_write" or cmd['name'] == "async_sdo_read": continue cog.outl("case %s_CMD:" % cmd['name'].upper()) diff --git a/src/fcgen/templates/device_includes.h.cog b/src/fcgen/templates/device_includes.h.cog new file mode 100644 index 0000000..b0ddbbe --- /dev/null +++ b/src/fcgen/templates/device_includes.h.cog @@ -0,0 +1,41 @@ +[[[cog +import yaml +import re + +def snake2camel(str): + return ''.join(x.capitalize() or '_' for x in str.split('_')) + +cmd_data = yaml.load(open(command_yaml, 'r'), Loader=yaml.Loader) +device_data = yaml.load(open(device_yaml, 'r'), Loader=yaml.Loader) +enum_data = yaml.load(open(enum_yaml, 'r'), Loader=yaml.Loader) +manager_data = yaml.load(open(manager_yaml, 'r'), Loader=yaml.Loader) + +cog.outl('// This file is autogenerated from: %s' % cog_yaml_file) +cog.outl('// using the python cog tool. Do not modify this file manually.') +cog.outl('// Please make modifications to fcgen/fastcat_devices.h.cog') + +]]] +[[[end]]] + +#ifndef FASTCAT_DEVICES_H_ +#define FASTCAT_DEVICES_H_ + + +[[[cog + +for device in device_data['devices']: + + dev_kind = device['type'] + dev_name = device['name'] + + if 'jsd_device' == dev_kind: + cog.outl('#include "fastcat/jsd/%s.h"' % (dev_name)) + cog.outl('#include "fastcat/jsd/%s_offline.h"' % (dev_name)) + else: + cog.outl('#include "fastcat/fastcat_devices/%s.h"' % (dev_name)) + + +]]] +[[[end]]] + +#endif diff --git a/src/fcgen/signal_handling.cc.cog b/src/fcgen/templates/signal_handling.cc.cog similarity index 88% rename from src/fcgen/signal_handling.cc.cog rename to src/fcgen/templates/signal_handling.cc.cog index 2d079fa..e24cb08 100644 --- a/src/fcgen/signal_handling.cc.cog +++ b/src/fcgen/templates/signal_handling.cc.cog @@ -5,7 +5,10 @@ import re def snake2camel(str): return ''.join(x.capitalize() or '_' for x in str.split('_')) -data = yaml.load(open(cog_yaml_file, 'r'), Loader=yaml.Loader) +cmd_data = yaml.load(open(command_yaml, 'r'), Loader=yaml.Loader) +device_data = yaml.load(open(device_yaml, 'r'), Loader=yaml.Loader) +enum_data = yaml.load(open(enum_yaml, 'r'), Loader=yaml.Loader) +manager_data = yaml.load(open(manager_yaml, 'r'), Loader=yaml.Loader) cog.outl('// This file is autogenerated from: %s' % cog_yaml_file) cog.outl('// using the python cog tool.') @@ -121,20 +124,20 @@ bool fastcat::ConfigSignalByteIndexing(fastcat::DeviceState *state, switch (state->type) { [[[cog -for state in data['states']: - cog.outl('case %s_STATE:' % state['name'].upper()) +for device in device_data['devices']: + cog.outl('case %s_DEVICE:' % device['name'].upper()) - if(len(state['fields']) == 0): + if(len(device['state']) == 0): cog.outl('ERROR("%s has no valid signals);' % state['name'].upper()); cog.outl('return false;'); else: - for field in state['fields']: + for field in device['state']: cog.outl('if (signal.request_signal_name.compare("%s") == 0) {' % field['name']); dtype_tuple = [(native, enum) for native, enum in dtype_native_enum if native == field['type']] if len(dtype_tuple) > 0: - cog.outl(' signal.data_loc = (void *)&state->%s_state.%s;' % (state['name'], field['name'])) + cog.outl(' signal.data_loc = (void *)&state->%s_state.%s;' % (device['name'], field['name'])) cog.outl(' signal.data_type = %s;' % (dtype_tuple[0][1])) cog.outl(' return true;') cog.out('}') @@ -144,7 +147,7 @@ for state in data['states']: cog.out('}') cog.outl('else {') - cog.outl(' ERROR("%s invalid signal: %s", signal.request_signal_name.c_str());' % (state['name'].upper(), "%s")) + cog.outl(' ERROR("%s invalid signal: %s", signal.request_signal_name.c_str());' % (device['name'].upper(), "%s")) cog.outl(' return false;') cog.outl('}') cog.outl('break;') @@ -166,7 +169,7 @@ enum fastcat::DeviceCmdType fastcat::DeviceCmdTypeFromString(std::string str) { [[[cog -for cmd in data['commands']: +for cmd in cmd_data['commands']: cog.outl('if (std::string("%s_CMD").compare(str) == 0) {' % cmd['name'].upper()) cog.outl(' return fastcat::%s_CMD;' % cmd['name'].upper()) cog.outl('}'); diff --git a/src/fcgen/types.h.cog b/src/fcgen/templates/types.h.cog similarity index 53% rename from src/fcgen/types.h.cog rename to src/fcgen/templates/types.h.cog index 8caa34b..3a2ca93 100644 --- a/src/fcgen/types.h.cog +++ b/src/fcgen/templates/types.h.cog @@ -5,7 +5,10 @@ import re def snake2camel(str): return ''.join(x.capitalize() or '_' for x in str.split('_')) -data = yaml.load(open(cog_yaml_file, 'r'), Loader=yaml.Loader) +cmd_data = yaml.load(open(command_yaml, 'r'), Loader=yaml.Loader) +device_data = yaml.load(open(device_yaml, 'r'), Loader=yaml.Loader) +enum_data = yaml.load(open(enum_yaml, 'r'), Loader=yaml.Loader) +manager_data = yaml.load(open(manager_yaml, 'r'), Loader=yaml.Loader) cog.outl('// This file is autogenerated from: %s' % cog_yaml_file) cog.outl('// using the python cog tool. Do not modify this file manually.') @@ -19,36 +22,42 @@ cog.outl('// Please make modifications to fcgen/types.h.cog') #include +#include #include "jsd/jsd_types.h" namespace fastcat { +////////////////////////////////// +// Manager Configuration Struct +////////////////////////////////// +typedef struct { +[[[cog +for field in manager_data['manager_config']: + cog.outl('%s %s;' % (field['type'], field['name'])) +]]] +[[[end]]] +} MangerConfig; ////////////////////////////////// -// Device Commands +// Device Types ////////////////////////////////// +enum DeviceType { [[[cog -for cmd in data['commands']: - cog.outl('typedef struct {') - for field in cmd['fields']: - cog.outl('%s %s;' % (field['type'], field['name'])) - camel = snake2camel(cmd['name']) - cog.outl('} %sCmd;' % camel) - cog.outl('') - +for device in device_data['devices']: + cog.outl('%s_DEVICE,' % device['name'].upper()) ]]] [[[end]]] - +}; ////////////////////////////////// -// Fastcat Commands +// Command Types ////////////////////////////////// enum DeviceCmdType { [[[cog -for cmd in data['commands']: +for cmd in cmd_data['commands']: cog.outl('%s_CMD,' %cmd['name'].upper()) ]]] [[[end]]] @@ -56,66 +65,117 @@ for cmd in data['commands']: }; + +////////////////////////////////// +// Device Configuration Types +////////////////////////////////// +[[[cog +for this_enum in enum_data['enumerations']: + cog.outl('enum %s {' % (snake2camel(this_enum['name']))) + for entry in this_enum['entries']: + cog.outl('%s,' % entry['value'].upper()) + cog.outl('BAD_%s' % this_enum['name'].upper()) + cog.outl('};') +]]] +[[[end]]] + + +////////////////////////////////// +// Device States +////////////////////////////////// +[[[cog +for device in device_data['devices']: + cog.outl('typedef struct {') + for field in device['state']: + cog.outl('%s %s;' % (field['type'], field['name'])) + camel = snake2camel(device['name']) + cog.outl('} %sState;' % camel) + cog.outl('') + +]]] +[[[end]]] + typedef struct { std::string name; - DeviceCmdType type; + DeviceType type; union { [[[cog -for cmd in data['commands']: - camel = snake2camel(cmd['name']) - cog.outl('%sCmd %s_cmd;' % (camel, cmd['name']) ) +for device in device_data['devices']: + camel = snake2camel(device['name']) + cog.outl('%sState %s_state;' % (camel, device['name']) ) ]]] [[[end]]] }; -} DeviceCmd; - - - + double time; +} DeviceState; ////////////////////////////////// -// Device States +// Device Config ////////////////////////////////// [[[cog -for state in data['states']: +for device in device_data['devices']: cog.outl('typedef struct {') - for field in state['fields']: - cog.outl('%s %s;' % (field['type'], field['name'])) - camel = snake2camel(state['name']) - cog.outl('} %sState;' % camel) + if not 'config' in device: + cog.outl('bool dummy; // device does not have any config') + else: + for field in device['config']: + cog.outl('%s %s;' % (field['type'], field['name'])) + camel = snake2camel(device['name']) + cog.outl('} %sConfig;' % camel) cog.outl('') ]]] [[[end]]] +typedef std::variant< +[[[cog +for device in device_data['devices']: + if device in device_data['devices'][:-1]: + cog.out('%sConfig,' % (snake2camel(device['name'])) ) + else: + cog.out('%sConfig' % (snake2camel(device['name'])) ) + cog.out('\n') +]]] +[[[end]]] +> DeviceConfigVariant; + +typedef struct{ + std::string name; + DeviceConfigVariant config_variant; +} DeviceConfig; + + ////////////////////////////////// -// Fastcat States +// Device Commands ////////////////////////////////// -enum DeviceStateType { [[[cog -for state in data['states']: - cog.outl('%s_STATE,' % state['name'].upper()) +for cmd in cmd_data['commands']: + cog.outl('typedef struct {') + for field in cmd['fields']: + cog.outl('%s %s;' % (field['type'], field['name'])) + camel = snake2camel(cmd['name']) + cog.outl('} %sCmd;' % camel) + cog.outl('') + ]]] [[[end]]] - BAD_DEVICE_STATE -}; typedef struct { std::string name; - DeviceStateType type; + DeviceCmdType type; union { [[[cog -for state in data['states']: - camel = snake2camel(state['name']) - cog.outl('%sState %s_state;' % (camel, state['name']) ) +for cmd in cmd_data['commands']: + camel = snake2camel(cmd['name']) + cog.outl('%sCmd %s_cmd;' % (camel, cmd['name']) ) ]]] [[[end]]] }; - double time; -} DeviceState; +} DeviceCmd; ////////////////////////////////// @@ -136,7 +196,6 @@ typedef enum { typedef struct { // Yaml input fields - std::string observed_device_name; std::string request_signal_name; std::string cmd_field_name; diff --git a/src/jsd/actuator.cc b/src/jsd/actuator.cc index 35f8578..d5ab00e 100644 --- a/src/jsd/actuator.cc +++ b/src/jsd/actuator.cc @@ -673,9 +673,9 @@ std::string fastcat::Actuator::GetFastcatFaultCodeAsString( { std::string fault_str; - if (state.type == GOLD_ACTUATOR_STATE || state.type == PLATINUM_ACTUATOR_STATE) { + if (state.type == GOLD_ACTUATOR_DEVICE || state.type == PLATINUM_ACTUATOR_DEVICE) { ActuatorFastcatFault fault; - if (state.type == GOLD_ACTUATOR_STATE) { + if (state.type == GOLD_ACTUATOR_DEVICE) { fault = static_cast( state.gold_actuator_state.fastcat_fault_code); } else { @@ -731,11 +731,11 @@ std::string fastcat::Actuator::GetJSDFaultCodeAsString(const DeviceState& state) { std::string fault_str; - if (state.type == GOLD_ACTUATOR_STATE) { + if (state.type == GOLD_ACTUATOR_DEVICE) { auto fault = static_cast( state.gold_actuator_state.jsd_fault_code); fault_str = std::string(jsd_egd_fault_code_to_string(fault)); - } else if (state.type == PLATINUM_ACTUATOR_STATE) { + } else if (state.type == PLATINUM_ACTUATOR_DEVICE) { auto fault = static_cast( state.platinum_actuator_state.jsd_fault_code); fault_str = std::string(jsd_epd_fault_code_to_string(fault)); @@ -750,11 +750,11 @@ bool fastcat::Actuator::IsJsdFaultCodePresent(const DeviceState& state) { bool fault_present = false; - if (state.type == GOLD_ACTUATOR_STATE) { + if (state.type == GOLD_ACTUATOR_DEVICE) { if (state.gold_actuator_state.jsd_fault_code != JSD_EGD_FAULT_OKAY) { fault_present = true; } - } else if (state.type == PLATINUM_ACTUATOR_STATE) { + } else if (state.type == PLATINUM_ACTUATOR_DEVICE) { if (state.platinum_actuator_state.jsd_fault_code != JSD_EPD_FAULT_OKAY) { fault_present = true; } @@ -771,9 +771,9 @@ bool fastcat::Actuator::IsJsdFaultCodePresent(const DeviceState& state) double fastcat::Actuator::GetActualPosition(const DeviceState& state) { double actual_position; - if (state.type == GOLD_ACTUATOR_STATE) { + if (state.type == GOLD_ACTUATOR_DEVICE) { actual_position = state.gold_actuator_state.actual_position; - } else if (state.type == PLATINUM_ACTUATOR_STATE) { + } else if (state.type == PLATINUM_ACTUATOR_DEVICE) { actual_position = state.platinum_actuator_state.actual_position; } else { ERROR( diff --git a/src/jsd/ati_fts.cc b/src/jsd/ati_fts.cc index 71ad6c9..bc2bcb6 100644 --- a/src/jsd/ati_fts.cc +++ b/src/jsd/ati_fts.cc @@ -12,7 +12,7 @@ fastcat::AtiFts::AtiFts() MSG_DEBUG("Constructed AtiFts"); state_ = std::make_shared(); - state_->type = FTS_STATE; + state_->type = ATI_FTS_DEVICE; } bool fastcat::AtiFts::ConfigFromYamlCommon(YAML::Node node) diff --git a/src/jsd/egd.cc b/src/jsd/egd.cc index 3487993..bef22ad 100644 --- a/src/jsd/egd.cc +++ b/src/jsd/egd.cc @@ -15,7 +15,7 @@ fastcat::Egd::Egd() MSG_DEBUG("Constructed Egd"); state_ = std::make_shared(); - state_->type = EGD_STATE; + state_->type = EGD_DEVICE; } bool fastcat::Egd::ConfigFromYaml(YAML::Node node) diff --git a/src/jsd/el2124.cc b/src/jsd/el2124.cc index 1cf529e..17996ab 100644 --- a/src/jsd/el2124.cc +++ b/src/jsd/el2124.cc @@ -15,7 +15,7 @@ fastcat::El2124::El2124() MSG_DEBUG("Constructed El2124"); state_ = std::make_shared(); - state_->type = EL2124_STATE; + state_->type = EL2124_DEVICE; } bool fastcat::El2124::ConfigFromYaml(YAML::Node node) diff --git a/src/jsd/el3104.cc b/src/jsd/el3104.cc index b2e43b5..79399ca 100644 --- a/src/jsd/el3104.cc +++ b/src/jsd/el3104.cc @@ -15,7 +15,7 @@ fastcat::El3104::El3104() MSG_DEBUG("Constructed El3104"); state_ = std::make_shared(); - state_->type = EL3104_STATE; + state_->type = EL3104_DEVICE; } bool fastcat::El3104::ConfigFromYaml(YAML::Node node) diff --git a/src/jsd/el3162.cc b/src/jsd/el3162.cc index e74e037..14b8f97 100644 --- a/src/jsd/el3162.cc +++ b/src/jsd/el3162.cc @@ -11,7 +11,7 @@ fastcat::El3162::El3162() MSG_DEBUG("Constructed El3162"); state_ = std::make_shared(); - state_->type = EL3162_STATE; + state_->type = EL3162_DEVICE; } bool fastcat::El3162::ConfigFromYaml(YAML::Node node) @@ -48,4 +48,4 @@ bool fastcat::El3162::Read() state_->el3162_state.adc_value_ch2 = jsd_state->adc_value[1]; return true; -} \ No newline at end of file +} diff --git a/src/jsd/el3202.cc b/src/jsd/el3202.cc index 8f9a8db..002162b 100644 --- a/src/jsd/el3202.cc +++ b/src/jsd/el3202.cc @@ -15,7 +15,7 @@ fastcat::El3202::El3202() MSG_DEBUG("Constructed El3202"); state_ = std::make_shared(); - state_->type = EL3202_STATE; + state_->type = EL3202_DEVICE; } bool fastcat::El3202::ConfigFromYaml(YAML::Node node) diff --git a/src/jsd/el3208.cc b/src/jsd/el3208.cc index f7bca0d..37e114d 100644 --- a/src/jsd/el3208.cc +++ b/src/jsd/el3208.cc @@ -16,7 +16,7 @@ fastcat::El3208::El3208() MSG_DEBUG("Constructed El3208"); state_ = std::make_shared(); - state_->type = EL3208_STATE; + state_->type = EL3208_DEVICE; outputs_[0] = &state_->el3208_state.output_ch1; outputs_[1] = &state_->el3208_state.output_ch2; diff --git a/src/jsd/el3318.cc b/src/jsd/el3318.cc index 93b3111..fe3e1c4 100644 --- a/src/jsd/el3318.cc +++ b/src/jsd/el3318.cc @@ -15,7 +15,7 @@ fastcat::El3318::El3318() MSG_DEBUG("Constructed El3318"); state_ = std::make_shared(); - state_->type = EL3318_STATE; + state_->type = EL3318_DEVICE; } bool fastcat::El3318::ConfigFromYaml(YAML::Node node) diff --git a/src/jsd/el3602.cc b/src/jsd/el3602.cc index e99fe10..523ee14 100644 --- a/src/jsd/el3602.cc +++ b/src/jsd/el3602.cc @@ -15,7 +15,7 @@ fastcat::El3602::El3602() MSG_DEBUG("Constructed El3602"); state_ = std::make_shared(); - state_->type = EL3602_STATE; + state_->type = EL3602_DEVICE; } bool fastcat::El3602::ConfigFromYaml(YAML::Node node) diff --git a/src/jsd/el4102.cc b/src/jsd/el4102.cc index a658a33..9a95a5b 100644 --- a/src/jsd/el4102.cc +++ b/src/jsd/el4102.cc @@ -15,7 +15,7 @@ fastcat::El4102::El4102() MSG_DEBUG("Constructed El4102"); state_ = std::make_shared(); - state_->type = EL4102_STATE; + state_->type = EL4102_DEVICE; } bool fastcat::El4102::ConfigFromYaml(YAML::Node node) diff --git a/src/jsd/gold_actuator.cc b/src/jsd/gold_actuator.cc index d274951..6504c88 100644 --- a/src/jsd/gold_actuator.cc +++ b/src/jsd/gold_actuator.cc @@ -8,7 +8,7 @@ // Include external then project includes #include "jsd/jsd.h" -fastcat::GoldActuator::GoldActuator() { state_->type = GOLD_ACTUATOR_STATE; } +fastcat::GoldActuator::GoldActuator() { state_->type = GOLD_ACTUATOR_DEVICE; } void fastcat::GoldActuator::PopulateJsdSlaveConfig() { diff --git a/src/jsd/ild1900.cc b/src/jsd/ild1900.cc index 1299e43..fa043b5 100644 --- a/src/jsd/ild1900.cc +++ b/src/jsd/ild1900.cc @@ -11,7 +11,7 @@ fastcat::Ild1900::Ild1900() MSG_DEBUG("Constructed ILD1900"); state_ = std::make_shared(); - state_->type = ILD1900_STATE; + state_->type = ILD1900_DEVICE; } bool fastcat::Ild1900::ConfigFromYaml(YAML::Node node) @@ -196,4 +196,4 @@ bool fastcat::Ild1900::PeakSelectionFromString( } return true; -} \ No newline at end of file +} diff --git a/src/jsd/jed0101.cc b/src/jsd/jed0101.cc deleted file mode 100644 index 6fc346a..0000000 --- a/src/jsd/jed0101.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Include related header (for cc files) -#include "fastcat/jsd/jed0101.h" - -// Include c then c++ libraries -#include - -// Include external then project includes -#include "fastcat/yaml_parser.h" -#include "jsd/jsd_print.h" - -fastcat::Jed0101::Jed0101() -{ - MSG_DEBUG("Constructed Jed0101"); - - state_ = std::make_shared(); - state_->type = JED0101_STATE; -} - -bool fastcat::Jed0101::ConfigFromYaml(YAML::Node node) -{ - bool retval = ConfigFromYamlCommon(node); - jsd_set_slave_config((jsd_t*)context_, slave_id_, jsd_slave_config_); - return retval; -} -bool fastcat::Jed0101::ConfigFromYamlCommon(YAML::Node node) -{ - if (!ParseVal(node, "name", name_)) { - return false; - } - state_->name = name_; - - jsd_slave_config_.configuration_active = true; - jsd_slave_config_.product_code = JSD_JED0101_PRODUCT_CODE; - snprintf(jsd_slave_config_.name, JSD_NAME_LEN, "%s", name_.c_str()); - - if (!ParseVal(node, "initial_cmd", initial_cmd_)) { - WARNING("JED0101 intial_cmd unspecified, defaulting to 0"); - initial_cmd_ = 0; - } - - return true; -} - -bool fastcat::Jed0101::Read() -{ - jsd_jed0101_read((jsd_t*)context_, slave_id_); - - const jsd_jed0101_state_t* jsd_state = - jsd_jed0101_get_state((jsd_t*)context_, slave_id_); - - state_->jed0101_state.status = jsd_state->status; - state_->jed0101_state.w_raw = jsd_state->w_raw; - state_->jed0101_state.x_raw = jsd_state->x_raw; - state_->jed0101_state.y_raw = jsd_state->y_raw; - state_->jed0101_state.z_raw = jsd_state->z_raw; - state_->jed0101_state.w = jsd_state->w; - state_->jed0101_state.x = jsd_state->x; - state_->jed0101_state.y = jsd_state->y; - state_->jed0101_state.z = jsd_state->z; - state_->jed0101_state.cmd = jsd_state->cmd; - - return true; -} - -fastcat::FaultType fastcat::Jed0101::Process() -{ - jsd_jed0101_process((jsd_t*)context_, slave_id_); - return NO_FAULT; -} - -bool fastcat::Jed0101::Write(DeviceCmd& cmd) -{ - // If device supports async SDO requests - AsyncSdoRetVal sdoResult = WriteAsyncSdoRequest(cmd); - if (sdoResult != SDO_RET_VAL_NOT_APPLICABLE) { - return (sdoResult == SDO_RET_VAL_SUCCESS); - } - - if (cmd.type == JED0101_SET_CMD_VALUE_CMD) { - jsd_jed0101_set_cmd_value((jsd_t*)context_, slave_id_, - cmd.jed0101_set_cmd_value_cmd.cmd); - - } else { - WARNING("Bad JED0101 Command"); - return false; - } - return true; -} diff --git a/src/jsd/jed0101_offline.cc b/src/jsd/jed0101_offline.cc deleted file mode 100644 index 52ef9fa..0000000 --- a/src/jsd/jed0101_offline.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Include related header (for cc files) -#include "fastcat/jsd/jed0101_offline.h" - -// Include c then c++ libraries -#include - -// Include external then project includes -#include "jsd/jsd_print.h" - -bool fastcat::Jed0101Offline::ConfigFromYaml(YAML::Node node) -{ - bool retval = ConfigFromYamlCommon(node); - state_->jed0101_state.cmd = initial_cmd_; - return retval; -} - -bool fastcat::Jed0101Offline::Read() { return true; } - -fastcat::FaultType fastcat::Jed0101Offline::Process() -{ - return DeviceBase::Process(); -} - -bool fastcat::Jed0101Offline::Write(DeviceCmd& cmd) -{ - // If device supports async SDO requests - AsyncSdoRetVal sdoResult = WriteAsyncSdoRequest(cmd); - if (sdoResult != SDO_RET_VAL_NOT_APPLICABLE) { - return (sdoResult == SDO_RET_VAL_SUCCESS); - } - - if (cmd.type == JED0101_SET_CMD_VALUE_CMD) { - state_->jed0101_state.cmd = cmd.jed0101_set_cmd_value_cmd.cmd; - } else { - WARNING("that command type is not supported yet!"); - return false; - } - return true; -} diff --git a/src/jsd/jed0200.cc b/src/jsd/jed0200.cc deleted file mode 100644 index d965f93..0000000 --- a/src/jsd/jed0200.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Include related header (for cc files) -#include "fastcat/jsd/jed0200.h" - -// Include c then c++ libraries -#include - -// Include external then project includes -#include "fastcat/yaml_parser.h" -#include "jsd/jsd_print.h" - -fastcat::Jed0200::Jed0200() -{ - MSG_DEBUG("Constructed Jed0200"); - - state_ = std::make_shared(); - state_->type = JED0200_STATE; -} - -bool fastcat::Jed0200::ConfigFromYaml(YAML::Node node) -{ - bool retval = ConfigFromYamlCommon(node); - jsd_set_slave_config((jsd_t*)context_, slave_id_, jsd_slave_config_); - return retval; -} -bool fastcat::Jed0200::ConfigFromYamlCommon(YAML::Node node) -{ - if (!ParseVal(node, "name", name_)) { - return false; - } - state_->name = name_; - - jsd_slave_config_.configuration_active = true; - jsd_slave_config_.product_code = JSD_JED0200_PRODUCT_CODE; - snprintf(jsd_slave_config_.name, JSD_NAME_LEN, "%s", name_.c_str()); - - if (!ParseVal(node, "initial_cmd", initial_cmd_)) { - WARNING("JED0200 intial_cmd unspecified, defaulting to 0"); - initial_cmd_ = 0; - } - - return true; -} - -bool fastcat::Jed0200::Read() -{ - jsd_jed0200_read((jsd_t*)context_, slave_id_); - - const jsd_jed0200_state_t* jsd_state = - jsd_jed0200_get_state((jsd_t*)context_, slave_id_); - - state_->jed0200_state.status = jsd_state->status; - state_->jed0200_state.ticks = jsd_state->ticks; - state_->jed0200_state.voltage_hv = jsd_state->voltage_hv; - state_->jed0200_state.voltage_lv = jsd_state->voltage_lv; - state_->jed0200_state.voltage_12v = jsd_state->voltage_12v; - state_->jed0200_state.temp_ambient = jsd_state->temp_ambient; - state_->jed0200_state.temp_actuator = jsd_state->temp_actuator; - state_->jed0200_state.humidity = jsd_state->humidity; - state_->jed0200_state.pressure = jsd_state->pressure; - state_->jed0200_state.brake_current = jsd_state->brake_current; - state_->jed0200_state.brake_cc_val = jsd_state->brake_cc_val; - state_->jed0200_state.cmd = jsd_state->cmd; - - return true; -} - -fastcat::FaultType fastcat::Jed0200::Process() -{ - jsd_jed0200_process((jsd_t*)context_, slave_id_); - return NO_FAULT; -} - -bool fastcat::Jed0200::Write(DeviceCmd& cmd) -{ - // If device supports async SDO requests - AsyncSdoRetVal sdoResult = WriteAsyncSdoRequest(cmd); - if (sdoResult != SDO_RET_VAL_NOT_APPLICABLE) { - return (sdoResult == SDO_RET_VAL_SUCCESS); - } - - if (cmd.type == JED0200_SET_CMD_VALUE_CMD) { - jsd_jed0200_set_cmd_value((jsd_t*)context_, slave_id_, - cmd.jed0200_set_cmd_value_cmd.cmd); - - } else { - WARNING("Bad JED0200 Command"); - return false; - } - return true; -} diff --git a/src/jsd/jed0200_offline.cc b/src/jsd/jed0200_offline.cc deleted file mode 100644 index 7db9ba2..0000000 --- a/src/jsd/jed0200_offline.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Include related header (for cc files) -#include "fastcat/jsd/jed0200_offline.h" - -// Include c then c++ libraries -#include - -// Include external then project includes -#include "jsd/jsd_print.h" - -bool fastcat::Jed0200Offline::ConfigFromYaml(YAML::Node node) -{ - bool retval = ConfigFromYamlCommon(node); - state_->jed0200_state.cmd = initial_cmd_; - return retval; -} - -bool fastcat::Jed0200Offline::Read() { return true; } - -fastcat::FaultType fastcat::Jed0200Offline::Process() -{ - return DeviceBase::Process(); -} - -bool fastcat::Jed0200Offline::Write(DeviceCmd& cmd) -{ - // If device supports async SDO requests - AsyncSdoRetVal sdoResult = WriteAsyncSdoRequest(cmd); - if (sdoResult != SDO_RET_VAL_NOT_APPLICABLE) { - return (sdoResult == SDO_RET_VAL_SUCCESS); - } - - if (cmd.type == JED0200_SET_CMD_VALUE_CMD) { - state_->jed0200_state.cmd = cmd.jed0200_set_cmd_value_cmd.cmd; - } else { - WARNING("that command type is not supported yet!"); - return false; - } - return true; -} diff --git a/src/jsd/platinum_actuator.cc b/src/jsd/platinum_actuator.cc index 9834b78..09719dd 100644 --- a/src/jsd/platinum_actuator.cc +++ b/src/jsd/platinum_actuator.cc @@ -7,7 +7,7 @@ // Include external then project includes -fastcat::PlatinumActuator::PlatinumActuator() { state_->type = PLATINUM_ACTUATOR_STATE; } +fastcat::PlatinumActuator::PlatinumActuator() { state_->type = PLATINUM_ACTUATOR_DEVICE; } void fastcat::PlatinumActuator::PopulateJsdSlaveConfig() { diff --git a/src/manager.cc b/src/manager.cc index 227a391..b5a1f6e 100644 --- a/src/manager.cc +++ b/src/manager.cc @@ -14,48 +14,7 @@ #include // Include external then project includes -#include "fastcat/fastcat_devices/commander.h" -#include "fastcat/fastcat_devices/conditional.h" -#include "fastcat/fastcat_devices/faulter.h" -#include "fastcat/fastcat_devices/filter.h" -#include "fastcat/fastcat_devices/fts.h" -#include "fastcat/fastcat_devices/function.h" -#include "fastcat/fastcat_devices/linear_interpolation.h" -#include "fastcat/fastcat_devices/pid.h" -#include "fastcat/fastcat_devices/saturation.h" -#include "fastcat/fastcat_devices/schmitt_trigger.h" -#include "fastcat/fastcat_devices/signal_generator.h" -#include "fastcat/fastcat_devices/virtual_fts.h" -#include "fastcat/jsd/ati_fts.h" -#include "fastcat/jsd/ati_fts_offline.h" -#include "fastcat/jsd/egd.h" -#include "fastcat/jsd/egd_offline.h" -#include "fastcat/jsd/el2124.h" -#include "fastcat/jsd/el2124_offline.h" -#include "fastcat/jsd/el3104.h" -#include "fastcat/jsd/el3104_offline.h" -#include "fastcat/jsd/el3162.h" -#include "fastcat/jsd/el3162_offline.h" -#include "fastcat/jsd/el3202.h" -#include "fastcat/jsd/el3202_offline.h" -#include "fastcat/jsd/el3208.h" -#include "fastcat/jsd/el3208_offline.h" -#include "fastcat/jsd/el3318.h" -#include "fastcat/jsd/el3318_offline.h" -#include "fastcat/jsd/el3602.h" -#include "fastcat/jsd/el3602_offline.h" -#include "fastcat/jsd/el4102.h" -#include "fastcat/jsd/el4102_offline.h" -#include "fastcat/jsd/gold_actuator.h" -#include "fastcat/jsd/gold_actuator_offline.h" -#include "fastcat/jsd/ild1900.h" -#include "fastcat/jsd/ild1900_offline.h" -#include "fastcat/jsd/jed0101.h" -#include "fastcat/jsd/jed0101_offline.h" -#include "fastcat/jsd/jed0200.h" -#include "fastcat/jsd/jed0200_offline.h" -#include "fastcat/jsd/platinum_actuator.h" -#include "fastcat/jsd/platinum_actuator_offline.h" +#include "fastcat/device_includes.h" #include "fastcat/signal_handling.h" #include "fastcat/yaml_parser.h" #include "jsd/jsd_print.h" @@ -332,11 +291,11 @@ double fastcat::Manager::GetTargetLoopRate() { return target_loop_rate_hz_; } bool fastcat::Manager::IsFaulted() { return faulted_; } void fastcat::Manager::GetDeviceNamesByType( - std::vector& names, fastcat::DeviceStateType device_state_type) + std::vector& names, fastcat::DeviceType device_type) { names.clear(); for (auto& device : jsd_device_list_) { - if (device->GetState()->type == device_state_type) { + if (device->GetState()->type == device_type) { names.push_back(device->GetName()); } } @@ -347,8 +306,8 @@ bool fastcat::Manager::GetActuatorParams( { if (device_map_.count(name)) { auto& device = device_map_[name]; - if (device->GetState()->type == GOLD_ACTUATOR_STATE or - device->GetState()->type == PLATINUM_ACTUATOR_STATE) { + if (device->GetState()->type == GOLD_ACTUATOR_DEVICE or + device->GetState()->type == PLATINUM_ACTUATOR_DEVICE) { auto actuator = std::dynamic_pointer_cast(device); params = actuator->GetParams(); return true; @@ -445,12 +404,6 @@ bool fastcat::Manager::ConfigJSDBusFromYaml(YAML::Node node) } else if (0 == device_class.compare("PlatinumActuator")) { device = std::make_shared(); - } else if (0 == device_class.compare("Jed0101")) { - device = std::make_shared(); - - } else if (0 == device_class.compare("Jed0200")) { - device = std::make_shared(); - } else if (0 == device_class.compare("AtiFts")) { device = std::make_shared(); @@ -645,12 +598,6 @@ bool fastcat::Manager::ConfigOfflineBusFromYaml(YAML::Node node) } else if (0 == device_class.compare("PlatinumActuator")) { device = std::make_shared(); - } else if (0 == device_class.compare("Jed0101")) { - device = std::make_shared(); - - } else if (0 == device_class.compare("Jed0200")) { - device = std::make_shared(); - } else if (0 == device_class.compare("AtiFts")) { device = std::make_shared(); @@ -907,8 +854,8 @@ bool fastcat::Manager::LoadActuatorPosFile() bool actuators_in_topo = false; for (auto device = jsd_device_list_.begin(); device != jsd_device_list_.end(); ++device) { - if ((*device)->GetState()->type == GOLD_ACTUATOR_STATE || - (*device)->GetState()->type == PLATINUM_ACTUATOR_STATE) { + if ((*device)->GetState()->type == GOLD_ACTUATOR_DEVICE || + (*device)->GetState()->type == PLATINUM_ACTUATOR_DEVICE) { actuators_in_topo = true; break; } @@ -1005,8 +952,8 @@ bool fastcat::Manager::ValidateActuatorPosFile() dev_state = (*device)->GetState(); dev_name = (*device)->GetName(); - if (dev_state->type != GOLD_ACTUATOR_STATE && - dev_state->type != PLATINUM_ACTUATOR_STATE) { + if (dev_state->type != GOLD_ACTUATOR_DEVICE && + dev_state->type != PLATINUM_ACTUATOR_DEVICE) { continue; } @@ -1050,8 +997,8 @@ bool fastcat::Manager::SetActuatorPositions() dev_state = (*device)->GetState(); dev_name = (*device)->GetName(); - if (dev_state->type != GOLD_ACTUATOR_STATE && - dev_state->type != PLATINUM_ACTUATOR_STATE) { + if (dev_state->type != GOLD_ACTUATOR_DEVICE && + dev_state->type != PLATINUM_ACTUATOR_DEVICE) { continue; } @@ -1087,8 +1034,8 @@ void fastcat::Manager::GetActuatorPositions() dev_state = (*device)->GetState(); dev_name = (*device)->GetName(); - if (dev_state->type != GOLD_ACTUATOR_STATE && - dev_state->type != PLATINUM_ACTUATOR_STATE) { + if (dev_state->type != GOLD_ACTUATOR_DEVICE && + dev_state->type != PLATINUM_ACTUATOR_DEVICE) { continue; } diff --git a/src/manager.h b/src/manager.h index 09e85c5..149e44e 100644 --- a/src/manager.h +++ b/src/manager.h @@ -172,7 +172,7 @@ class Manager /** @brief names of actuator devices */ - void GetDeviceNamesByType(std::vector&, fastcat::DeviceStateType); + void GetDeviceNamesByType(std::vector&, fastcat::DeviceType); private: bool ConfigJSDBusFromYaml(YAML::Node node); diff --git a/test/test_cli.cc b/test/test_cli.cc index 325d4db..906c1eb 100644 --- a/test/test_cli.cc +++ b/test/test_cli.cc @@ -18,7 +18,7 @@ void print_header(std::vector states) fprintf(file, "rel_time_sec, "); for (auto state = states.begin(); state != states.end(); ++state) { switch (state->type) { - case fastcat::EGD_STATE: + case fastcat::EGD_DEVICE: fprintf(file, "%s_actual_position, ", state->name.c_str()); fprintf(file, "%s_actual_velocity, ", state->name.c_str()); @@ -31,37 +31,37 @@ void print_header(std::vector states) fprintf(file, "%s_target_reached, ", state->name.c_str()); break; - case fastcat::SIGNAL_GENERATOR_STATE: + case fastcat::SIGNAL_GENERATOR_DEVICE: fprintf(file, "%s_output, ", state->name.c_str()); break; - case fastcat::COMMANDER_STATE: + case fastcat::COMMANDER_DEVICE: fprintf(file, "%s_enable, ", state->name.c_str()); break; - case fastcat::FUNCTION_STATE: + case fastcat::FUNCTION_DEVICE: fprintf(file, "%s_output, ", state->name.c_str()); break; - case fastcat::CONDITIONAL_STATE: + case fastcat::CONDITIONAL_DEVICE: fprintf(file, "%s_output, ", state->name.c_str()); break; - case fastcat::EL3602_STATE: + case fastcat::EL3602_DEVICE: fprintf(file, "%s_voltage_ch1, ", state->name.c_str()); fprintf(file, "%s_voltage_ch2, ", state->name.c_str()); fprintf(file, "%s_adc_value_ch1, ", state->name.c_str()); fprintf(file, "%s_adc_value_ch2, ", state->name.c_str()); break; - case fastcat::SCHMITT_TRIGGER_STATE: + case fastcat::SCHMITT_TRIGGER_DEVICE: fprintf(file, "%s_output, ", state->name.c_str()); break; - case fastcat::EL2124_STATE: + case fastcat::EL2124_DEVICE: fprintf(file, "%s_level_ch1, ", state->name.c_str()); fprintf(file, "%s_level_ch2, ", state->name.c_str()); fprintf(file, "%s_level_ch3, ", state->name.c_str()); fprintf(file, "%s_level_ch4, ", state->name.c_str()); break; - case fastcat::FILTER_STATE: + case fastcat::FILTER_DEVICE: fprintf(file, "%s_output, ", state->name.c_str()); break; - case fastcat::FTS_STATE: + case fastcat::FTS_DEVICE: fprintf(file, "%s_raw_fx, ", state->name.c_str()); fprintf(file, "%s_raw_fy, ", state->name.c_str()); fprintf(file, "%s_raw_fz, ", state->name.c_str()); @@ -75,33 +75,7 @@ void print_header(std::vector states) fprintf(file, "%s_tared_ty, ", state->name.c_str()); fprintf(file, "%s_tared_tz, ", state->name.c_str()); break; - case fastcat::JED0101_STATE: - fprintf(file, "%s_status, ", state->name.c_str()); - fprintf(file, "%s_w_raw, ", state->name.c_str()); - fprintf(file, "%s_x_raw, ", state->name.c_str()); - fprintf(file, "%s_y_raw, ", state->name.c_str()); - fprintf(file, "%s_z_raw, ", state->name.c_str()); - fprintf(file, "%s_w, ", state->name.c_str()); - fprintf(file, "%s_x, ", state->name.c_str()); - fprintf(file, "%s_y, ", state->name.c_str()); - fprintf(file, "%s_z, ", state->name.c_str()); - fprintf(file, "%s_cmd, ", state->name.c_str()); - break; - case fastcat::JED0200_STATE: - fprintf(file, "%s_status, ", state->name.c_str()); - fprintf(file, "%s_ticks, ", state->name.c_str()); - fprintf(file, "%s_voltage_hv, ", state->name.c_str()); - fprintf(file, "%s_voltage_lv, ", state->name.c_str()); - fprintf(file, "%s_voltage_12v, ", state->name.c_str()); - fprintf(file, "%s_temp_ambient, ", state->name.c_str()); - fprintf(file, "%s_temp_actuator, ", state->name.c_str()); - fprintf(file, "%s_humidity, ", state->name.c_str()); - fprintf(file, "%s_pressure, ", state->name.c_str()); - fprintf(file, "%s_brake_current, ", state->name.c_str()); - fprintf(file, "%s_brake_cc_val, ", state->name.c_str()); - fprintf(file, "%s_cmd, ", state->name.c_str()); - break; - case fastcat::EL3208_STATE: + case fastcat::EL3208_DEVICE: fprintf(file, "%s_output_ch1, ", state->name.c_str()); fprintf(file, "%s_output_ch2, ", state->name.c_str()); fprintf(file, "%s_output_ch3, ", state->name.c_str()); @@ -111,12 +85,12 @@ void print_header(std::vector states) fprintf(file, "%s_output_ch7, ", state->name.c_str()); fprintf(file, "%s_output_ch8, ", state->name.c_str()); break; - case fastcat::FAULTER_STATE: + case fastcat::FAULTER_DEVICE: fprintf(file, "%s_enable, ", state->name.c_str()); fprintf(file, "%s_fault_active, ", state->name.c_str()); break; - case fastcat::GOLD_ACTUATOR_STATE: - case fastcat::PLATINUM_ACTUATOR_STATE: + case fastcat::GOLD_ACTUATOR_DEVICE: + case fastcat::PLATINUM_ACTUATOR_DEVICE: fprintf(file, "%s_actual_position, ", state->name.c_str()); fprintf(file, "%s_actual_velocity, ", state->name.c_str()); fprintf(file, "%s_actual_current, ", state->name.c_str()); @@ -132,7 +106,7 @@ void print_header(std::vector states) fprintf(file, "%s_motor_on, ", state->name.c_str()); fprintf(file, "%s_servo_enabled, ", state->name.c_str()); break; - case fastcat::LINEAR_INTERPOLATION_STATE: + case fastcat::LINEAR_INTERPOLATION_DEVICE: fprintf(file, "%s_output, ", state->name.c_str()); fprintf(file, "%s_is_saturated, ", state->name.c_str()); @@ -150,7 +124,7 @@ void print_csv_data(std::vector states) fprintf(file, "%lf, ", time); for (auto state = states.begin(); state != states.end(); ++state) { switch (state->type) { - case fastcat::EGD_STATE: + case fastcat::EGD_DEVICE: fprintf(file, "%i, ", state->egd_state.actual_position); fprintf(file, "%i, ", state->egd_state.actual_velocity); @@ -162,37 +136,37 @@ void print_csv_data(std::vector states) fprintf(file, "%u, ", state->egd_state.target_reached); break; - case fastcat::SIGNAL_GENERATOR_STATE: + case fastcat::SIGNAL_GENERATOR_DEVICE: fprintf(file, "%lf, ", state->signal_generator_state.output); break; - case fastcat::COMMANDER_STATE: + case fastcat::COMMANDER_DEVICE: fprintf(file, "%u, ", state->commander_state.enable); break; - case fastcat::FUNCTION_STATE: + case fastcat::FUNCTION_DEVICE: fprintf(file, "%lf, ", state->function_state.output); break; - case fastcat::CONDITIONAL_STATE: + case fastcat::CONDITIONAL_DEVICE: fprintf(file, "%u, ", state->conditional_state.output); break; - case fastcat::EL3602_STATE: + case fastcat::EL3602_DEVICE: fprintf(file, "%lf, ", state->el3602_state.voltage_ch1); fprintf(file, "%lf, ", state->el3602_state.voltage_ch2); fprintf(file, "%i, ", state->el3602_state.adc_value_ch1); fprintf(file, "%i, ", state->el3602_state.adc_value_ch2); break; - case fastcat::SCHMITT_TRIGGER_STATE: + case fastcat::SCHMITT_TRIGGER_DEVICE: fprintf(file, "%u, ", state->schmitt_trigger_state.output); break; - case fastcat::EL2124_STATE: + case fastcat::EL2124_DEVICE: fprintf(file, "%u, ", state->el2124_state.level_ch1); fprintf(file, "%u, ", state->el2124_state.level_ch2); fprintf(file, "%u, ", state->el2124_state.level_ch3); fprintf(file, "%u, ", state->el2124_state.level_ch4); break; - case fastcat::FILTER_STATE: + case fastcat::FILTER_DEVICE: fprintf(file, "%lf, ", state->filter_state.output); break; - case fastcat::FTS_STATE: + case fastcat::FTS_DEVICE: fprintf(file, "%lf, ", state->fts_state.raw_fx); fprintf(file, "%lf, ", state->fts_state.raw_fy); fprintf(file, "%lf, ", state->fts_state.raw_fz); @@ -206,33 +180,7 @@ void print_csv_data(std::vector states) fprintf(file, "%lf, ", state->fts_state.tared_ty); fprintf(file, "%lf, ", state->fts_state.tared_tz); break; - case fastcat::JED0101_STATE: - fprintf(file, "%u, ", state->jed0101_state.status); - fprintf(file, "%u, ", state->jed0101_state.w_raw); - fprintf(file, "%u, ", state->jed0101_state.x_raw); - fprintf(file, "%u, ", state->jed0101_state.y_raw); - fprintf(file, "%u, ", state->jed0101_state.z_raw); - fprintf(file, "%lf, ", state->jed0101_state.w); - fprintf(file, "%lf, ", state->jed0101_state.x); - fprintf(file, "%lf, ", state->jed0101_state.y); - fprintf(file, "%lf, ", state->jed0101_state.z); - fprintf(file, "%u, ", state->jed0101_state.cmd); - break; - case fastcat::JED0200_STATE: - fprintf(file, "%u, ", state->jed0200_state.status); - fprintf(file, "%u, ", state->jed0200_state.ticks); - fprintf(file, "%f, ", state->jed0200_state.voltage_hv); - fprintf(file, "%f, ", state->jed0200_state.voltage_lv); - fprintf(file, "%f, ", state->jed0200_state.voltage_12v); - fprintf(file, "%f, ", state->jed0200_state.temp_ambient); - fprintf(file, "%f, ", state->jed0200_state.temp_actuator); - fprintf(file, "%f, ", state->jed0200_state.humidity); - fprintf(file, "%f, ", state->jed0200_state.pressure); - fprintf(file, "%u, ", state->jed0200_state.brake_current); - fprintf(file, "%u, ", state->jed0200_state.brake_cc_val); - fprintf(file, "%u, ", state->jed0200_state.cmd); - break; - case fastcat::EL3208_STATE: + case fastcat::EL3208_DEVICE: fprintf(file, "%lf, ", state->el3208_state.output_ch1); fprintf(file, "%lf, ", state->el3208_state.output_ch2); fprintf(file, "%lf, ", state->el3208_state.output_ch3); @@ -242,11 +190,11 @@ void print_csv_data(std::vector states) fprintf(file, "%lf, ", state->el3208_state.output_ch7); fprintf(file, "%lf, ", state->el3208_state.output_ch8); break; - case fastcat::FAULTER_STATE: + case fastcat::FAULTER_DEVICE: fprintf(file, "%u, ", state->faulter_state.enable); fprintf(file, "%u, ", state->faulter_state.fault_active); break; - case fastcat::GOLD_ACTUATOR_STATE: + case fastcat::GOLD_ACTUATOR_DEVICE: fprintf(file, "%lf, ", state->gold_actuator_state.actual_position); fprintf(file, "%lf, ", state->gold_actuator_state.actual_velocity); fprintf(file, "%lf, ", state->gold_actuator_state.actual_current); @@ -263,7 +211,7 @@ void print_csv_data(std::vector states) fprintf(file, "%u, ", state->gold_actuator_state.motor_on); fprintf(file, "%u, ", state->gold_actuator_state.servo_enabled); break; - case fastcat::PLATINUM_ACTUATOR_STATE: + case fastcat::PLATINUM_ACTUATOR_DEVICE: fprintf(file, "%lf, ", state->platinum_actuator_state.actual_position); fprintf(file, "%lf, ", state->platinum_actuator_state.actual_velocity); fprintf(file, "%lf, ", state->platinum_actuator_state.actual_current); @@ -280,7 +228,7 @@ void print_csv_data(std::vector states) fprintf(file, "%u, ", state->platinum_actuator_state.motor_on); fprintf(file, "%u, ", state->platinum_actuator_state.servo_enabled); break; - case fastcat::LINEAR_INTERPOLATION_STATE: + case fastcat::LINEAR_INTERPOLATION_DEVICE: fprintf(file, "%lf, ", state->linear_interpolation_state.output); fprintf(file, "%u, ", state->linear_interpolation_state.is_saturated); break; @@ -392,20 +340,6 @@ void* cli_process(void*) cmd.el2124_write_channel_cmd.level = atoi(tokens[3].c_str()); cmd.type = fastcat::EL2124_WRITE_CHANNEL_CMD; - } else if (tokens[0].compare("jed0101_set_cmd_value") == 0 && - tokens.size() == 3) { - MSG("Issuing jed0101_set_cmd_value command"); - cmd.name = tokens[1]; - cmd.jed0101_set_cmd_value_cmd.cmd = atoi(tokens[2].c_str()); - cmd.type = fastcat::JED0101_SET_CMD_VALUE_CMD; - - } else if (tokens[0].compare("jed0200_set_cmd_value") == 0 && - tokens.size() == 3) { - MSG("Issuing jed0200_set_cmd_value command"); - cmd.name = tokens[1]; - cmd.jed0200_set_cmd_value_cmd.cmd = atoi(tokens[2].c_str()); - cmd.type = fastcat::JED0200_SET_CMD_VALUE_CMD; - } else if (tokens[0].compare("actuator_set_output_position") == 0 && tokens.size() == 3) { MSG("Issuing actuator_set_output_position command"); diff --git a/test/test_unit/test_conditional.cc b/test/test_unit/test_conditional.cc index 97adfc8..e0ce816 100644 --- a/test/test_unit/test_conditional.cc +++ b/test/test_unit/test_conditional.cc @@ -80,7 +80,7 @@ TEST_F(ConditionalTest, ReadResponse) // Read() returns true when signal updates successfully fastcat::DeviceState sgs; - sgs.type = fastcat::SIGNAL_GENERATOR_STATE; + sgs.type = fastcat::SIGNAL_GENERATOR_DEVICE; sgs.signal_generator_state.output = 10.0; fastcat::ConfigSignalByteIndexing(&sgs, c2_.signals_[0]); diff --git a/test/test_unit/test_fts.cc b/test/test_unit/test_fts.cc index b8cf0c6..c11d3b2 100644 --- a/test/test_unit/test_fts.cc +++ b/test/test_unit/test_fts.cc @@ -56,7 +56,7 @@ TEST_F(FtsTest, WideMatrixValid) for (int i=0; i<(int)device_.signals_.size(); i++) { auto &sgs = device_states[i]; - sgs.type = fastcat::SIGNAL_GENERATOR_STATE; + sgs.type = fastcat::SIGNAL_GENERATOR_DEVICE; sgs.signal_generator_state.output = 0.0; fastcat::ConfigSignalByteIndexing(&sgs, device_.signals_[i]); } @@ -70,4 +70,4 @@ TEST_F(FtsTest, WideMatrixValid) device_.Read(); EXPECT_EQ( 35.0, device_.GetState()->fts_state.raw_tz); -} \ No newline at end of file +} diff --git a/test/test_unit/test_function.cc b/test/test_unit/test_function.cc index f104359..bd3871b 100644 --- a/test/test_unit/test_function.cc +++ b/test/test_unit/test_function.cc @@ -89,7 +89,7 @@ TEST_F(FunctionTest, ReadResponse) // Read() returns true when signal updates successfully for POLYNOMIAL // Functions fastcat::DeviceState sgs; - sgs.type = fastcat::SIGNAL_GENERATOR_STATE; + sgs.type = fastcat::SIGNAL_GENERATOR_DEVICE; sgs.signal_generator_state.output = 10.0; fastcat::ConfigSignalByteIndexing(&sgs, f2_.signals_[0]); diff --git a/test/test_unit/test_schmitt_trigger.cc b/test/test_unit/test_schmitt_trigger.cc index 5aadc44..37d0092 100644 --- a/test/test_unit/test_schmitt_trigger.cc +++ b/test/test_unit/test_schmitt_trigger.cc @@ -73,7 +73,7 @@ TEST_F(SchmittTriggerTest, ReadResponse) // Read() returns true when signal updates successfully fastcat::DeviceState sgs; - sgs.type = fastcat::SIGNAL_GENERATOR_STATE; + sgs.type = fastcat::SIGNAL_GENERATOR_DEVICE; sgs.signal_generator_state.output = 10.0; fastcat::ConfigSignalByteIndexing(&sgs, st2_.signals_[0]);