Skip to content

Commit

Permalink
Merge pull request #545 from bls337/ASITiger
Browse files Browse the repository at this point in the history
ASITiger: add preset 60 and cell type 18 (D - Flop (sync/async)
  • Loading branch information
nicost authored Jan 14, 2025
2 parents 22b85f4 + 1e256b9 commit 200fc3d
Show file tree
Hide file tree
Showing 25 changed files with 176 additions and 208 deletions.
6 changes: 3 additions & 3 deletions DeviceAdapters/ASITiger/ASIBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
// BASED ON: ASIStage.h
//

#ifndef _ASIBase_H_
#define _ASIBase_H_
#ifndef ASIBASE_H
#define ASIBASE_H

#include "MMDevice.h"
#include "DeviceBase.h"
Expand Down Expand Up @@ -125,4 +125,4 @@ class ASIBase : public TDeviceBase<UConcreteDevice>
}
};

#endif // _ASIBase_H_
#endif // ASIBASE_H
6 changes: 3 additions & 3 deletions DeviceAdapters/ASITiger/ASICRISP.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
// BASED ON: ASIStage.h and others
//

#ifndef _ASICRISP_H_
#define _ASICRISP_H_
#ifndef ASICRISP_H
#define ASICRISP_H

#include "ASIPeripheralBase.h"
#include "MMDevice.h"
Expand Down Expand Up @@ -85,4 +85,4 @@ class CCRISP : public ASIPeripheralBase<CAutoFocusBase, CCRISP>
int ForceSetFocusState(string focusState);
};

#endif // end _ASICRISP_H_
#endif // ASICRISP_H
8 changes: 3 additions & 5 deletions DeviceAdapters/ASITiger/ASIClocked.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
// BASED ON: ASIStage.h and others
//

#ifndef _ASIClocked_H_
#define _ASIClocked_H_
#ifndef ASICLOCKED_H
#define ASICLOCKED_H

#include "ASIPeripheralBase.h"
#include "MMDevice.h"
#include "DeviceBase.h"

using namespace std;

class CClocked : public ASIPeripheralBase<CStateDeviceBase, CClocked>
{
public:
Expand Down Expand Up @@ -93,4 +91,4 @@ class CPortSwitch : public CClocked
int Initialize();
};

