From 1e02ce73479efb9b8411327f7a31e7246014cf23 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 8 Oct 2024 11:35:51 -0700 Subject: [PATCH 1/6] add table to PLogic header; remove unused fn SetShutterChannel --- DeviceAdapters/ASITiger/ASIPLogic.h | 33 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/DeviceAdapters/ASITiger/ASIPLogic.h b/DeviceAdapters/ASITiger/ASIPLogic.h index 6a9a18507..f2a3776a5 100644 --- a/DeviceAdapters/ASITiger/ASIPLogic.h +++ b/DeviceAdapters/ASITiger/ASIPLogic.h @@ -22,8 +22,8 @@ // BASED ON: ASIStage.h and others // -#ifndef _ASIPLOGIC_H_ -#define _ASIPLOGIC_H_ +#ifndef ASIPLOGIC_H +#define ASIPLOGIC_H #include "ASIPeripheralBase.h" #include "MMDevice.h" @@ -36,7 +36,6 @@ class CPLogic : public ASIPeripheralBase ~CPLogic() { } // Device API - // ---------- int Initialize(); bool Busy() { return false; } @@ -46,7 +45,6 @@ class CPLogic : public ASIPeripheralBase int Fire(double /*deltaT*/) { return DEVICE_UNSUPPORTED_COMMAND; } // action interface - // ---------------- int OnPLogicMode (MM::PropertyBase* pProp, MM::ActionType eAct); int OnSetShutterChannel (MM::PropertyBase* pProp, MM::ActionType eAct); int OnPLogicOutputState (MM::PropertyBase* pProp, MM::ActionType eAct); @@ -78,24 +76,35 @@ class CPLogic : public ASIPeripheralBase private: - string axisLetter_; + std::string axisLetter_; unsigned int numCells_; unsigned int currentPosition_; // cached value of current position -// static const int NUM_CELLS = 16; - bool useAsdiSPIMShutter_; // used together with either useAs4ChShutter_ or useAs7ChShutter_, takes into account address 41 backplane (TTL0 for CameraA) + + // PLogic Mode Table + // -------------------- + // diSPIM | 4ch | 7ch | (useAsdiSPIMShutter_, useAs4ChShutter_, useAs7ChShutter_) + // -------------------- + // 0 | 0 | 0 | "None" + // 1 | 1 | 0 | "diSPIM Shutter" + // 0 | 1 | 0 | "Four-channel shutter" + // 0 | 0 | 1 | "Seven-channel shutter" + // 1 | 0 | 1 | "Seven-channel TTL shutter" + bool useAsdiSPIMShutter_; bool useAs4ChShutter_; bool useAs7ChShutter_; + // used together with either useAs4ChShutter_ or useAs7ChShutter_, + // takes into account address 41 backplane (TTL0 for CameraA) + bool shutterOpen_; - bool advancedPropsEnabled_; bool editCellUpdates_; + bool advancedPropsEnabled_; // flag to only create advanced properties once - int SetShutterChannel(); int SetPositionDirectly(unsigned int position); - int GetCellPropertyName(long index, string suffix, char* name); - int GetIOPropertyName(long index, string suffix, char* name); + int GetCellPropertyName(long index, std::string suffix, char* name); + int GetIOPropertyName(long index, std::string suffix, char* name); int RefreshAdvancedCellPropertyValues(long index); int RefreshCurrentPosition(); int RefreshEditCellPropertyValues(); }; -#endif //_ASIPLOGIC_H_ +#endif // ASIPLOGIC_H From 286efb49095239b44f51a1809da6fe1ccd223fa9 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 8 Oct 2024 12:32:22 -0700 Subject: [PATCH 2/6] remove using namespace std from PLogic --- DeviceAdapters/ASITiger/ASIPLogic.cpp | 85 +++++++++++++-------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/DeviceAdapters/ASITiger/ASIPLogic.cpp b/DeviceAdapters/ASITiger/ASIPLogic.cpp index 7342575bb..adbc096a2 100644 --- a/DeviceAdapters/ASITiger/ASIPLogic.cpp +++ b/DeviceAdapters/ASITiger/ASIPLogic.cpp @@ -48,11 +48,7 @@ #define PLOGIC_PHYSICAL_IO_END_ADDRESS PLOGIC_BACKPLANE_END_ADDRESS #define PLOGIC_PHYSICAL_IO_NUM (PLOGIC_PHYSICAL_IO_END_ADDRESS - PLOGIC_PHYSICAL_IO_START_ADDRESS + 1) -using namespace std; - -/////////////////////////////////////////////////////////////////////////////// -// CPLogic -// +// ASI Tiger Programmable Logic Card CPLogic::CPLogic(const char* name) : ASIPeripheralBase< ::CShutterBase, CPLogic >(name), axisLetter_(g_EmptyAxisLetterStr), // value determined by extended name @@ -92,7 +88,7 @@ int CPLogic::Initialize() RETURN_ON_MM_ERROR( PeripheralInitialize() ); // create MM description; this doesn't work during hardware configuration wizard but will work afterwards - ostringstream command; + std::ostringstream command; command.str(""); command << g_PLogicDeviceDescription << " HexAddr=" << addressString_; CreateProperty(MM::g_Keyword_Description, command.str().c_str(), MM::String, true); @@ -103,7 +99,7 @@ int CPLogic::Initialize() char buildName[MM::MaxStrLength]; unsigned int tmp; GetProperty(g_FirmwareBuildPropertyName, buildName); - string s = buildName; + std::string s = buildName; hub_->SetLastSerialAnswer(s); int ret = hub_->ParseAnswerAfterUnderscore(tmp); if (!ret) { @@ -429,7 +425,7 @@ int CPLogic::SetOpen(bool open) { if (useAs4ChShutter_ || useAs7ChShutter_) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); shutterOpen_ = open; // sets cell 8 which is "software shutter open" indicator via preset 11 (sets high) or preset 10 (sets low) if (open) { @@ -450,12 +446,13 @@ int CPLogic::GetOpen(bool& open) //////////////// // action handlers +// Modify the "PLogic Mode Table" in the header if you change this function. int CPLogic::OnPLogicMode(MM::PropertyBase* pProp, MM::ActionType eAct) { if (eAct == MM::BeforeGet) { // do nothing for now } else if (eAct == MM::AfterSet) { - string tmpstr; + std::string tmpstr; pProp->Get(tmpstr); if (tmpstr.compare(g_PLogicModediSPIMShutter) == 0) { @@ -504,9 +501,9 @@ int CPLogic::OnSetShutterChannel(MM::PropertyBase* pProp, MM::ActionType eAct) } } } else if (eAct == MM::AfterSet) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; - string tmpstr; + std::string tmpstr; RETURN_ON_MM_ERROR ( GetCurrentPropertyData(pProp->GetName().c_str(), tmp) ); if (tmp < 0) return DEVICE_OK; // no preset and other "signaling" preset codes are negative command << addressChar_ << "CCA X=" << tmp; @@ -521,7 +518,7 @@ int CPLogic::OnSetShutterChannel(MM::PropertyBase* pProp, MM::ActionType eAct) int CPLogic::OnPLogicOutputState(MM::PropertyBase* pProp, MM::ActionType eAct) { unsigned int val; - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if (eAct == MM::BeforeGet || eAct == MM::AfterSet) { // always read @@ -537,7 +534,7 @@ int CPLogic::OnPLogicOutputState(MM::PropertyBase* pProp, MM::ActionType eAct) int CPLogic::OnPLogicOutputStateUpper(MM::PropertyBase* pProp, MM::ActionType eAct) { unsigned int val; - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if (eAct == MM::BeforeGet || eAct == MM::AfterSet) { // always read @@ -553,7 +550,7 @@ int CPLogic::OnPLogicOutputStateUpper(MM::PropertyBase* pProp, MM::ActionType eA int CPLogic::OnFrontpanelOutputState(MM::PropertyBase* pProp, MM::ActionType eAct) { unsigned int val; - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if (eAct == MM::BeforeGet || eAct == MM::AfterSet) { // always read @@ -569,7 +566,7 @@ int CPLogic::OnFrontpanelOutputState(MM::PropertyBase* pProp, MM::ActionType eAc int CPLogic::OnBackplaneOutputState(MM::PropertyBase* pProp, MM::ActionType eAct) { unsigned int val; - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if (eAct == MM::BeforeGet || eAct == MM::AfterSet) { // always read @@ -584,9 +581,9 @@ int CPLogic::OnBackplaneOutputState(MM::PropertyBase* pProp, MM::ActionType eAct int CPLogic::OnTriggerSource(MM::PropertyBase* pProp, MM::ActionType eAct) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; - string tmpstr; + std::string tmpstr; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) return DEVICE_OK; @@ -615,7 +612,7 @@ int CPLogic::OnTriggerSource(MM::PropertyBase* pProp, MM::ActionType eAct) int CPLogic::OnPointerPosition(MM::PropertyBase* pProp, MM::ActionType eAct) { static bool justSet = false; - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_ && !justSet) @@ -640,8 +637,8 @@ int CPLogic::OnPointerPosition(MM::PropertyBase* pProp, MM::ActionType eAct) int CPLogic::OnSaveCardSettings(MM::PropertyBase* pProp, MM::ActionType eAct) { - string tmpstr; - ostringstream command; command.str(""); + std::string tmpstr; + std::ostringstream command; command.str(""); if (eAct == MM::AfterSet) { command << addressChar_ << "SS "; pProp->Get(tmpstr); @@ -663,7 +660,7 @@ int CPLogic::OnSaveCardSettings(MM::PropertyBase* pProp, MM::ActionType eAct) int CPLogic::OnRefreshProperties(MM::PropertyBase* pProp, MM::ActionType eAct) { - string tmpstr; + std::string tmpstr; if (eAct == MM::AfterSet) { pProp->Get(tmpstr); if (tmpstr.compare(g_YesState) == 0) @@ -710,7 +707,7 @@ int CPLogic::RefreshEditCellPropertyValues() int CPLogic::OnEditCellType(MM::PropertyBase* pProp, MM::ActionType eAct) { // NB: works for I/O addresses but will have incorrect strings - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if(currentPosition_ <= numCells_ // normal cells || (currentPosition_ >= PLOGIC_FRONTPANEL_START_ADDRESS && currentPosition_ <= PLOGIC_BACKPLANE_END_ADDRESS)) { // or I/O addresses if (eAct == MM::BeforeGet) { @@ -778,7 +775,7 @@ int CPLogic::OnEditCellInput4(MM::PropertyBase* pProp, MM::ActionType eAct) int CPLogic::OnEditCellUpdates(MM::PropertyBase* pProp, MM::ActionType eAct) { - string tmpstr; + std::string tmpstr; if (eAct == MM::AfterSet) { pProp->Get(tmpstr); if (tmpstr.compare(g_YesState) == 0) @@ -789,17 +786,17 @@ int CPLogic::OnEditCellUpdates(MM::PropertyBase* pProp, MM::ActionType eAct) return DEVICE_OK; } -int CPLogic::GetCellPropertyName(long index, string suffix, char* name) +int CPLogic::GetCellPropertyName(long index, std::string suffix, char* name) { - ostringstream os; + std::ostringstream os; os << "PCell_" << setw(2) << setfill('0') << index << suffix; CDeviceUtils::CopyLimitedString(name, os.str().c_str()); return DEVICE_OK; } -int CPLogic::GetIOPropertyName(long index, string suffix, char* name) +int CPLogic::GetIOPropertyName(long index, std::string suffix, char* name) { - ostringstream os; + std::ostringstream os; if (index < PLOGIC_BACKPLANE_START_ADDRESS) { // front panel os << "IOFrontpanel_" << index - PLOGIC_FRONTPANEL_START_ADDRESS + 1; } else { // backplane @@ -817,7 +814,7 @@ int CPLogic::OnAdvancedProperties(MM::PropertyBase* pProp, MM::ActionType eAct) return DEVICE_OK; // do nothing } else if (eAct == MM::AfterSet) { - string tmpstr; + std::string tmpstr; pProp->Get(tmpstr); if ((tmpstr.compare(g_YesState) == 0) && !advancedPropsEnabled_) // after creating advanced properties once no need to repeat { @@ -835,7 +832,6 @@ int CPLogic::OnAdvancedProperties(MM::PropertyBase* pProp, MM::ActionType eAct) SetProperty(g_RefreshPropValsPropertyName, g_YesState); for (long i=1; i<=(long)numCells_; i++) { - // logic cell type GetCellPropertyName(i, "_CellType", propName); pActEx = new CPropertyActionEx (this, &CPLogic::OnCellType, i); @@ -887,7 +883,6 @@ int CPLogic::OnAdvancedProperties(MM::PropertyBase* pProp, MM::ActionType eAct) pActEx = new CPropertyActionEx (this, &CPLogic::OnInput4, i); CreateProperty(propName, "0", MM::Integer, false, pActEx); UpdateProperty(propName); - } for (long i=PLOGIC_FRONTPANEL_START_ADDRESS; i<=PLOGIC_BACKPLANE_END_ADDRESS; i++) { @@ -945,7 +940,7 @@ int CPLogic::RefreshAdvancedCellPropertyValues(long index) // don't bother updating things like if the user changes position from the property int CPLogic::SetPositionDirectly(unsigned int position) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if (position == currentPosition_) return DEVICE_OK; command << "M " << axisLetter_ << "=" << position; @@ -956,7 +951,7 @@ int CPLogic::SetPositionDirectly(unsigned int position) int CPLogic::RefreshCurrentPosition() { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); unsigned int tmp; command << "W " << axisLetter_; RETURN_ON_MM_ERROR ( hub_->QueryCommandVerify(command.str(),":A") ); @@ -967,9 +962,9 @@ int CPLogic::RefreshCurrentPosition() int CPLogic::OnCellType(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; - string tmpstr; + std::string tmpstr; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) return DEVICE_OK; @@ -1021,7 +1016,7 @@ int CPLogic::OnCellType(MM::PropertyBase* pProp, MM::ActionType eAct, long index int CPLogic::OnCellConfig(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) @@ -1043,7 +1038,7 @@ int CPLogic::OnCellConfig(MM::PropertyBase* pProp, MM::ActionType eAct, long ind int CPLogic::OnInput1(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) @@ -1065,7 +1060,7 @@ int CPLogic::OnInput1(MM::PropertyBase* pProp, MM::ActionType eAct, long index) int CPLogic::OnInput2(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) @@ -1087,7 +1082,7 @@ int CPLogic::OnInput2(MM::PropertyBase* pProp, MM::ActionType eAct, long index) int CPLogic::OnInput3(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) @@ -1109,7 +1104,7 @@ int CPLogic::OnInput3(MM::PropertyBase* pProp, MM::ActionType eAct, long index) int CPLogic::OnInput4(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) @@ -1131,7 +1126,7 @@ int CPLogic::OnInput4(MM::PropertyBase* pProp, MM::ActionType eAct, long index) int CPLogic::OnIOType(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) @@ -1162,7 +1157,7 @@ int CPLogic::OnIOType(MM::PropertyBase* pProp, MM::ActionType eAct, long index) int CPLogic::OnIOSourceAddress(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; if (eAct == MM::BeforeGet) { if (!refreshProps_ && initialized_) @@ -1184,12 +1179,12 @@ int CPLogic::OnIOSourceAddress(MM::PropertyBase* pProp, MM::ActionType eAct, lon int CPLogic::OnClearAllCellStates(MM::PropertyBase* pProp, MM::ActionType eAct) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); if (eAct == MM::BeforeGet) { pProp->Set(g_IdleState); } else if (eAct == MM::AfterSet) { - string tmpstr; + std::string tmpstr; pProp->Get(tmpstr); if (tmpstr.compare(g_DoItState) == 0) { @@ -1203,9 +1198,9 @@ int CPLogic::OnClearAllCellStates(MM::PropertyBase* pProp, MM::ActionType eAct) int CPLogic::OnSetCardPreset(MM::PropertyBase* pProp, MM::ActionType eAct) { - ostringstream command; command.str(""); + std::ostringstream command; command.str(""); long tmp; - string tmpstr; + std::string tmpstr; if (eAct == MM::BeforeGet) { // can't do anything of real value here if (!initialized_) From a21b26f73afb12652b0923440b19a79facebdd14 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 8 Oct 2024 13:02:34 -0700 Subject: [PATCH 3/6] use const std::string& in GetCellPropertyName and GetIOPropertyName --- DeviceAdapters/ASITiger/ASIPLogic.cpp | 6 +++--- DeviceAdapters/ASITiger/ASIPLogic.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DeviceAdapters/ASITiger/ASIPLogic.cpp b/DeviceAdapters/ASITiger/ASIPLogic.cpp index adbc096a2..a5a3d90b9 100644 --- a/DeviceAdapters/ASITiger/ASIPLogic.cpp +++ b/DeviceAdapters/ASITiger/ASIPLogic.cpp @@ -786,15 +786,15 @@ int CPLogic::OnEditCellUpdates(MM::PropertyBase* pProp, MM::ActionType eAct) return DEVICE_OK; } -int CPLogic::GetCellPropertyName(long index, std::string suffix, char* name) +int CPLogic::GetCellPropertyName(long index, const std::string& suffix, char* name) { std::ostringstream os; - os << "PCell_" << setw(2) << setfill('0') << index << suffix; + os << "PCell_" << std::setw(2) << std::setfill('0') << index << suffix; CDeviceUtils::CopyLimitedString(name, os.str().c_str()); return DEVICE_OK; } -int CPLogic::GetIOPropertyName(long index, std::string suffix, char* name) +int CPLogic::GetIOPropertyName(long index, const std::string& suffix, char* name) { std::ostringstream os; if (index < PLOGIC_BACKPLANE_START_ADDRESS) { // front panel diff --git a/DeviceAdapters/ASITiger/ASIPLogic.h b/DeviceAdapters/ASITiger/ASIPLogic.h index f2a3776a5..e3dd0bec6 100644 --- a/DeviceAdapters/ASITiger/ASIPLogic.h +++ b/DeviceAdapters/ASITiger/ASIPLogic.h @@ -100,8 +100,8 @@ class CPLogic : public ASIPeripheralBase bool advancedPropsEnabled_; // flag to only create advanced properties once int SetPositionDirectly(unsigned int position); - int GetCellPropertyName(long index, std::string suffix, char* name); - int GetIOPropertyName(long index, std::string suffix, char* name); + int GetCellPropertyName(long index, const std::string& suffix, char* name); + int GetIOPropertyName(long index, const std::string& suffix, char* name); int RefreshAdvancedCellPropertyValues(long index); int RefreshCurrentPosition(); int RefreshEditCellPropertyValues(); From d9ed3fc218f8906a3023cd17eca698ebe9b456fd Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 8 Oct 2024 13:08:27 -0700 Subject: [PATCH 4/6] use false for bool; add break to default cases --- DeviceAdapters/ASITiger/ASIPLogic.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/DeviceAdapters/ASITiger/ASIPLogic.cpp b/DeviceAdapters/ASITiger/ASIPLogic.cpp index a5a3d90b9..b1d7b15bd 100644 --- a/DeviceAdapters/ASITiger/ASIPLogic.cpp +++ b/DeviceAdapters/ASITiger/ASIPLogic.cpp @@ -590,14 +590,14 @@ int CPLogic::OnTriggerSource(MM::PropertyBase* pProp, MM::ActionType eAct) command << "PM " << axisLetter_ << "?"; RETURN_ON_MM_ERROR ( hub_->QueryCommandVerify(command.str(), axisLetter_) ); RETURN_ON_MM_ERROR ( hub_->ParseAnswerAfterEquals(tmp) ); - bool success = 0; + bool success = false; switch (tmp) { case 0: success = pProp->Set(g_TriggerSourceCode0); break; case 1: success = pProp->Set(g_TriggerSourceCode1); break; case 2: success = pProp->Set(g_TriggerSourceCode2); break; case 3: success = pProp->Set(g_TriggerSourceCode3); break; case 4: success = pProp->Set(g_TriggerSourceCode4); break; - default: success=0; + default: break; } if (!success) return DEVICE_INVALID_PROPERTY_VALUE; @@ -972,12 +972,13 @@ int CPLogic::OnCellType(MM::PropertyBase* pProp, MM::ActionType eAct, long index command << addressChar_ << "CCA Y?"; RETURN_ON_MM_ERROR ( hub_->QueryCommandVerify(command.str(),":A") ); RETURN_ON_MM_ERROR ( hub_->ParseAnswerAfterEquals(tmp) ); - bool success = 0; + bool success = false; if (currentPosition_ > numCells_) { switch (tmp) { case 0: success = pProp->Set(g_IOTypeCode0); break; case 1: success = pProp->Set(g_IOTypeCode1); break; case 2: success = pProp->Set(g_IOTypeCode2); break; + default: break; } } else { switch (tmp) { @@ -997,7 +998,7 @@ int CPLogic::OnCellType(MM::PropertyBase* pProp, MM::ActionType eAct, long index case 13:success = pProp->Set(g_CellTypeCode13); break; case 14:success = pProp->Set(g_CellTypeCode14); break; case 15:success = pProp->Set(g_CellTypeCode15); break; - default: success=0; + default: break; } } if (!success) @@ -1135,12 +1136,12 @@ int CPLogic::OnIOType(MM::PropertyBase* pProp, MM::ActionType eAct, long index) command << addressChar_ << "CCA Y?"; RETURN_ON_MM_ERROR ( hub_->QueryCommandVerify(command.str(),":A") ); RETURN_ON_MM_ERROR ( hub_->ParseAnswerAfterEquals(tmp) ); - bool success = 0; + bool success = false; switch (tmp) { case 0: success = pProp->Set(g_IOTypeCode0); break; case 1: success = pProp->Set(g_IOTypeCode1); break; case 2: success = pProp->Set(g_IOTypeCode2); break; - default: success=0; + default: break; } if (!success) return DEVICE_INVALID_PROPERTY_VALUE; From 45b47b230eab70db3f21cc50a05ad68b1643400d Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 8 Oct 2024 13:31:46 -0700 Subject: [PATCH 5/6] add one shot OR2 (NRT) and delay OR2 (NRT) logic cell types --- DeviceAdapters/ASITiger/ASIPLogic.cpp | 4 ++++ DeviceAdapters/ASITiger/ASITiger.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/DeviceAdapters/ASITiger/ASIPLogic.cpp b/DeviceAdapters/ASITiger/ASIPLogic.cpp index b1d7b15bd..b740a96bf 100644 --- a/DeviceAdapters/ASITiger/ASIPLogic.cpp +++ b/DeviceAdapters/ASITiger/ASIPLogic.cpp @@ -285,6 +285,10 @@ int CPLogic::Initialize() AddAllowedValue(g_EditCellTypePropertyName, g_CellTypeCode13, 13); AddAllowedValue(g_EditCellTypePropertyName, g_CellTypeCode14, 14); AddAllowedValue(g_EditCellTypePropertyName, g_CellTypeCode15, 15); + if (FirmwareVersionAtLeast(3.50)) { + AddAllowedValue(g_EditCellTypePropertyName, g_CellTypeCode16, 16); + AddAllowedValue(g_EditCellTypePropertyName, g_CellTypeCode17, 17); + } AddAllowedValue(g_EditCellTypePropertyName, g_IOTypeCode0, 100); AddAllowedValue(g_EditCellTypePropertyName, g_IOTypeCode1, 101); AddAllowedValue(g_EditCellTypePropertyName, g_IOTypeCode2, 102); diff --git a/DeviceAdapters/ASITiger/ASITiger.h b/DeviceAdapters/ASITiger/ASITiger.h index 120418220..c466a8519 100644 --- a/DeviceAdapters/ASITiger/ASITiger.h +++ b/DeviceAdapters/ASITiger/ASITiger.h @@ -478,6 +478,8 @@ const char* const g_CellTypeCode12 = "12 - D flop (sync)"; const char* const g_CellTypeCode13 = "13 - JK flop"; const char* const g_CellTypeCode14 = "14 - one shot (NRT)"; const char* const g_CellTypeCode15 = "15 - delay (NRT)"; +const char* const g_CellTypeCode16 = "16 - one shot OR2 (NRT)"; +const char* const g_CellTypeCode17 = "17 - delay OR2 (NRT)"; const char* const g_IOTypeCode0 = "0 - input"; const char* const g_IOTypeCode1 = "1 - output (open-drain)"; const char* const g_IOTypeCode2 = "2 - output (push-pull)"; From 63b43016439cb560c65419cb4c9a4d22a331f176 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 9 Oct 2024 11:09:48 -0700 Subject: [PATCH 6/6] add new cell types to adv properties; use constexpr instead of #define --- DeviceAdapters/ASITiger/ASIPLogic.cpp | 33 +++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/DeviceAdapters/ASITiger/ASIPLogic.cpp b/DeviceAdapters/ASITiger/ASIPLogic.cpp index b740a96bf..a40ace638 100644 --- a/DeviceAdapters/ASITiger/ASIPLogic.cpp +++ b/DeviceAdapters/ASITiger/ASIPLogic.cpp @@ -36,17 +36,17 @@ #include #include -#define PLOGIC_NUM_ADDRESSES 128 -#define PLOGIC_INVERT_ADDRESS 64 -#define PLOGIC_FRONTPANEL_START_ADDRESS 33 -#define PLOGIC_FRONTPANEL_END_ADDRESS 40 -#define PLOGIC_FRONTPANEL_NUM (PLOGIC_FRONTPANEL_END_ADDRESS - PLOGIC_FRONTPANEL_START_ADDRESS + 1) -#define PLOGIC_BACKPLANE_START_ADDRESS 41 -#define PLOGIC_BACKPLANE_END_ADDRESS 48 -#define PLOGIC_BACKPLANE_NUM (PLOGIC_BACKPLANE_END_ADDRESS - PLOGIC_BACKPLANE_START_ADDRESS + 1) -#define PLOGIC_PHYSICAL_IO_START_ADDRESS PLOGIC_FRONTPANEL_START_ADDRESS -#define PLOGIC_PHYSICAL_IO_END_ADDRESS PLOGIC_BACKPLANE_END_ADDRESS -#define PLOGIC_PHYSICAL_IO_NUM (PLOGIC_PHYSICAL_IO_END_ADDRESS - PLOGIC_PHYSICAL_IO_START_ADDRESS + 1) +constexpr unsigned int PLOGIC_NUM_ADDRESSES = 128; +constexpr unsigned int PLOGIC_INVERT_ADDRESS = 64; +constexpr unsigned int PLOGIC_FRONTPANEL_START_ADDRESS = 33; +constexpr unsigned int PLOGIC_FRONTPANEL_END_ADDRESS = 40; +constexpr unsigned int PLOGIC_FRONTPANEL_NUM = PLOGIC_FRONTPANEL_END_ADDRESS - PLOGIC_FRONTPANEL_START_ADDRESS + 1; +constexpr unsigned int PLOGIC_BACKPLANE_START_ADDRESS = 41; +constexpr unsigned int PLOGIC_BACKPLANE_END_ADDRESS = 48; +constexpr unsigned int PLOGIC_BACKPLANE_NUM = PLOGIC_BACKPLANE_END_ADDRESS - PLOGIC_BACKPLANE_START_ADDRESS + 1; +constexpr unsigned int PLOGIC_PHYSICAL_IO_START_ADDRESS = PLOGIC_FRONTPANEL_START_ADDRESS; +constexpr unsigned int PLOGIC_PHYSICAL_IO_END_ADDRESS = PLOGIC_BACKPLANE_END_ADDRESS; +constexpr unsigned int PLOGIC_PHYSICAL_IO_NUM = PLOGIC_PHYSICAL_IO_END_ADDRESS - PLOGIC_PHYSICAL_IO_START_ADDRESS + 1; // ASI Tiger Programmable Logic Card CPLogic::CPLogic(const char* name) : @@ -266,7 +266,8 @@ int CPLogic::Initialize() AddAllowedValue(g_SaveSettingsPropertyName, g_SaveSettingsOrig); AddAllowedValue(g_SaveSettingsPropertyName, g_SaveSettingsDone); - // edits cell wherever current pointer position is + // edits cell type wherever current pointer position is + // Note: also add new cell types to OnAdvancedProperties pAct = new CPropertyAction (this, &CPLogic::OnEditCellType); CreateProperty(g_EditCellTypePropertyName, g_CellTypeCode0, MM::String, false, pAct); AddAllowedValue(g_EditCellTypePropertyName, g_CellTypeCode0, 0); @@ -835,7 +836,7 @@ int CPLogic::OnAdvancedProperties(MM::PropertyBase* pProp, MM::ActionType eAct) GetProperty(g_RefreshPropValsPropertyName, refreshPropValsStr); SetProperty(g_RefreshPropValsPropertyName, g_YesState); - for (long i=1; i<=(long)numCells_; i++) { + for (long i = 1; i <= (long)numCells_; i++) { // logic cell type GetCellPropertyName(i, "_CellType", propName); pActEx = new CPropertyActionEx (this, &CPLogic::OnCellType, i); @@ -856,6 +857,10 @@ int CPLogic::OnAdvancedProperties(MM::PropertyBase* pProp, MM::ActionType eAct) AddAllowedValue(propName, g_CellTypeCode13, 13); AddAllowedValue(propName, g_CellTypeCode14, 14); AddAllowedValue(propName, g_CellTypeCode15, 15); + if (FirmwareVersionAtLeast(3.50)) { + AddAllowedValue(propName, g_CellTypeCode16, 16); + AddAllowedValue(propName, g_CellTypeCode17, 17); + } UpdateProperty(propName); // logic cell CCA Z code @@ -889,7 +894,7 @@ int CPLogic::OnAdvancedProperties(MM::PropertyBase* pProp, MM::ActionType eAct) UpdateProperty(propName); } - for (long i=PLOGIC_FRONTPANEL_START_ADDRESS; i<=PLOGIC_BACKPLANE_END_ADDRESS; i++) { + for (long i = PLOGIC_FRONTPANEL_START_ADDRESS; i <= (long)PLOGIC_BACKPLANE_END_ADDRESS; i++) { GetIOPropertyName(i, "_IOType", propName); pActEx = new CPropertyActionEx (this, &CPLogic::OnIOType, i); CreateProperty(propName, "0", MM::String, false, pActEx);