Skip to content

Ticket 5544: Monitor board temperatures #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bin/
lib/
include/
/include
/lib
db/
O.*/
dbd/
Expand Down
1 change: 1 addition & 0 deletions CAENHVAsynApp/Db/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ DB += stringin.template
DB += stringout.template
DB += longin.template
DB += longout.template
DB += mbbi.template

#----------------------------------------------------
# If <anyname>.db template is not named <anyname>*.template add
Expand Down
1 change: 0 additions & 1 deletion CAENHVAsynApp/Db/ai.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ record(ai, "$(P)$(R)") {
field(LOPR, "$(LOPR)")
field(HOPR, "$(HOPR)")
field(INP, "@asyn($(PORT))$(PARAM)")
info(autosaveFields, "VAL")
}
1 change: 0 additions & 1 deletion CAENHVAsynApp/Db/ao.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ record(ao, "$(P)$(R)") {
field(DRVL, "$(DRVL)")
field(DRVH, "$(DRVH)")
field(OUT, "@asyn($(PORT))$(PARAM)")
info(autosaveFields, "VAL")
}
1 change: 0 additions & 1 deletion CAENHVAsynApp/Db/bi.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ record(bi, "$(P)$(R)") {
field(INP, "@asynMask($(PORT),0,$(MASK))$(PARAM)")
field(ZNAM, "$(ZNAM)")
field(ONAM, "$(ONAM)")
info(autosaveFields, "VAL")
}
1 change: 0 additions & 1 deletion CAENHVAsynApp/Db/bo.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ record(bo, "$(P)$(R)") {
field(OUT, "@asynMask($(PORT),0,$(MASK))$(PARAM)")
field(ZNAM, "$(ZNAM)")
field(ONAM, "$(ONAM)")
info(autosaveFields, "VAL")
}
1 change: 0 additions & 1 deletion CAENHVAsynApp/Db/longin.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ record(longin, "$(P)$(R)") {
field(PINI, "YES")
field(SCAN, "$(SCAN)")
field(INP, "@asyn($(PORT))$(PARAM)")
info(autosaveFields, "VAL")
}
1 change: 0 additions & 1 deletion CAENHVAsynApp/Db/longout.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ record(longout, "$(P)$(R)") {
field(PINI, "YES")
field(SCAN, "Passive")
field(OUT, "@asyn($(PORT))$(PARAM)")
info(autosaveFields, "VAL")
}
23 changes: 23 additions & 0 deletions CAENHVAsynApp/Db/mbbi.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
record(mbbi, "$(P)$(R)") {
field(DTYP, "asynUInt32Digital")
field(DESC, "$(DESC)")
field(PINI, "YES")
field(SCAN, "$(SCAN)")
field(INP, "@asynMask($(PORT),0,256)$(PARAM)")
field( ZRVL, "$(0VL=)") field( ZRST, "$(0ST=)") field( ZRSV, "$(0SV=)")
field( ONVL, "$(1VL=)") field( ONST, "$(1ST=)") field( ONSV, "$(1SV=)")
field( TWVL, "$(2VL=)") field( TWST, "$(2ST=)") field( ZRSV, "$(2SV=)")
field( THVL, "$(3VL=)") field( THST, "$(3ST=)") field( TWSV, "$(3SV=)")
field( FRVL, "$(4VL=)") field( FRST, "$(4ST=)") field( FRSV, "$(4SV=)")
field( FVVL, "$(5VL=)") field( FVST, "$(5ST=)") field( FVSV, "$(5SV=)")
field( SXVL, "$(6VL=)") field( SXST, "$(6ST=)") field( SXSV, "$(6SV=)")
field( SVVL, "$(7VL=)") field( SVST, "$(7ST=)") field( SVSV, "$(7SV=)")
field( EIVL, "$(8VL=)") field( EIST, "$(8ST=)") field( EISV, "$(8SV=)")
field( NIVL, "$(9VL=)") field( NIST, "$(9ST=)") field( NISV, "$(9SV=)")
field( TEVL, "$(10VL=)") field( TEST, "$(10ST=)") field( TESV, "$(10SV=)")
field( ELVL, "$(11VL=)") field( ELST, "$(11ST=)") field( ELSV, "$(11SV=)")
field( TVVL, "$(12VL=)") field( TVST, "$(12ST=)") field( TVSV, "$(12SV=)")
field( TTVL, "$(13VL=)") field( TTST, "$(13ST=)") field( TTSV, "$(13SV=)")
field( FTVL, "$(14VL=)") field( FTST, "$(14ST=)") field( FTSV, "$(14SV=)")
field( FFVL, "$(15VL=)") field( FFST, "$(15ST=)") field( FFSV, "$(15SV=)")
}
8 changes: 7 additions & 1 deletion CAENHVAsynApp/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ LIB_LIBS += asyn
#=====================================================
# Path to "NON EPICS" External PACKAGES: USER INCLUDES
#======================================================