#endif //_ASIClocked_H_
#endif // ASICLOCKED_H
8 changes: 4 additions & 4 deletions DeviceAdapters/ASITiger/ASIDac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int CDAC::Initialize()
// ASI's unit multiplier is how many units per volt, so divide by 1 here to get units per volt, divide by 1000 to get units in millivolts
// except for GetSignal() and SetSignal() which deals in Volts, we will make all properties units millivolt
command.str("");
command << "UM " << axisLetter_ << "? ";
command << "UM " << axisLetter_ << "?";
RETURN_ON_MM_ERROR(hub_->QueryCommandVerify(command.str(), ":"));
RETURN_ON_MM_ERROR(hub_->ParseAnswerAfterEquals(tmp));
unitMult_ = tmp / 1000;
Expand Down Expand Up @@ -350,7 +350,7 @@ int CDAC::GetGateOpen(bool &open) {
ostringstream command;
long tmp;
command.str("");
command << "MC " << axisLetter_ << "? ";
command << "MC " << axisLetter_ << "?";

open = false;//incase of error we return that gate is closed
// "MC <Axis>?" replies look like ":A 1"
Expand All @@ -367,7 +367,7 @@ int CDAC::GetMaxVolts(double &volts)
ostringstream command;

command.str("");
command << "SU " << axisLetter_ << "? ";
command << "SU " << axisLetter_ << "?";
RETURN_ON_MM_ERROR(hub_->QueryCommandVerify(command.str(), ":A"));
RETURN_ON_MM_ERROR(hub_->ParseAnswerAfterEquals(volts));
return DEVICE_OK;
Expand All @@ -378,7 +378,7 @@ int CDAC::GetMinVolts(double &volts)
ostringstream command;

command.str("");
command << "SL " << axisLetter_ << "? ";
command << "SL " << axisLetter_ << "?";
RETURN_ON_MM_ERROR(hub_->QueryCommandVerify(command.str(), ":A"));
RETURN_ON_MM_ERROR(hub_->ParseAnswerAfterEquals(volts));
return DEVICE_OK;
Expand Down
14 changes: 4 additions & 10 deletions DeviceAdapters/ASITiger/ASIDac.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
// BASED ON: ASIStage.h and others
//

#ifndef _ASIDAC_H_
#define _ASIDAC_H_
#ifndef ASIDAC_H
#define ASIDAC_H

#include "ASIPeripheralBase.h"
#include "MMDevice.h"
#include "DeviceBase.h"


class CDAC : public ASIPeripheralBase<CSignalIOBase, CDAC>
{
public:
Expand Down Expand Up @@ -95,7 +94,7 @@ class CDAC : public ASIPeripheralBase<CSignalIOBase, CDAC>

private:
double unitMult_;
string axisLetter_;
std::string axisLetter_;
double maxvolts_;
double minvolts_;
bool ring_buffer_supported_;
Expand All @@ -108,11 +107,6 @@ class CDAC : public ASIPeripheralBase<CSignalIOBase, CDAC>
int GetMinVolts(double &volts);
int SetSignalmv(double millivolts);
int GetSignalmv(double& millivolts);



};



#endif//_ASIDAC_H_
#endif // ASIDAC_H
6 changes: 3 additions & 3 deletions DeviceAdapters/ASITiger/ASIDacXYStage.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
// BASED ON: ASIStage.cpp and others
//

#ifndef _ASIDACXYStage_H_
#define _ASIDACXYStage_H_
#ifndef ASIDACXYSTAGE_H
#define ASIDACXYSTAGE_H

#include "ASIPeripheralBase.h"
#include "MMDevice.h"
Expand Down Expand Up @@ -172,4 +172,4 @@ class CDACXYStage : public ASIPeripheralBase<CXYStageBase, CDACXYStage>
int GetMinVolts(double& volts, std::string axisLetter);
};

#endif // _ASIDACXYStage_H_
#endif // ASIDACXYSTAGE_H
12 changes: 5 additions & 7 deletions DeviceAdapters/ASITiger/ASIFWheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
// BASED ON: ASIStage.h and others
//

#ifndef _ASIFWheel_H_
#define _ASIFWheel_H_
#ifndef ASIFWHEEL_H
#define ASIFWHEEL_H

#include "ASIPeripheralBase.h"
#include "MMDevice.h"
#include "DeviceBase.h"

using namespace std;

class CFWheel : public ASIPeripheralBase<CStateDeviceBase, CFWheel>
{
public:
Expand Down Expand Up @@ -62,12 +60,12 @@ class CFWheel : public ASIPeripheralBase<CStateDeviceBase, CFWheel>
unsigned int numPositions_;
unsigned int curPosition_;
bool spinning_;
string wheelNumber_;
static string selectedWheel_; // which wheel is currently selected, shared among all instances of this class
std::string wheelNumber_;
static std::string selectedWheel_; // which wheel is currently selected, shared among all instances of this class

int SelectWheelOverride();
int SelectWheel();
void ForcePropertyRefresh();
};

#endif //_ASIFWheel_H_
#endif // ASIFWHEEL_H
75 changes: 36 additions & 39 deletions DeviceAdapters/ASITiger/ASIHub.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
// BASED ON: ASIStage.h
//

#ifndef _ASIHub_H_
#define _ASIHub_H_
#ifndef ASIHUB_H
#define ASIHUB_H

#include "ASIBase.h"
#include "MMDevice.h"
#include "DeviceBase.h"
#include "DeviceThreads.h"
#include <string>

using namespace std;

