Skip to content
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

ASITiger: add support for NR Z bit 7 for SPIM and smooth slice enable property for ASIScanner #484

Merged
merged 3 commits into from
Aug 22, 2024
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
60 changes: 59 additions & 1 deletion DeviceAdapters/ASITiger/ASIScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,15 @@ int CScanner::Initialize()
UpdateProperty(g_SPIMScanDurationPropertyName);
}

if (FirmwareVersionAtLeast(3.14)) {
// in 3.50 added bit 7 of SPIM mode for smooth slice (e.g. constant galvo scan for scope)
pAct = new CPropertyAction (this, &CScanner::OnSPIMSmoothSliceEnable);
CreateProperty(g_SPIMSmoothSliceEnable, g_NoState, MM::String, false, pAct);
AddAllowedValue(g_SPIMSmoothSliceEnable, g_YesState);
AddAllowedValue(g_SPIMSmoothSliceEnable, g_NoState);
UpdateProperty(g_SPIMSmoothSliceEnable);
}

} // adding SPIM properties

// add ring buffer properties if supported (starting 2.81)
Expand Down Expand Up @@ -3251,7 +3260,7 @@ int CScanner::OnSPIMAlternateDirectionsEnable(MM::PropertyBase* pProp, MM::Actio
RETURN_ON_MM_ERROR( hub_->QueryCommandVerify(command.str(), ":A Z="));
RETURN_ON_MM_ERROR ( hub_->ParseAnswerAfterEquals(tmp) );
tmp = tmp >> 5; // shift left to get bits 5 in position of LSB
tmp &= (0x01); // mask off all but what used to be bit 4
tmp &= (0x01); // mask off all but what used to be bit 5
switch (tmp)
{
case 0: success = pProp->Set(g_NoState); break;
Expand Down Expand Up @@ -3287,6 +3296,55 @@ int CScanner::OnSPIMAlternateDirectionsEnable(MM::PropertyBase* pProp, MM::Actio
return DEVICE_OK;
}

int CScanner::OnSPIMSmoothSliceEnable(MM::PropertyBase* pProp, MM::ActionType eAct)
{
ostringstream command; command.str("");
long tmp = 0;
bool success;
if (eAct == MM::BeforeGet)
{
if (!refreshProps_ && initialized_)
return DEVICE_OK
command << addressChar_ << "NR Z?";
RETURN_ON_MM_ERROR( hub_->QueryCommandVerify(command.str(), ":A Z="));
RETURN_ON_MM_ERROR ( hub_->ParseAnswerAfterEquals(tmp) );
tmp = tmp >> 7; // shift left to get bits 7 in position of LSB
tmp &= (0x01); // mask off all but what used to be bit 7
switch (tmp)
{
case 0: success = pProp->Set(g_NoState); break;
case 1: success = pProp->Set(g_YesState); break;
default: success = 0;
}
if (!success)
return DEVICE_INVALID_PROPERTY_VALUE;
}
else if (eAct == MM::AfterSet) {
if (hub_->UpdatingSharedProperties())
return DEVICE_OK;
string tmpstr;
pProp->Get(tmpstr);
if (tmpstr.compare(g_NoState) == 0)
tmp = 0;
else if (tmpstr.compare(g_YesState) == 0)
tmp = 1;
else
return DEVICE_INVALID_PROPERTY_VALUE;
tmp = tmp << 7; // right shift to get the value to bit 7
command << addressChar_ << "NR Z?";
long tmp2;
RETURN_ON_MM_ERROR( hub_->QueryCommandVerify(command.str(), ":A Z="));
RETURN_ON_MM_ERROR ( hub_->ParseAnswerAfterEquals(tmp2) );
tmp += (tmp2 & (0x7F)); // keep bit 7 from tmp, all others use current setting
if (tmp == tmp2)
return DEVICE_OK; // don't need to set value if it's already correct
command.str(""); command << addressChar_ << "NR Z=" << tmp;
RETURN_ON_MM_ERROR ( hub_->QueryCommandVerify(command.str(), ":A") );
RETURN_ON_MM_ERROR ( hub_->UpdateSharedProperties(addressChar_, pProp->GetName(), tmpstr.c_str()) );
}
return DEVICE_OK;
}

int CScanner::OnSPIMModeByte(MM::PropertyBase* pProp, MM::ActionType eAct)
{
ostringstream command; command.str("");
Expand Down
1 change: 1 addition & 0 deletions DeviceAdapters/ASITiger/ASIScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class CScanner : public ASIPeripheralBase<CGalvoBase, CScanner>
int OnSPIMPiezoHomeDisable (MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSPIMInterleaveSidesEnable(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSPIMAlternateDirectionsEnable(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSPIMSmoothSliceEnable(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSPIMModeByte (MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSPIMNumRepeats (MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSPIMState (MM::PropertyBase* pProp, MM::ActionType eAct);
Expand Down
1 change: 1 addition & 0 deletions DeviceAdapters/ASITiger/ASITiger.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ const char* const g_SPIMPiezoHomeDisable = "SPIMPiezoHomeDisable";
const char* const g_SPIMScannerHomeDisable = "SPIMScannerHomeDisable";
const char* const g_SPIMInterleaveSidesEnable = "SPIMInterleaveSidesEnable";
const char* const g_SPIMAlternateDirectionsEnable = "SPIMAlternateDirectionsEnable";
const char* const g_SPIMSmoothSliceEnable = "SPIMSmoothSliceEnable";
const char* const g_SPIMNumRepeatsPropertyName = "SPIMNumRepeats";
const char* const g_SPIMArmForTTLPropertyName = "SPIMArm";
const char* const g_SPIMStatePropertyName = "SPIMState";
Expand Down