Skip to content
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
11 changes: 11 additions & 0 deletions isisdaeApp/Db/isisdae.db
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ record(ai, "$(P)$(Q)TOTALUAMPS")
info(archive, "-5.0 VAL")
}

record(ai, "$(P)$(Q)TOTALUAMPS_PD")
{
field(DESC, "DAE Raw Period Microamps")
field(DTYP, "asynFloat64")
field(INP, "@asyn(icp,0,0)TOTALUAMPSPD")
field(PREC, "3")
field(SCAN, "I/O Intr")
field(EGU, "uA hour")
info(archive, "-5.0 VAL")
}

record(ai, "$(P)$(Q)MEVENTS")
{
field(DESC, "DAE millions of events")
Expand Down
50 changes: 50 additions & 0 deletions isisdaeApp/src/NORDPV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,55 @@ bool NORDPV<T>::getNewValue(smartGDDPointer& pDD)
return true;
}

template <typename T>
NORDSPECPV<T>::NORDSPECPV ( exServer & cas, pvInfo &setup, bool preCreateFlag, bool scanOnIn, T& nord, int spec, bool is_edges) : NORDPV<T>(cas, setup, preCreateFlag, scanOnIn, nord), m_is_edges(is_edges), m_spec(spec)
{

}

template <typename T>
bool NORDSPECPV<T>::getNewValue(smartGDDPointer& pDD)
{
try {
setNORD(cas.iface()->getSpectrumSize(m_spec) + (m_is_edges ? 1 : 0));
}
catch(const std::exception& ex) {
std::cerr << "CAS: Exception in NORDSPECPV::getNewValue(): " << ex.what() << std::endl;
return false;
}
catch(...) {
std::cerr << "CAS: Exception in NORDSPECPV::getNewValue()" << std::endl;
return false;
}
return NORDPV<T>::getNewValue(pDD);
}

template <typename T>
NORDMONPV<T>::NORDMONPV ( exServer & cas, pvInfo &setup, bool preCreateFlag, bool scanOnIn, T& nord, int mon, bool is_edges) : NORDPV<T>(cas, setup, preCreateFlag, scanOnIn, nord), m_is_edges(is_edges), m_mon(mon)
{

}

template <typename T>
bool NORDMONPV<T>::getNewValue(smartGDDPointer& pDD)
{
try {
int spec = cas.iface()->getSpectrumNumberForMonitor(m_mon);
setNORD(cas.iface()->getSpectrumSize(spec) + (m_is_edges ? 1 : 0));
}
catch(const std::exception& ex) {
std::cerr << "CAS: Exception in NORDMONPV::getNewValue(): " << ex.what() << std::endl;
return false;
}
catch(...) {
std::cerr << "CAS: Exception in NORDMONPV::getNewValue()" << std::endl;
return false;
}
return NORDPV<T>::getNewValue(pDD);
}

template class NORDPV<int>;
template class NORDPV<float>;