////////////////////////////////////////////////////////////////
// *********** generic ASI comm class *************************
// implements a "hub" device with communication abilities
Expand All @@ -56,44 +54,44 @@ class ASIHub : public ASIBase<HubBase, ASIHub>
int QueryCommandUnterminatedResponse(const char *command, const long timeoutMs, unsigned long reply_length);
int QueryCommandUnterminatedResponse(const char *command, const long timeoutMs)
{ return QueryCommandUnterminatedResponse(command, timeoutMs,1); }
int QueryCommandUnterminatedResponse(const string command, const long timeoutMs)
int QueryCommandUnterminatedResponse(const std::string command, const long timeoutMs)
{ return QueryCommandUnterminatedResponse(command.c_str(), timeoutMs,1); }
int QueryCommandUnterminatedResponse(const string command, const long timeoutMs, unsigned long reply_length)
int QueryCommandUnterminatedResponse(const std::string command, const long timeoutMs, unsigned long reply_length)
{ return QueryCommandUnterminatedResponse(command.c_str(), timeoutMs, reply_length); }

int QueryCommandLongReply(const char *command, const char *replyTerminator); // all variants call this
int QueryCommandLongReply(const char *command) { return QueryCommandLongReply(command, g_SerialTerminatorMultiLine); }
int QueryCommandLongReply(const string &command) { return QueryCommandLongReply(command.c_str(), g_SerialTerminatorMultiLine); }
int QueryCommandLongReply(const std::string &command) { return QueryCommandLongReply(command.c_str(), g_SerialTerminatorMultiLine); }

// QueryCommand gets the response (optional 2nd parameter is the response's termination string) (optional 3rd parameter is delay between sending and reading response)
int QueryCommand(const char *command, const char *replyTerminator, const long delayMs); // all variants call this
int QueryCommand(const char *command) { return QueryCommand(command, g_SerialTerminatorDefault, (long)0); }
int QueryCommand(const string &command) { return QueryCommand(command.c_str(), g_SerialTerminatorDefault, (long)0); }
int QueryCommand(const string &command, const string &replyTerminator) { return QueryCommand(command.c_str(), replyTerminator.c_str(), (long)0); }
int QueryCommand(const std::string &command) { return QueryCommand(command.c_str(), g_SerialTerminatorDefault, (long)0); }
int QueryCommand(const std::string &command, const std::string &replyTerminator) { return QueryCommand(command.c_str(), replyTerminator.c_str(), (long)0); }
int QueryCommand(const char *command, const long delayMs) { return QueryCommand(command, g_SerialTerminatorDefault, delayMs); }
int QueryCommand(const string &command, const long delayMs) { return QueryCommand(command.c_str(), g_SerialTerminatorDefault, delayMs); }
int QueryCommand(const string &command, const string &replyTerminator, const long delayMs) { return QueryCommand(command.c_str(), replyTerminator.c_str(), delayMs); }
int QueryCommand(const std::string &command, const long delayMs) { return QueryCommand(command.c_str(), g_SerialTerminatorDefault, delayMs); }
int QueryCommand(const std::string &command, const std::string &replyTerminator, const long delayMs) { return QueryCommand(command.c_str(), replyTerminator.c_str(), delayMs); }