USR_INCLUDES = $(addprefix -I,$(CAENHVWRAPPER_INCLUDE))
caenhvwrapper_DIR = $(CAENHVWRAPPER_LIB)
USR_LIBS_Linux += caenhvwrapper
#======================================================

LIB_LIBS_WIN32 += caenhvwrapper
BIN_INSTALLS_WIN32 += $(wildcard $(CAENHVWRAPPER_DLL)/*.dll)
LIB_INSTALLS_WIN32 += $(wildcard $(CAENHVWRAPPER_LIB)/*.lib)
LIB_SYS_LIBS_WIN32 += ws2_32
LIB_LIBS_WIN32 += $(EPICS_BASE_IOC_LIBS)

#===========================

Expand Down
21 changes: 16 additions & 5 deletions CAENHVAsynApp/src/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@

#include "board.h"

IBoard::IBoard(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw)
IBoard::IBoard(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw, bool readOnly)
:
handle(h),
slot(s),
model(m),
description(d),
numChannels(n),
serialNumber(sn),
firmwareRelease(fw)
firmwareRelease(fw),
readOnly(readOnly)
{
GetBoardParams();
GetBoardChannels();
Expand All @@ -39,9 +40,9 @@ IBoard::~IBoard()
{
}

Board IBoard::create(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw)
Board IBoard::create(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw, bool readOnly)
{
return std::make_shared<IBoard>(h, s, m, d, n, sn, fw);
return std::make_shared<IBoard>(h, s, m, d, n, sn, fw, readOnly);
}

void IBoard::printInfo(std::ostream& stream) const
Expand Down Expand Up @@ -116,6 +117,13 @@ void IBoard::GetBoardParams()
if (CAENHV_GetBdParamProp(handle, slot, p[i], "Mode", &mode) != CAENHV_OK )
throw std::runtime_error("CAENHV_GetBdParamProp failed: " + std::string(CAENHV_GetError(handle)));

if (readOnly) {
if (mode == PARAM_MODE_RDWR) {
mode = PARAM_MODE_RDONLY;
} else if (mode == PARAM_MODE_WRONLY) {
break;
}
}

if (type == PARAM_TYPE_NUMERIC)
boardParameterNumerics.push_back( IBoardParameterNumeric::create(handle, slot, p[i], mode));
Expand All @@ -130,12 +138,15 @@ void IBoard::GetBoardParams()
std::cerr << "Error found when creating a Board Parameter object for pamater '" << p[i] << "'. Unsupported type = " << type << std::endl;
}

// Memory allocated across CRTs can cause issues on Windows
#ifndef _WIN32
// Deallocate memory (Use RAII in the future for this)
free(ParNameList);
#endif
}

void IBoard::GetBoardChannels()
{
for (std::size_t i(0); i < numChannels; ++i)
channels.push_back( IChannel::create(handle, slot, i) );
channels.push_back( IChannel::create(handle, slot, i, readOnly) );
}
11 changes: 9 additions & 2 deletions CAENHVAsynApp/src/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
#include <vector>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif

#include <iostream>

#include "CAENHVWrapper.h"
Expand All @@ -49,11 +55,11 @@ typedef std::shared_ptr<IBoard> Board;
class IBoard
{
public:
IBoard(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw);
IBoard(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw, bool readOnly);
~IBoard();

// Factory method
static Board create(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw);
static Board create(int h, std::size_t s, std::string m, std::string d, std::size_t n, std::string sn, std::string fw, bool readOnly);

void printInfo(std::ostream& stream) const;
void printBoardInfo(std::ostream& stream) const;
Expand All @@ -76,6 +82,7 @@ class IBoard
std::size_t numChannels;
std::string serialNumber;
std::string firmwareRelease;
bool readOnly;

std::vector<BoardParameterNumeric> boardParameterNumerics;
std::vector<BoardParameterOnOff> boardParameterOnOffs;
Expand Down
6 changes: 6 additions & 0 deletions CAENHVAsynApp/src/board_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
#include <algorithm>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif

#include <iostream>

#include "CAENHVWrapper.h"
Expand Down
28 changes: 24 additions & 4 deletions CAENHVAsynApp/src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@

#include "channel.h"

IChannel::IChannel(int h, std::size_t s, std::size_t c)
IChannel::IChannel(int h, std::size_t s, std::size_t c, bool readOnly)
:
handle(h),
slot(s),
channel(c)
channel(c),
readOnly(readOnly)
{
GetChannelParams();
}

Channel IChannel::create(int h, std::size_t s, std::size_t c)
Channel IChannel::create(int h, std::size_t s, std::size_t c, bool readOnly)
{
return std::make_shared<IChannel>(h, s, c);
return std::make_shared<IChannel>(h, s, c, readOnly);
}

void IChannel::printInfo(std::ostream& stream) const
{
stream << " Slot = " << slot \
<< ", Channel = " << channel \
<< std::endl;

stream << " Number of String parameters: " << channelParameterStrings.size() << std::endl;
for (std::vector<ChannelParameterString>::const_iterator it = channelParameterStrings.begin(); it != channelParameterStrings.end(); ++it)
(*it)->printInfo(stream);

stream << " Number of Numeric parameters: " << channelParameterNumerics.size() << std::endl;
for (std::vector<ChannelParameterNumeric>::const_iterator it = channelParameterNumerics.begin(); it != channelParameterNumerics.end(); ++it)
Expand Down Expand Up @@ -76,6 +81,9 @@ void IChannel::GetChannelParams()
if ( r != CAENHV_OK )
return;

// Get the channel name
channelParameterStrings.push_back( IChannelName::create(handle, slot, channel, "NAME", PARAM_MODE_RDWR) );

// Check if we the number of parameter is > 0
if (ParNumber <= 0)
return;
Expand All @@ -99,6 +107,15 @@ void IChannel::GetChannelParams()
if (CAENHV_GetChParamProp(handle, slot, channel, p[i], "Mode", &mode) != CAENHV_OK )
throw std::runtime_error("CAENHV_GetChParamProp failed: " + std::string(CAENHV_GetError(handle)));

if (readOnly) {
if (mode == PARAM_MODE_RDWR) {
mode = PARAM_MODE_RDONLY;
}
else if (mode == PARAM_MODE_WRONLY) {
break;
}
}

if (type == PARAM_TYPE_NUMERIC)
channelParameterNumerics.push_back( IChannelParameterNumeric::create(handle, slot, channel, p[i], mode) );
else if (type == PARAM_TYPE_ONOFF)
Expand All @@ -112,6 +129,9 @@ void IChannel::GetChannelParams()
std::cerr << "Error found when creating a Board Parameter object for pamater '" << p[i] << "'. Unsupported type = " << type << std::endl;
}

// Memory allocated across CRTs can cause issues on Windows
#ifndef _WIN32
// Deallocate memory (Use RAII in the future for this)
free(ParNameList);
#endif
}
13 changes: 11 additions & 2 deletions CAENHVAsynApp/src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
#include <vector>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif

#include <iostream>

#include "CAENHVWrapper.h"
Expand All @@ -49,14 +55,15 @@ typedef std::shared_ptr<IChannel> Channel;
class IChannel
{
public:
IChannel(int h, std::size_t s, std::size_t c);
IChannel(int h, std::size_t s, std::size_t c, bool readOnly);
~IChannel() {};

// Factory method
static Channel create(int h, std::size_t s, std::size_t c);
static Channel create(int h, std::size_t s, std::size_t c, bool readOnly);

void printInfo(std::ostream& stream) const;

std::vector<ChannelParameterString> getChannelParameterStrings() { return channelParameterStrings; };
std::vector<ChannelParameterNumeric> getChannelParameterNumerics() { return channelParameterNumerics; };
std::vector<ChannelParameterOnOff> getChannelParameterOnOffs() { return channelParameterOnOffs; };
std::vector<ChannelParameterChStatus> getChannelParameterChStatuses() { return channelParameterChStatuses; };
Expand All @@ -69,7 +76,9 @@ class IChannel
int handle;
std::size_t slot;
std::size_t channel;
bool readOnly;

std::vector<ChannelParameterString> channelParameterStrings;
std::vector<ChannelParameterNumeric> channelParameterNumerics;
std::vector<ChannelParameterOnOff> channelParameterOnOffs;
std::vector<ChannelParameterChStatus> channelParameterChStatuses;
Expand Down
49 changes: 47 additions & 2 deletions CAENHVAsynApp/src/channel_parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ IChannelParameterOnOff::IChannelParameterOnOff(int h, std::size_t s, std::size_t
char temp[30];

if ( CAENHV_GetChParamProp(handle, slot, channel, param.c_str(), "Onstate", temp ) != CAENHV_OK )
throw std::runtime_error("CAENHV_GetBdParamProp failed: " + std::string(CAENHV_GetError(handle)));
throw std::runtime_error("CAENHV_GetChParamProp failed: " + std::string(CAENHV_GetError(handle)));

onState = temp;

if ( CAENHV_GetChParamProp(handle, slot, channel, param.c_str(), "Offstate", temp ) != CAENHV_OK )
throw std::runtime_error("CAENHV_GetBdParamProp failed: " + std::string(CAENHV_GetError(handle)));
throw std::runtime_error("CAENHV_GetChParamProp failed: " + std::string(CAENHV_GetError(handle)));

offState = temp;

Expand Down Expand Up @@ -222,3 +222,48 @@ void IChannelParameterBinary::printInfo(std::ostream& stream) const
<< ", epicsRecordName = " << epicsRecordName \
<< std::endl;
}

// Class for String parameters
IChannelParameterString::IChannelParameterString(int h, std::size_t s, std::size_t c, const std::string& p, uint32_t m)
:
ChannelParameterBase<std::string>(h, s, c, p, m)
{
}

ChannelParameterString IChannelParameterString::create(int h, std::size_t s, std::size_t c, const std::string& p, uint32_t m)
{
return std::make_shared<IChannelParameterString>(h, s, c, p, m);
}

// Class for Channel Name
IChannelName::IChannelName(int h, std::size_t s, std::size_t c, const std::string& p, uint32_t m)
:
IChannelParameterString(h, s, c, p, m)
{
}

ChannelName IChannelName::create(int h, std::size_t s, std::size_t c, const std::string& p, uint32_t m)
{
return std::make_shared<IChannelName>(h, s, c, p, m);
}

std::string IChannelName::getVal() const
{
char name_char[MAX_CH_NAME];

uint16_t tempChan = channel;
if (CAENHV_GetChName(handle, slot, 1, &tempChan, &name_char) != CAENHV_OK)
throw std::runtime_error("CAENHV_GetChName failed: " + std::string(CAENHV_GetError(handle)));

return std::string(name_char);
}

void IChannelName::setVal(std::string name) const
{
if (mode == PARAM_MODE_RDONLY)
return;

uint16_t tempChan = channel;
if (CAENHV_SetChName(handle, slot, 1, &tempChan, name.c_str()) != CAENHV_OK)
throw std::runtime_error("CAENHV_SetChName failed: " + std::string(CAENHV_GetError(handle)));
}
Loading