template class NORDSPECPV<int>;
template class NORDMONPV<int>;
15 changes: 11 additions & 4 deletions isisdaeApp/src/SpectrumPV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ bool SpectrumPV::getNewValue(smartGDDPointer& pDD)
return false;
}
int n = 0;
bool as_histogram = (m_axis == "XE" ? true : false); // is X bin boundaries
bool as_distribution = (m_axis == "YC" ? false : true); // is Y a distribution
try {
if (m_axis == "YC")
{
n = cas.iface()->getSpectrum(m_spec, m_period, pX, pY, nmax, false);
n = cas.iface()->getSpectrum(m_spec, m_period, pX, pY, nmax, as_histogram, as_distribution);
}
else
{
n = cas.iface()->getSpectrum(m_spec, m_period, pX, pY, nmax, true);
n = cas.iface()->getSpectrum(m_spec, m_period, pX, pY, nmax, as_histogram, as_distribution);
}
}
catch(const std::exception& ex) {
Expand All @@ -55,9 +57,9 @@ bool SpectrumPV::getNewValue(smartGDDPointer& pDD)
delete[] pY;
return false;
}
m_nord = n; // number of elements used
if (m_axis == "Y" || m_axis == "YC")
{
m_nord = n; // number of elements used
delete[] pX;
if ( this->pValue.valid() )
{
Expand Down Expand Up @@ -87,8 +89,12 @@ bool SpectrumPV::getNewValue(smartGDDPointer& pDD)
m_maxval = *(minmax.second);
return true;
}
else if (m_axis == "X")
else if (m_axis == "X" || m_axis == "XE")
{
if (as_histogram && n < nmax) {
++n; // we have bin boundaries
}
m_nord = n; // number of elements used
delete[] pY;
// check to see if value has actually changed since last time
if ( this->pValue.valid() )
Expand Down Expand Up @@ -121,6 +127,7 @@ bool SpectrumPV::getNewValue(smartGDDPointer& pDD)
}
else
{
m_nord = 0; // number of elements used
delete[] pX;
delete[] pY;
return false;
Expand Down
4 changes: 4 additions & 0 deletions isisdaeApp/src/dae.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace ISISICPINT
ISISICPINT_DllExport extern int(startSEWait)(std::string& messages);
ISISICPINT_DllExport extern int(endSEWait)(std::string& messages);
ISISICPINT_DllExport extern int(getSpectrum)(long spectrum_number, long period, std::vector<double>& time_channels, std::vector<double>& signal, bool as_histogram, bool as_distribution, long& sum, std::string& messages);
ISISICPINT_DllExport extern long(getSpectrumSize)(long spectrum_number, std::string& messages);
ISISICPINT_DllExport extern int(changeTCB)(const std::string& tcb_xml, std::string& messages);
ISISICPINT_DllExport extern int(changeDAEsettings)(const std::string& dae_xml, std::string& messages);
ISISICPINT_DllExport extern int(getSpectrumIntegral)(long spectrum_number, long period, float time_low, float time_high, long& counts, std::string& messages);
Expand All @@ -33,6 +34,7 @@ namespace ISISICPINT
ISISICPINT_DllExport extern long(getRawFramesTotal)(std::string& messages); // retval
ISISICPINT_DllExport extern long(getGoodFramesTotal)(std::string& messages); // retval
ISISICPINT_DllExport extern double(getGoodUAmpH)(std::string& messages); // retval
ISISICPINT_DllExport extern double(getRawUAmpH)(std::string& messages); // retval
ISISICPINT_DllExport extern int(getSpectraSum)(long period, long first_spec, long num_spec, long spec_type, double time_low, double time_high, std::vector<long>& sums, std::vector<long>& max_vals, std::vector<long>& spec_nums, std::string& messages);
ISISICPINT_DllExport extern int(changeSample)(const std::string& sample_xml, std::string& messages);
ISISICPINT_DllExport extern int(changeUser)(const std::string& user_xml, std::string& messages);
Expand Down Expand Up @@ -86,6 +88,8 @@ namespace ISISICPINT
ISISICPINT_DllExport extern int(getStatusMessages)(long stream, std::list<std::string>& messages);
ISISICPINT_DllExport extern long(getGoodFramesPeriod)(std::string& messages); // retval
ISISICPINT_DllExport extern double(getGoodUAmpHPeriod)(std::string& messages); // retval
ISISICPINT_DllExport extern long(getRawFramesPeriod)(std::string& messages); // retval
ISISICPINT_DllExport extern double(getRawUAmpHPeriod)(std::string& messages); // retval
ISISICPINT_DllExport extern int(getFramesAllPeriods)(std::vector<long>& good_frames, std::vector<long>& raw_frames, std::string& messages);
ISISICPINT_DllExport extern int(getUAmpHAllPeriods)(std::vector<float>& good_uamph, std::vector<float>& raw_uamph, std::string& messages);
ISISICPINT_DllExport extern double(getMEventsPeriod)(long period, std::string& messages); // retval
Expand Down
21 changes: 21 additions & 0 deletions isisdaeApp/src/dae_isisicpint_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ double ISISICPINT::getGoodUAmpH(std::string& messages)
return 0;
}

double ISISICPINT::getRawUAmpH(std::string& messages)
{
return 0;
}

int ISISICPINT::getSpectraSum(long period, long first_spec, long num_spec, long spec_type, double time_low, double time_high, std::vector<long>& sums, std::vector<long>& max_vals, std::vector<long>& spec_nums, std::string& messages)
{
return 0;
Expand Down Expand Up @@ -387,6 +392,16 @@ double ISISICPINT::getGoodUAmpHPeriod(std::string& messages)
return 0.0;
}

long ISISICPINT::getRawFramesPeriod(std::string& messages)
{
return 0;
}

double ISISICPINT::getRawUAmpHPeriod(std::string& messages)
{
return 0.0;
}

int ISISICPINT::getFramesAllPeriods(std::vector<long>& good_frames, std::vector<long>& raw_frames, std::string& messages)
{
return 0;
Expand All @@ -402,6 +417,12 @@ int ISISICPINT::updateCRPTSpectra(LONG period, LONG spec_start, LONG nspec, std:
return 0;
}

long ISISICPINT::getSpectrumSize(long spectrum_number, std::string& messages)
{
return 0;
}


int ISISICPINT::getCRPTSpectraIntegral(const std::vector<long>& spectrum_numbers, long period, const std::vector<float>& time_low, const std::vector<float>& time_high, std::vector<long>& counts, std::string& messages)
{
return 0;
Expand Down
14 changes: 9 additions & 5 deletions isisdaeApp/src/exServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,11 @@ void exServer::createAxisPVs(bool is_monitor, int id, int period, const char* ax
}

sprintf(buffer, "%s:%d:%d:%s.NORD", prefix, period, id, axis);
bool is_edges = (strcmp(axis, "XE") == 0);
pPVI = new pvInfo (0.5, buffer, static_cast<float>(m_ntc), 1.0f, "", aitEnumInt32, 1);
m_pvList[buffer] = pPVI;
exPV* pPV = new NORDPV<int>(*this, *pPVI, true, scanOn, pSPV->getNORD());
exPV* pPV = (is_monitor ? static_cast<NORDPV<int>*>(new NORDMONPV<int>(*this, *pPVI, true, scanOn, pSPV->getNORD(), id, is_edges)) :
static_cast<NORDPV<int>*>(new NORDSPECPV<int>(*this, *pPVI, true, scanOn, pSPV->getNORD(), id, is_edges)));
pPVI->setPV(pPV);
sprintf(pvAlias, "%s%s", m_pvPrefix.c_str(), buffer);
this->installAliasName(*pPVI, pvAlias);
Expand Down Expand Up @@ -520,6 +522,7 @@ bool exServer::createSpecPVs(const std::string& pvStr)
}

createAxisPVs(false, spec, period, "X", m_tof_units);
createAxisPVs(false, spec, period, "XE", m_tof_units);
createAxisPVs(false, spec, period, "Y", std::string("cnt /") + m_tof_units); // currently MAX_UNIT_SIZE = 8 for CTRL_DOUBLE calls
createAxisPVs(false, spec, period, "YC", "cnt");
createCountsPV(false, spec, period);
Expand All @@ -543,6 +546,7 @@ bool exServer::createMonitorPVs(const std::string& pvStr)
}

createAxisPVs(true, mon, period, "X", m_tof_units);
createAxisPVs(true, mon, period, "XE", m_tof_units);
createAxisPVs(true, mon, period, "Y", std::string("cnt /") + m_tof_units); // currently MAX_UNIT_SIZE = 8 for CTRL_DOUBLE calls
createAxisPVs(true, mon, period, "YC", "cnt");
createCountsPV(true, mon, period);
Expand Down Expand Up @@ -570,8 +574,8 @@ bool exServer::createMonitorPVs(const std::string& pvStr)
bool parseSpecPV(const std::string& pvStr, int& spec, int& period, std::string& axis, std::string& field)
{
//Assumes period then spectrum
pcrecpp::RE spec_per_re("SPEC:(\\d+):(\\d+):(X|YC|Y|C)([.].*)?");
pcrecpp::RE spec_re("SPEC:(\\d+):(X|YC|Y|C)([.].*)?");
pcrecpp::RE spec_per_re("SPEC:(\\d+):(\\d+):(XE|X|YC|Y|C)([.].*)?");
pcrecpp::RE spec_re("SPEC:(\\d+):(XE|X|YC|Y|C)([.].*)?");

if (!spec_per_re.FullMatch(pvStr, &period, &spec, &axis, &field))
{
Expand All @@ -588,8 +592,8 @@ bool parseSpecPV(const std::string& pvStr, int& spec, int& period, std::string&
bool parseMonitorPV(const std::string& pvStr, int& mon, int& period, std::string& axis, std::string& field)
{
//Assumes period then monitor
pcrecpp::RE monitor_per_re("MON:(\\d+):(\\d+):(X|YC|Y|C|S)([.].*)?");
pcrecpp::RE monitor_re("MON:(\\d+):(X|YC|Y|C|S)([.].*)?");
pcrecpp::RE monitor_per_re("MON:(\\d+):(\\d+):(XE|X|YC|Y|C|S)([.].*)?");
pcrecpp::RE monitor_re("MON:(\\d+):(XE|X|YC|Y|C|S)([.].*)?");
if (!monitor_per_re.FullMatch(pvStr, &period, &mon, &axis, &field))
{
if (!monitor_re.FullMatch(pvStr, &mon, &axis, &field))
Expand Down
30 changes: 30 additions & 0 deletions isisdaeApp/src/exServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,42 @@ class NORDPV : public exScalarPV {
NORDPV ( exServer & cas, pvInfo &setup,
bool preCreateFlag, bool scanOnIn, T& nord );
virtual bool getNewValue(smartGDDPointer& pDD);
protected:
void setNORD(const T& nord) { m_nord = nord; }
private:
T& m_nord;
NORDPV & operator = ( const NORDPV & );
NORDPV ( const NORDPV & );
};

template <typename T>
class NORDSPECPV : public NORDPV<T>
{
public:
NORDSPECPV ( exServer & cas, pvInfo &setup,
bool preCreateFlag, bool scanOnIn, T& nord, int spec, bool is_edges );
virtual bool getNewValue(smartGDDPointer& pDD);
private:
bool m_is_edges;
int m_spec;
NORDSPECPV & operator = ( const NORDSPECPV & );
NORDSPECPV ( const NORDSPECPV & );
};

template <typename T>
class NORDMONPV : public NORDPV<T>
{
public:
NORDMONPV ( exServer & cas, pvInfo &setup,
bool preCreateFlag, bool scanOnIn, T& nord, int mon, bool is_edges );
virtual bool getNewValue(smartGDDPointer& pDD);
private:
bool m_is_edges;
int m_mon;
NORDMONPV & operator = ( const NORDMONPV & );
NORDMONPV ( const NORDMONPV & );
};

class CountsPV : public exScalarPV {
public:
CountsPV ( exServer & cas, pvInfo &setup,
Expand Down
25 changes: 16 additions & 9 deletions isisdaeApp/src/isisdaeDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ isisdaeDriver::isisdaeDriver(isisdaeInterface* iface, const char *portName, int

createParam(P_BeamCurrentString, asynParamFloat64, &P_BeamCurrent);
createParam(P_TotalUAmpsString, asynParamFloat64, &P_TotalUAmps);
createParam(P_TotalUAmpsPeriodString, asynParamFloat64, &P_TotalUAmpsPeriod);
createParam(P_MonitorFromString, asynParamFloat64, &P_MonitorFrom);
createParam(P_MonitorToString, asynParamFloat64, &P_MonitorTo);
createParam(P_MEventsString, asynParamFloat64, &P_MEvents);
Expand Down Expand Up @@ -1409,22 +1410,26 @@ void isisdaeDriver::updateRunStatus()
{
m_RunStatus = rs;
}
long frames = m_iface->getGoodFrames();
unsigned long tc = m_iface->getTotalCounts();
epicsTime tc_ts(epicsTime::getCurrent());
double uah = m_iface->getGoodUAH();
// long p_frames = m_iface->getGoodFramesPeriod(); // this currently only works in period card mode
// double p_uah = m_iface->getGoodUAHPeriod();
long frames = m_iface->getGoodFrames();
long p_frames = m_iface->getGoodFramesPeriod();
long r_frames = m_iface->getRawFrames();
double r_uah = 0.0;
long p_r_frames = m_iface->getRawFramesPeriod();
double uah = m_iface->getGoodUAH();
double p_uah = m_iface->getGoodUAHPeriod();
double r_uah = m_iface->getRawUAH();
double p_r_uah = m_iface->getRawUAHPeriod();
if (no_check_frame_uamp == NULL || *no_check_frame_uamp == '\0')
{
check_frame_uamp("good", frames, uah, fu_state);
check_frame_uamp("raw", r_frames, r_uah, r_fu_state);
// check_frame_uamp("period good", p_frames, p_uah, p_fu_state);
check_frame_uamp("period good", p_frames, p_uah, p_fu_state);
}
setDoubleParam(P_GoodUAH, uah);
// setDoubleParam(P_GoodUAHPeriod, p_uah);
setDoubleParam(P_GoodUAHPeriod, p_uah);
setDoubleParam(P_TotalUAmps, r_uah);
setDoubleParam(P_TotalUAmpsPeriod, p_r_uah);
setIntegerParam(P_TotalCounts, tc);
setDoubleParam(P_MEvents, static_cast<double>(tc) / 1.0e6);
double tdiff = static_cast<double>(tc_ts - old_tc_ts);
Expand All @@ -1445,10 +1450,11 @@ void isisdaeDriver::updateRunStatus()
old_frames = frames;
}
setIntegerParam(P_GoodFramesTotal, frames);
// setIntegerParam(P_GoodFramesPeriod, p_frames);
setIntegerParam(P_GoodFramesPeriod, p_frames);
setIntegerParam(P_RawFramesPeriod, p_r_frames);
setIntegerParam(P_RawFramesTotal, r_frames);
setIntegerParam(P_RunStatus, m_RunStatus);
///@todo need to update P_RawFramesPeriod, P_RunDurationTotal, P_TotalUAmps, P_RunDurationPeriod, P_MonitorCounts
///@todo need to update P_RunDurationTotal, P_RunDurationPeriod, P_MonitorCounts
}

// zero counters st start of run, done early before actual readbacks
Expand All @@ -1457,6 +1463,7 @@ void isisdaeDriver::zeroRunCounters(bool do_callbacks)
setDoubleParam(P_GoodUAH, 0.0);
setDoubleParam(P_GoodUAHPeriod, 0.0);
setDoubleParam(P_TotalUAmps, 0.0);
setDoubleParam(P_TotalUAmpsPeriod, 0.0);
setIntegerParam(P_TotalCounts, 0);
setIntegerParam(P_GoodFramesTotal, 0);
setIntegerParam(P_GoodFramesPeriod, 0);
Expand Down
2 changes: 2 additions & 0 deletions isisdaeApp/src/isisdaeDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class isisdaeDriver : public ADDriver
int P_PeriodSequence; // long
int P_BeamCurrent; // double
int P_TotalUAmps; // double
int P_TotalUAmpsPeriod; // double
int P_MonitorFrom; // double
int P_MonitorTo; // double
int P_MEvents; // double
Expand Down Expand Up @@ -265,6 +266,7 @@ class isisdaeDriver : public ADDriver
#define P_PeriodSequenceString "PERIODSEQ"
#define P_BeamCurrentString "BEAMCURRENT"
#define P_TotalUAmpsString "TOTALUAMPS"
#define P_TotalUAmpsPeriodString "TOTALUAMPSPD"
#define P_MonitorFromString "MONITORFROM"
#define P_MonitorToString "MONITORTO"
#define P_MEventsString "MEVENTS"
Expand Down
Loading