// QueryCommandVerify gets the response and makes sure the first characters match expectedReplyPrefix
int QueryCommandVerify(const char *command, const char *expectedReplyPrefix, const char *replyTerminator, const long delayMs); // all variants call this
int QueryCommandVerify(const char *command, const char *expectedReplyPrefix)
{ return QueryCommandVerify(command, expectedReplyPrefix, g_SerialTerminatorDefault, (long)0); }
int QueryCommandVerify(const string &command, const string &expectedReplyPrefix)
int QueryCommandVerify(const std::string &command, const std::string &expectedReplyPrefix)
{ return QueryCommandVerify(command.c_str(), expectedReplyPrefix.c_str(), g_SerialTerminatorDefault, (long)0); }
int QueryCommandVerify(const string &command, const string &expectedReplyPrefix, const string &replyTerminator)
int QueryCommandVerify(const std::string &command, const std::string &expectedReplyPrefix, const std::string &replyTerminator)
{ return QueryCommandVerify(command.c_str(), expectedReplyPrefix.c_str(), replyTerminator.c_str(), (long)0); }
int QueryCommandVerify(const char *command, const char *expectedReplyPrefix, const long delayMs)
{ return QueryCommandVerify(command, expectedReplyPrefix, g_SerialTerminatorDefault, delayMs); }
int QueryCommandVerify(const string &command, const string &expectedReplyPrefix, const long delayMs)
int QueryCommandVerify(const std::string &command, const std::string &expectedReplyPrefix, const long delayMs)
{ return QueryCommandVerify(command.c_str(), expectedReplyPrefix.c_str(), g_SerialTerminatorDefault, delayMs); }
int QueryCommandVerify(const string &command, const string &expectedReplyPrefix, const string &replyTerminator, const long delayMs)
int QueryCommandVerify(const std::string &command, const std::string &expectedReplyPrefix, const std::string &replyTerminator, const long delayMs)
{ return QueryCommandVerify(command.c_str(), expectedReplyPrefix.c_str(), replyTerminator.c_str(), delayMs); }

// accessing serial commands and answers
string LastSerialAnswer() const { return serialAnswer_; } // use with caution!; crashes to access something that doesn't exist!
string LastSerialCommand() const { return serialCommand_; }
char LastSerialAnswerChar() const { return serialAnswer_.back(); }
void SetLastSerialAnswer(string s) { serialAnswer_ = s; } // used to parse subsets of full answer for commands like PZINFO using "Split" functions
void SetLastSerialAnswer(std::string s) { serialAnswer_ = s; } // used to parse subsets of full answer for commands like PZINFO using "Split" functions

// Interpreting serial response
int ParseAnswerAfterEquals(double &val); // finds next number after equals sign and returns as float
Expand All @@ -114,30 +112,30 @@ class ASIHub : public ASIBase<HubBase, ASIHub>
int GetAnswerCharAtPosition(unsigned int pos, char &val); // returns the character at specified position, a safer version of LastSerialAnswer().at(pos)
int GetAnswerCharAtPosition3(char &val); // returns the character at position 3, a safer version of LastSerialAnswer().at(3)

vector<string> SplitAnswerOnDelim(string delim) const; // splits answer on arbitrary delimeter list (any of included characters will split)
vector<string> SplitAnswerOnCR() const { return SplitAnswerOnDelim("\r"); }
vector<string> SplitAnswerOnSpace() const { return SplitAnswerOnDelim(" "); }
std::vector<std::string> SplitAnswerOnDelim(std::string delim) const; // splits answer on arbitrary delimeter list (any of included characters will split)
std::vector<std::string> SplitAnswerOnCR() const { return SplitAnswerOnDelim("\r"); }
std::vector<std::string> SplitAnswerOnSpace() const { return SplitAnswerOnDelim(" "); }

// function to grab all the build info from BU X command
int GetBuildInfo(const string addressLetter, build_info_type &build);
int GetBuildInfo(const std::string addressLetter, build_info_type &build);

// look to see if particular define is present
bool IsDefinePresent(const build_info_type build, const string defineToLookFor);
bool IsDefinePresent(const build_info_type build, const std::string defineToLookFor);

// get define string from substring (e.g. the RING BUFFER define has the # of positions)
string GetDefineString(const build_info_type build, const string substringToLookFor);
std::string GetDefineString(const build_info_type build, const std::string substringToLookFor);

