#include "generic.h" #include "generic_conf.h" #include "tmfe.h" #include struct channelInfo { bool isInput; bool isOutput; std::string type; std::string input; std::string output; }; generic::generic(std::string equipmentName, const char *equipmentFilename) : TMFeEquipment(equipmentName.c_str(), equipmentFilename) { this->equipmentName = equipmentName; fEqConfPeriodMilliSec = 100; fEqConfLogHistory = 60; fEqConfReadOnlyWhenRunning = false; fEqConfWriteEventsToOdb = true; } void generic::HandlePeriodic() { std::vector channel_names; std::vector is_input_channels; std::vector is_output_channels; std::vector channel_types; std::vector inputs; std::vector outputs; { std::string varname = DEVICE_DIR_NAME + std::string("/") + CHANNEL_NAMES_VARNAME; fOdbEqSettings->RSA(varname.c_str(), &channel_names, true); } { std::string varname = DEVICE_DIR_NAME + std::string("/") + IS_INPUT_CHANNELS_VARNAME; fOdbEqSettings->RBA(varname.c_str(), &is_input_channels, true); } { std::string varname = DEVICE_DIR_NAME + std::string("/") + IS_OUTPUT_CHANNELS_VARNAME; fOdbEqSettings->RBA(varname.c_str(), &is_output_channels, true); } { std::string varname = DEVICE_DIR_NAME + std::string("/") + CHANNEL_TYPES_VARNAME; fOdbEqSettings->RSA(varname.c_str(), &channel_types, true); } { std::string varname = INPUT_VARNAME; fOdbEqVariables->RSA(varname.c_str(), &inputs, true); } { std::string varname = OUTPUT_VARNAME; fOdbEqVariables->RSA(varname.c_str(), &outputs, true); } std::map cache; int size = (int)this->channel_names.size(); size = 1; // for (int i = 0; i < size; i++) { // std::string name = this->channel_names.at(i); // bool isInput = this->is_input_channels.at(i); // bool isOutput = this->is_output_channels.at(i); // std::string type = this->channels_type.at(i); // std::string input = this->inputs.at(i); // std::string output = this->outputs.at(i); // cache.insert({name, {isInput, isOutput, type, input, output}}); // } // this->channel_names = channel_names; // this->is_input_channels = is_input_channels; // this->is_output_channels = is_output_channels; // this->channels_type = channel_types; // this->inputs = inputs; // this->outputs = outputs; /** * Create epics channels */ for (int i = 0; i < 1; i++) { this->epics_channels.resize(channel_names.size()); // std::string type = channels_type.at(i); std::string type = "string"; std::string channel_name = channel_names.at(i); if (type == "string") { printf("create string channel called %s\n", channel_name.c_str()); this->epics_channels.at(i) = std::make_unique>( std::string_view(channel_name.c_str())); } } /** * If channels is output / input => read and write data if value change */ for (int i = 0; i < 1; i++) { if (this->is_input_channels.at(i)) { std::string value; std::get>>( this->epics_channels.at(i)) ->get(&value); printf("value readed %s\n", value.c_str()); } if (is_input_channels.at(i)) { std::string value = outputs.at(i); std::get>>( this->epics_channels.at(i)) ->put(&value); printf("value %s written\n", value.c_str()); } } }