Files
ecmc_plugin_safety/src/ecmcSafetyGroup.h
2024-01-29 16:23:58 +01:00

85 lines
2.8 KiB
C++

/*************************************************************************\
* Copyright (c) 2023 Paul Scherrer Institute
* ecmc is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*
* ecmcSafetyPlg.h
*
* Created on: jan 29, 2024
* Author: anderssandstrom
*
\*************************************************************************/
#ifndef ECMC_SAFETY_GROUP_PLG_H_
#define ECMC_SAFETY_GROUP_PLG_H_
#include <stdexcept>
#include "ecmcDataItem.h"
#include "ecmcAsynPortDriver.h"
#include "ecmcSafetyPlgDefs.h"
#include <string>
#include "ecmcAxisBase.h"
#include <vector>
class ecmcSafetyGroup : public asynPortDriver {
public:
/** ecmc Safty Plg class
* This object can throw:
* - bad_alloc
* - out_of_range
*/
ecmcSafetyGroup(const char *name,
const char *ec_rampdown_cmd,
const char *ec_standstill_status,
int time_delay_ms,
char* portName);
~ecmcSafetyGroup();
// Call just before realtime because then all data sources should be available
void connectToDataSource();
void addAxis(int axisId);
void execute();
virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
std::string getName();
private:
//void parseConfigStr(char *configStr);
void initAsyn();
double ecmcSampleRateHz_;
int dataSourcesLinked_; // To avoid link several times
int objectId_; // Unique object id
int cycleCounter_;
// Config options
int cfgDbgMode_; // Config: allow dbg printouts
// Asyn
int asynStatusId_;
//
int status_;
int axesCounter_;
std::vector<ecmcAxisBase*> axes_;
std::string name_;
std::string ecRampDownCmdName_;
std::string ecAxesStandStillStat_;
int delayMs_;
// Some generic utility functions
static uint8_t getUint8(uint8_t* data);
static int8_t getInt8(uint8_t* data);
static uint16_t getUint16(uint8_t* data);
static int16_t getInt16(uint8_t* data);
static uint32_t getUint32(uint8_t* data);
static int32_t getInt32(uint8_t* data);
static uint64_t getUint64(uint8_t* data);
static int64_t getInt64(uint8_t* data);
static float getFloat32(uint8_t* data);
static double getFloat64(uint8_t* data);
static size_t getEcDataTypeByteSize(ecmcEcDataType dt);
static std::string to_string(int value);
};
#endif /* ECMC_SAFETY_GROUP_PLG_H_ */