void RegisterPeripheral(const string deviceLabel, const string addressChar) {
void RegisterPeripheral(const std::string deviceLabel, const std::string addressChar) {
deviceMap_[deviceLabel] = addressChar; // add device to lookup table
}

void UnRegisterPeripheral(const string deviceLabel) {
void UnRegisterPeripheral(const std::string deviceLabel) {
deviceMap_.erase(deviceLabel); // remove device from lookup table
}

bool UpdatingSharedProperties() { return updatingSharedProperties_; }

int UpdateSharedProperties(string addressChar, string propName, string value);
int UpdateSharedProperties(std::string addressChar, std::string propName, std::string value);

// action/property handlers
int OnPort (MM::PropertyBase* pProp, MM::ActionType eAct);
Expand All @@ -149,29 +147,28 @@ class ASIHub : public ASIBase<HubBase, ASIHub>
int OnSerialCommandOnlySendChanged(MM::PropertyBase* pProp, MM::ActionType eAct);

protected:
string port_; // port to use for communication
std::string port_; // port to use for communication

private:
int ParseErrorReply() const;
static string EscapeControlCharacters(const string v);
static string UnescapeControlCharacters(const string v0 );
static vector<char> ConvertStringVector2CharVector(const vector<string> v);
static vector<int> ConvertStringVector2IntVector(const vector<string> v);

string serialAnswer_; // the last answer received from any communication with the controller
string manualSerialAnswer_; // last answer received when the SerialCommand property was used
string serialCommand_; // the last command sent, or can be set for calling commands without args
string serialTerminator_; // only used when parsing command sent via OnSerialCommand action handler
static std::string EscapeControlCharacters(const std::string v);
static std::string UnescapeControlCharacters(const std::string v0);
static std::vector<char> ConvertStringVector2CharVector(const std::vector<std::string> v);
static std::vector<int> ConvertStringVector2IntVector(const std::vector<std::string> v);

std::string serialAnswer_; // the last answer received from any communication with the controller
std::string manualSerialAnswer_; // last answer received when the SerialCommand property was used
std::string serialCommand_; // the last command sent, or can be set for calling commands without args
std::string serialTerminator_; // only used when parsing command sent via OnSerialCommand action handler
long serialRepeatDuration_; // for how long total time the command is repeatedly sent
long serialRepeatPeriod_; // how often in ms the command is sent
bool serialOnlySendChanged_; // if true the serial command is only sent when it has changed
MMThreadLock threadLock_; // used to lock thread during serial transaction
bool updatingSharedProperties_;
map<string, string> deviceMap_; // to implement properties shared between devices
// key is the device name, value is the Tiger address (normally a single character, see note about addressChar_ in ASIPeripheralBase)

std::map<std::string, std::string> deviceMap_; // to implement properties shared between devices
// key is the device name, value is the Tiger address (normally a single character, see note about addressChar_ in ASIPeripheralBase
};



#endif //_ASIHub_H_
#endif // ASIHUB_H
9 changes: 3 additions & 6 deletions DeviceAdapters/ASITiger/ASILED.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
// BASED ON: ASIStage.h and others
//

#ifndef _ASILED_H_
#define _ASILED_H_
#ifndef ASILED_H
#define ASILED_H

#include "ASIPeripheralBase.h"
#include "MMDevice.h"
Expand All @@ -36,18 +36,15 @@ class CLED : public ASIPeripheralBase<CShutterBase, CLED>
~CLED() { }

// Device API
// ----------
int Initialize();
bool Busy() { return false; }

// Shutter API
// -----------
int SetOpen(bool open = true);
int GetOpen(bool& open);
int Fire(double /*deltaT*/) { return DEVICE_UNSUPPORTED_COMMAND; }

// action interface
// ----------------
int OnSaveCardSettings (MM::PropertyBase* pProp, MM::ActionType eAct);
int OnRefreshProperties (MM::PropertyBase* pProp, MM::ActionType eAct);
int OnIntensity (MM::PropertyBase* pProp, MM::ActionType eAct);
Expand All @@ -63,4 +60,4 @@ class CLED : public ASIPeripheralBase<CShutterBase, CLED>
int UpdateOpenIntensity();
};

#endif //_ASILED_H_
#endif // ASILED_H
Loading

0 comments on commit 200fc3d

Please sign in to comment.