MMDevice  1.4
MMDevice.h
1 // FILE: MMDevice.h
3 // PROJECT: Micro-Manager
4 // SUBSYSTEM: MMDevice - Device adapter kit
5 //-----------------------------------------------------------------------------
6 // DESCRIPTION: The interface to the Micro-Manager devices. Defines the
7 // plugin API for all devices.
8 //
9 // AUTHOR: Nenad Amodaj, nenad@amodaj.com, 06/08/2005
10 //
11 // COPYRIGHT: University of California, San Francisco, 2006-2014
12 // 100X Imaging Inc, 2008
13 //
14 // LICENSE: This file is distributed under the BSD license.
15 // License text is included with the source distribution.
16 //
17 // This file is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty
19 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 //
21 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
24 
25 
27 // Header version
28 // If any of the class definitions changes, the interface version
29 // must be incremented
30 #define DEVICE_INTERFACE_VERSION 70
31 
33 
34 // N.B.
35 //
36 // Never add parameters or return values that are not POD
37 // (http://stackoverflow.com/a/146454) to any method of class Device and its
38 // derived classes defined in this file. For example, a std::string parameter
39 // is not acceptable (use const char*). This is to prevent inter-DLL
40 // incompatibilities.
41 
42 
43 #pragma once
44 #ifndef MMMMDEVICE_H
45 #define MMMMDEVICE_H
46 
47 #include "MMDeviceConstants.h"
48 #include "DeviceUtils.h"
49 #include "ImageMetadata.h"
50 #include "DeviceThreads.h"
51 #include <string>
52 #include <cstring>
53 #include <climits>
54 #include <cstdlib>
55 #include <vector>
56 #include <sstream>
57 
58 
59 #ifdef MODULE_EXPORTS
60 # ifdef _MSC_VER
61 # define MM_DEPRECATED(prototype) __declspec(deprecated) prototype
62 # elif defined(__GNUC__)
63 # define MM_DEPRECATED(prototype) prototype __attribute__((deprecated))
64 # else
65 # define MM_DEPRECATED(prototype) prototype
66 # endif
67 #else
68 # define MM_DEPRECATED(prototype) prototype
69 #endif
70 
71 
72 #ifdef WIN32
73  #define WIN32_LEAN_AND_MEAN
74  #include <windows.h>
75 
76  typedef HMODULE HDEVMODULE;
77 #else
78  typedef void* HDEVMODULE;
79 #endif
80 
81 #include "FixSnprintf.h"
82 
83 
84 class ImgBuffer;
85 
86 
87 
88 namespace MM {
89 
90  // forward declaration for the MMCore callback class
91  class Core;
92 
97  class MMTime
98  {
99  public:
100  MMTime(double uSecTotal = 0.0)
101  {
102  sec_ = (long) (uSecTotal / 1.0e6);
103  uSec_ = (long) (uSecTotal - sec_ * 1.0e6);
104  }
105 
106  MMTime(long sec, long uSec) : sec_(sec), uSec_(uSec)
107  {
108  Normalize();
109  }
110 
111  ~MMTime() {}
112 
113  MMTime(std::string serialized) {
114  std::stringstream is(serialized);
115  is >> sec_ >> uSec_;
116  Normalize();
117  }
118 
119  std::string serialize() {
120  std::ostringstream os;
121  os << sec_ << " " << uSec_;
122  return os.str().c_str();
123  }
124 
125  long sec_;
126  long uSec_;
127 
128  MMTime operator+(const MMTime &other) const
129  {
130  MMTime res(sec_ + other.sec_, uSec_ + other.uSec_);
131  return res;
132  }
133 
134  MMTime operator-(const MMTime &other) const
135  {
136  MMTime res(sec_ - other.sec_, uSec_ - other.uSec_);
137  return res;
138  }
139 
140  bool operator>(const MMTime &other) const
141  {
142  if (sec_ > other.sec_)
143  return true;
144  else if (sec_ < other.sec_)
145  return false;
146 
147  if (uSec_ > other.uSec_)
148  return true;
149  else
150  return false;
151  }
152 
153  bool operator<(const MMTime &other) const
154  {
155  if (*this == other)
156  return false;
157 
158  return ! (*this > other);
159  }
160 
161  bool operator==(const MMTime &other) const
162  {
163  if (sec_ == other.sec_ && uSec_ == other.uSec_)
164  return true;
165  else
166  return false;
167  }
168 
169  double getMsec() const
170  {
171  return sec_ * 1000.0 + uSec_ / 1000.0;
172  }
173 
174  double getUsec() const
175  {
176  return sec_ * 1.0e6 + uSec_;
177  }
178 
179  private:
180  void Normalize()
181  {
182  if (sec_ < 0)
183  {
184  sec_ = 0L;
185  uSec_ = 0L;
186  return;
187  }
188 
189  if (uSec_ < 0)
190  {
191  sec_--;
192  uSec_ = 1000000L + uSec_;
193  }
194 
195  long overflow = uSec_ / 1000000L;
196  if (overflow > 0)
197  {
198  sec_ += overflow;
199  uSec_ -= overflow * 1000000L;
200  }
201  }
202  };
203 
204 
208  class TimeoutMs
209  {
210  public:
211  // arguments: MMTime start time, millisecond interval time
212  TimeoutMs(const MMTime startTime, const unsigned long intervalMs) :
213  startTime_(startTime),
214  interval_(0, 1000*intervalMs)
215  {
216  }
217  TimeoutMs(const MMTime startTime, const MMTime interval) :
218  startTime_(startTime),
219  interval_(interval)
220  {
221  }
222  ~TimeoutMs()
223  {
224  }
225  bool expired(const MMTime tnow)
226  {
227  MMTime elapsed = tnow - startTime_;
228  return ( interval_ < elapsed );
229  }
230  private:
231  TimeoutMs(const MM::TimeoutMs&) {}
232  const TimeoutMs& operator=(const MM::TimeoutMs&) {return *this;}
233  MMTime startTime_; // start time
234  MMTime interval_; // interval in milliseconds
235  };
236 
237 
241  class Device {
242  public:
243  Device() {}
244  virtual ~Device() {}
245 
246  virtual unsigned GetNumberOfProperties() const = 0;
247  virtual int GetProperty(const char* name, char* value) const = 0;
248  virtual int SetProperty(const char* name, const char* value) = 0;
249  virtual bool HasProperty(const char* name) const = 0;
250  virtual bool GetPropertyName(unsigned idx, char* name) const = 0;
251  virtual int GetPropertyReadOnly(const char* name, bool& readOnly) const = 0;
252  virtual int GetPropertyInitStatus(const char* name, bool& preInit) const = 0;
253  virtual int HasPropertyLimits(const char* name, bool& hasLimits) const = 0;
254  virtual int GetPropertyLowerLimit(const char* name, double& lowLimit) const = 0;
255  virtual int GetPropertyUpperLimit(const char* name, double& hiLimit) const = 0;
256  virtual int GetPropertyType(const char* name, MM::PropertyType& pt) const = 0;
257  virtual unsigned GetNumberOfPropertyValues(const char* propertyName) const = 0;
258  virtual bool GetPropertyValueAt(const char* propertyName, unsigned index, char* value) const = 0;
267  virtual int IsPropertySequenceable(const char* name, bool& isSequenceable) const = 0;
271  virtual int GetPropertySequenceMaxLength(const char* propertyName, long& nrEvents) const = 0;
275  virtual int StartPropertySequence(const char* propertyName) = 0;
279  virtual int StopPropertySequence(const char* propertyName) = 0;
283  virtual int ClearPropertySequence(const char* propertyName) = 0;
287  virtual int AddToPropertySequence(const char* propertyName, const char* value) = 0;
291  virtual int SendPropertySequence(const char* propertyName) = 0;
292 
293  virtual bool GetErrorText(int errorCode, char* errMessage) const = 0;
294  virtual bool Busy() = 0;
295  virtual double GetDelayMs() const = 0;
296  virtual void SetDelayMs(double delay) = 0;
297  virtual bool UsesDelay() = 0;
298 
302  // TODO Get/SetModuleHandle() is no longer used; can remove at a
303  // convenient time.
304  virtual HDEVMODULE GetModuleHandle() const = 0;
305  virtual void SetModuleHandle(HDEVMODULE hLibraryHandle) = 0;
306  virtual void SetLabel(const char* label) = 0;
307  virtual void GetLabel(char* name) const = 0;
308  virtual void SetModuleName(const char* moduleName) = 0;
309  virtual void GetModuleName(char* moduleName) const = 0;
310  virtual void SetDescription(const char* description) = 0;
311  virtual void GetDescription(char* description) const = 0;
312 
313  virtual int Initialize() = 0;
322  virtual int Shutdown() = 0;
323 
324  virtual DeviceType GetType() const = 0;
325  virtual void GetName(char* name) const = 0;
326  virtual void SetCallback(Core* callback) = 0;
327 
328  //device discovery API
329  virtual bool SupportsDeviceDetection(void) = 0;
330  virtual MM::DeviceDetectionStatus DetectDevice(void) = 0;
331 
332  // hub-peripheral relationship
333  virtual void SetParentID(const char* parentId) = 0;
334  virtual void GetParentID(char* parentID) const = 0;
335  // virtual void SetID(const char* id) = 0;
336  // virtual void GetID(char* id) const = 0;
337  };
338 
342  class Generic : public Device
343  {
344  public:
345  virtual DeviceType GetType() const { return Type; }
346  static const DeviceType Type;
347  };
348 
352  class Camera : public Device {
353  public:
354  Camera() {}
355  virtual ~Camera() {}
356 
357  virtual DeviceType GetType() const { return Type; }
358  static const DeviceType Type;
359 
360  // Camera API
369  virtual int SnapImage() = 0;
394  virtual const unsigned char* GetImageBuffer() = 0;
406  virtual const unsigned char* GetImageBuffer(unsigned channelNr) = 0;
410  virtual const unsigned int* GetImageBufferAsRGB32() = 0;
415  virtual unsigned GetNumberOfComponents() const = 0;
419  virtual int GetComponentName(unsigned component, char* name) = 0;
425  virtual int unsigned GetNumberOfChannels() const = 0;
430  virtual int GetChannelName(unsigned channel, char* name) = 0;
436  virtual long GetImageBufferSize() const = 0;
441  virtual unsigned GetImageWidth() const = 0;
446  virtual unsigned GetImageHeight() const = 0;
451  virtual unsigned GetImageBytesPerPixel() const = 0;
458  virtual unsigned GetBitDepth() const = 0;
463  virtual double GetPixelSizeUm() const = 0;
467  virtual int GetBinning() const = 0;
471  virtual int SetBinning(int binSize) = 0;
475  virtual void SetExposure(double exp_ms) = 0;
479  virtual double GetExposure() const = 0;
493  virtual int SetROI(unsigned x, unsigned y, unsigned xSize, unsigned ySize) = 0;
497  virtual int GetROI(unsigned& x, unsigned& y, unsigned& xSize, unsigned& ySize) = 0;
501  virtual int ClearROI() = 0;
502  virtual bool SupportsMultiROI() = 0;
503  virtual bool IsMultiROISet() = 0;
504  virtual int GetMultiROICount(unsigned& count) = 0;
505  virtual int SetMultiROI(const unsigned* xs, const unsigned* ys,
506  const unsigned* widths, const unsigned* heights,
507  unsigned numROIs) = 0;
508  virtual int GetMultiROI(unsigned* xs, unsigned* ys, unsigned* widths,
509  unsigned* heights, unsigned* length) = 0;
513  virtual int StartSequenceAcquisition(long numImages, double interval_ms, bool stopOnOverflow) = 0;
518  virtual int StartSequenceAcquisition(double interval_ms) = 0;
522  virtual int StopSequenceAcquisition() = 0;
526  virtual int PrepareSequenceAcqusition() = 0;
531  virtual bool IsCapturing() = 0;
532 
539  virtual void GetTags(char* serializedMetadata) = 0;
540 
548  virtual void AddTag(const char* key, const char* deviceLabel, const char* value) = 0;
549 
555  virtual void RemoveTag(const char* key) = 0;
556 
562  virtual int IsExposureSequenceable(bool& isSequenceable) const = 0;
563 
564  // Sequence functions
565  // Sequences can be used for fast acquisitions, synchronized by TTLs rather than
566  // computer commands.
567  // Sequences of exposures can be uploaded to the camera. The camera will cycle through
568  // the uploaded list of exposures (triggered by either an internal or
569  // external trigger). If the device is capable (and ready) to do so isSequenceable will
570  // be true. If your device can not execute this (true for most cameras)
571  // simply set IsExposureSequenceable to false
572  virtual int GetExposureSequenceMaxLength(long& nrEvents) const = 0;
573  virtual int StartExposureSequence() = 0;
574  virtual int StopExposureSequence() = 0;
575  // Remove all values in the sequence
576  virtual int ClearExposureSequence() = 0;
577  // Add one value to the sequence
578  virtual int AddToExposureSequence(double exposureTime_ms) = 0;
579  // Signal that we are done sending sequence values so that the adapter can send the whole sequence to the device
580  virtual int SendExposureSequence() const = 0;
581  };
582 
586  class Shutter : public Device
587  {
588  public:
589  Shutter() {}
590  virtual ~Shutter() {}
591 
592  // Device API
593  virtual DeviceType GetType() const { return Type; }
594  static const DeviceType Type;
595 
596  // Shutter API
597  virtual int SetOpen(bool open = true) = 0;
598  virtual int GetOpen(bool& open) = 0;
603  virtual int Fire(double deltaT) = 0;
604  };
605 
609  class Stage : public Device
610  {
611  public:
612  Stage() {}
613  virtual ~Stage() {}
614 
615  // Device API
616  virtual DeviceType GetType() const { return Type; }
617  static const DeviceType Type;
618 
619  // Stage API
620  virtual int SetPositionUm(double pos) = 0;
621  virtual int SetRelativePositionUm(double d) = 0;
622  virtual int Move(double velocity) = 0;
623  virtual int Stop() = 0;
624  virtual int Home() = 0;
625  virtual int SetAdapterOriginUm(double d) = 0;
626  virtual int GetPositionUm(double& pos) = 0;
627  virtual int SetPositionSteps(long steps) = 0;
628  virtual int GetPositionSteps(long& steps) = 0;
629  virtual int SetOrigin() = 0;
630  virtual int GetLimits(double& lower, double& upper) = 0;
631 
645  virtual int GetFocusDirection(FocusDirection& direction) = 0;
646 
654  virtual int IsStageSequenceable(bool& isSequenceable) const = 0;
655 
665  virtual int IsStageLinearSequenceable(bool& isSequenceable) const = 0;
666 
667  // Check if a stage has continuous focusing capability (positions can be set while continuous focus runs).
668  virtual bool IsContinuousFocusDrive() const = 0;
669 
670  // Sequence functions
671  // Sequences can be used for fast acquisitions, synchronized by TTLs rather than
672  // computer commands.
673  // Sequences of positions can be uploaded to the stage. The device will cycle through
674  // the uploaded list of states (triggered by an external trigger - most often coming
675  // from the camera). If the device is capable (and ready) to do so isSequenceable will
676  // be true. If your device can not execute this (true for most stages)
677  // simply set isSequenceable to false
678  virtual int GetStageSequenceMaxLength(long& nrEvents) const = 0;
679  virtual int StartStageSequence() = 0;
680  virtual int StopStageSequence() = 0;
684  virtual int ClearStageSequence() = 0;
688  virtual int AddToStageSequence(double position) = 0;
693  virtual int SendStageSequence() = 0;
694 
703  virtual int SetStageLinearSequence(double dZ_um, long nSlices) = 0;
704  };
705 
709  class XYStage : public Device
710  {
711  public:
712  XYStage() {}
713  virtual ~XYStage() {}
714 
715  // Device API
716  virtual DeviceType GetType() const { return Type; }
717  static const DeviceType Type;
718 
719  // XYStage API
720  // it is recommended that device adapters implement the "Steps" methods
721  // taking long integers but leave the default implementations (in
722  // DeviceBase.h) for the "Um" methods taking doubles. The latter utilize
723  // directionality and origin settings set by user and operate via the
724  // "Steps" methods. The step size is the inherent minimum distance/step
725  // and should be defined by the adapter.
726  virtual int SetPositionUm(double x, double y) = 0;
727  virtual int SetRelativePositionUm(double dx, double dy) = 0;
728  virtual int SetAdapterOriginUm(double x, double y) = 0;
729  virtual int GetPositionUm(double& x, double& y) = 0;
730  virtual int GetLimitsUm(double& xMin, double& xMax, double& yMin, double& yMax) = 0;
731  virtual int Move(double vx, double vy) = 0;
732 
733  virtual int SetPositionSteps(long x, long y) = 0;
734  virtual int GetPositionSteps(long& x, long& y) = 0;
735  virtual int SetRelativePositionSteps(long x, long y) = 0;
736  virtual int Home() = 0;
737  virtual int Stop() = 0;
738 
742  virtual int SetOrigin() = 0;
743 
748  virtual int SetXOrigin() = 0;
749 
754  virtual int SetYOrigin() = 0;
755 
756  virtual int GetStepLimits(long& xMin, long& xMax, long& yMin, long& yMax) = 0;
757  virtual double GetStepSizeXUm() = 0;
758  virtual double GetStepSizeYUm() = 0;
764  virtual int IsXYStageSequenceable(bool& isSequenceable) const = 0;
765  // Sequence functions
766  // Sequences can be used for fast acquisitions, synchronized by TTLs rather than
767  // computer commands.
768  // Sequences of positions can be uploaded to the XY stage. The device will cycle through
769  // the uploaded list of states (triggered by an external trigger - most often coming
770  // from the camera). If the device is capable (and ready) to do so isSequenceable will
771  // be true. If your device can not execute this (true for most XY stages
772  // simply set isSequenceable to false
773  virtual int GetXYStageSequenceMaxLength(long& nrEvents) const = 0;
774  virtual int StartXYStageSequence() = 0;
775  virtual int StopXYStageSequence() = 0;
779  virtual int ClearXYStageSequence() = 0;
783  virtual int AddToXYStageSequence(double positionX, double positionY) = 0;
788  virtual int SendXYStageSequence() = 0;
789 
790  };
791 
795  class State : public Device
796  {
797  public:
798  State() {}
799  virtual ~State() {}
800 
801  // MMDevice API
802  virtual DeviceType GetType() const { return Type; }
803  static const DeviceType Type;
804 
805  // MMStateDevice API
806  virtual int SetPosition(long pos) = 0;
807  virtual int SetPosition(const char* label) = 0;
808  virtual int GetPosition(long& pos) const = 0;
809  virtual int GetPosition(char* label) const = 0;
810  virtual int GetPositionLabel(long pos, char* label) const = 0;
811  virtual int GetLabelPosition(const char* label, long& pos) const = 0;
812  virtual int SetPositionLabel(long pos, const char* label) = 0;
813  virtual unsigned long GetNumberOfPositions() const = 0;
814  virtual int SetGateOpen(bool open = true) = 0;
815  virtual int GetGateOpen(bool& open) = 0;
816  };
817 
821  class Serial : public Device
822  {
823  public:
824  Serial() {}
825  virtual ~Serial() {}
826 
827  // MMDevice API
828  virtual DeviceType GetType() const { return Type; }
829  static const DeviceType Type;
830 
831  // Serial API
832  virtual PortType GetPortType() const = 0;
833  virtual int SetCommand(const char* command, const char* term) = 0;
834  virtual int GetAnswer(char* txt, unsigned maxChars, const char* term) = 0;
835  virtual int Write(const unsigned char* buf, unsigned long bufLen) = 0;
836  virtual int Read(unsigned char* buf, unsigned long bufLen, unsigned long& charsRead) = 0;
837  virtual int Purge() = 0;
838  };
839 
843  class AutoFocus : public Device
844  {
845  public:
846  AutoFocus() {}
847  virtual ~AutoFocus() {}
848 
849  // MMDevice API
850  virtual DeviceType GetType() const { return Type; }
851  static const DeviceType Type;
852 
853  // AutoFocus API
854  virtual int SetContinuousFocusing(bool state) = 0;
855  virtual int GetContinuousFocusing(bool& state) = 0;
856  virtual bool IsContinuousFocusLocked() = 0;
857  virtual int FullFocus() = 0;
858  virtual int IncrementalFocus() = 0;
859  virtual int GetLastFocusScore(double& score) = 0;
860  virtual int GetCurrentFocusScore(double& score) = 0;
861  virtual int AutoSetParameters() = 0;
862  virtual int GetOffset(double &offset) = 0;
863  virtual int SetOffset(double offset) = 0;
864  };
865 
869  class ImageProcessor : public Device
870  {
871  public:
872  ImageProcessor() {}
873  virtual ~ImageProcessor() {}
874 
875  // MMDevice API
876  virtual DeviceType GetType() const { return Type; }
877  static const DeviceType Type;
878 
879  // image processor API
880  virtual int Process(unsigned char* buffer, unsigned width, unsigned height, unsigned byteDepth) = 0;
881 
882 
883  };
884 
888  class SignalIO : public Device
889  {
890  public:
891  SignalIO() {}
892  virtual ~SignalIO() {}
893 
894  // MMDevice API
895  virtual DeviceType GetType() const { return Type; }
896  static const DeviceType Type;
897 
898  // signal io API
899  virtual int SetGateOpen(bool open = true) = 0;
900  virtual int GetGateOpen(bool& open) = 0;
901  virtual int SetSignal(double volts) = 0;
902  virtual int GetSignal(double& volts) = 0;
903  virtual int GetLimits(double& minVolts, double& maxVolts) = 0;
904 
916  virtual int IsDASequenceable(bool& isSequenceable) const = 0;
917 
918  // Sequence functions
919  // Sequences can be used for fast acquisitions, synchronized by TTLs rather than
920  // computer commands.
921  // Sequences of voltages can be uploaded to the DA. The device will cycle through
922  // the uploaded list of voltages (triggered by an external trigger - most often coming
923  // from the camera). If the device is capable (and ready) to do so isSequenceable will
924  // be true. If your device can not execute this simply set isSequenceable to false
930  virtual int GetDASequenceMaxLength(long& nrEvents) const = 0;
936  virtual int StartDASequence() = 0;
941  virtual int StopDASequence() = 0;
950  virtual int ClearDASequence() = 0;
951 
958  virtual int AddToDASequence(double voltage) = 0;
965  virtual int SendDASequence() = 0;
966 
967  };
968 
972  class Magnifier : public Device
973  {
974  public:
975  Magnifier() {}
976  virtual ~Magnifier() {}
977 
978  // MMDevice API
979  virtual DeviceType GetType() const { return Type; }
980  static const DeviceType Type;
981 
982  virtual double GetMagnification() = 0;
983  };
984 
985 
989  class SLM : public Device
990  {
991  public:
992  SLM() {}
993  virtual ~SLM() {}
994 
995  virtual DeviceType GetType() const { return Type; }
996  static const DeviceType Type;
997 
998  // SLM API
1002  virtual int SetImage(unsigned char * pixels) = 0;
1003 
1007  virtual int SetImage(unsigned int * pixels) = 0;
1008 
1012  virtual int DisplayImage() = 0;
1013 
1017  virtual int SetPixelsTo(unsigned char intensity) = 0;
1018 
1022  virtual int SetPixelsTo(unsigned char red, unsigned char green, unsigned char blue) = 0;
1023 
1027  virtual int SetExposure(double interval_ms) = 0;
1028 
1032  virtual double GetExposure() = 0;
1033 
1037  virtual unsigned GetWidth() = 0;
1038 
1042  virtual unsigned GetHeight() = 0;
1043 
1047  virtual unsigned GetNumberOfComponents() = 0;
1048 
1052  virtual unsigned GetBytesPerPixel() = 0;
1053 
1054  // SLM Sequence functions
1055  // Sequences can be used for fast acquisitions, synchronized by TTLs rather than
1056  // computer commands.
1057  // Sequences of images can be uploaded to the SLM. The SLM will cycle through
1058  // the uploaded list of images (perhaps triggered by an external trigger or by
1059  // an internal clock.
1060  // If the device is capable (and ready) to do so IsSLMSequenceable will return
1061  // be true. If your device can not execute sequences, IsSLMSequenceable returns false.
1062 
1073  virtual int IsSLMSequenceable(bool& isSequenceable) const = 0;
1074 
1080  virtual int GetSLMSequenceMaxLength(long& nrEvents) const = 0;
1081 
1087  virtual int StartSLMSequence() = 0;
1088 
1093  virtual int StopSLMSequence() = 0;
1094 
1104  virtual int ClearSLMSequence() = 0;
1105 
1113  virtual int AddToSLMSequence(const unsigned char * const pixels) = 0;
1114 
1122  virtual int AddToSLMSequence(const unsigned int * const pixels) = 0;
1123 
1130  virtual int SendSLMSequence() = 0;
1131 
1132  };
1133 
1137  class Galvo : public Device
1138  {
1139  public:
1140  Galvo() {}
1141  virtual ~Galvo() {}
1142 
1143  virtual DeviceType GetType() const { return Type; }
1144  static const DeviceType Type;
1145 
1146  //Galvo API:
1147 
1153  virtual int PointAndFire(double x, double y, double time_us) = 0;
1154  virtual int SetSpotInterval(double pulseInterval_us) = 0;
1155  virtual int SetPosition(double x, double y) = 0;
1156  virtual int GetPosition(double& x, double& y) = 0;
1157  virtual int SetIlluminationState(bool on) = 0;
1161  virtual double GetXRange() = 0;
1166  virtual double GetXMinimum() = 0;
1170  virtual double GetYRange() = 0;
1175  virtual double GetYMinimum() = 0;
1176  virtual int AddPolygonVertex(int polygonIndex, double x, double y) = 0;
1177  virtual int DeletePolygons() = 0;
1178  virtual int RunSequence() = 0;
1179  virtual int LoadPolygons() = 0;
1180  virtual int SetPolygonRepetitions(int repetitions) = 0;
1181  virtual int RunPolygons() = 0;
1182  virtual int StopSequence() = 0;
1183  virtual int GetChannel(char* channelName) = 0;
1184  };
1185 
1190  class Hub : public Device
1191  {
1192  public:
1193  Hub() {}
1194  virtual ~Hub() {}
1195 
1196  // MMDevice API
1197  virtual DeviceType GetType() const { return Type; }
1198  static const DeviceType Type;
1199 
1212  virtual int DetectInstalledDevices() = 0;
1213 
1222  virtual void ClearInstalledDevices() = 0;
1223 
1230  virtual unsigned GetNumberOfInstalledDevices() = 0;
1231 
1238  virtual Device* GetInstalledDevice(int devIdx) = 0;
1239  };
1240 
1245  class Core
1246  {
1247  public:
1248  Core() {}
1249  virtual ~Core() {}
1250 
1251  virtual int LogMessage(const Device* caller, const char* msg, bool debugOnly) const = 0;
1252  virtual Device* GetDevice(const Device* caller, const char* label) = 0;
1253  virtual int GetDeviceProperty(const char* deviceName, const char* propName, char* value) = 0;
1254  virtual int SetDeviceProperty(const char* deviceName, const char* propName, const char* value) = 0;
1255 
1257 
1265  virtual void GetLoadedDeviceOfType(const Device* caller, MM::DeviceType devType, char* pDeviceName, const unsigned int deviceIterator) = 0;
1266 
1267  virtual int SetSerialProperties(const char* portName,
1268  const char* answerTimeout,
1269  const char* baudRate,
1270  const char* delayBetweenCharsMs,
1271  const char* handshaking,
1272  const char* parity,
1273  const char* stopBits) = 0;
1274  virtual int SetSerialCommand(const Device* caller, const char* portName, const char* command, const char* term) = 0;
1275  virtual int GetSerialAnswer(const Device* caller, const char* portName, unsigned long ansLength, char* answer, const char* term) = 0;
1276  virtual int WriteToSerial(const Device* caller, const char* port, const unsigned char* buf, unsigned long length) = 0;
1277  virtual int ReadFromSerial(const Device* caller, const char* port, unsigned char* buf, unsigned long length, unsigned long& read) = 0;
1278  virtual int PurgeSerial(const Device* caller, const char* portName) = 0;
1279  virtual MM::PortType GetSerialPortType(const char* portName) const = 0;
1280 
1281  virtual int OnPropertiesChanged(const Device* caller) = 0;
1287  virtual int OnPropertyChanged(const Device* caller, const char* propName, const char* propValue) = 0;
1292  virtual int OnStagePositionChanged(const Device* caller, double pos) = 0;
1297  virtual int OnXYStagePositionChanged(const Device* caller, double xPos, double yPos) = 0;
1301  virtual int OnExposureChanged(const Device* caller, double newExposure) = 0;
1305  virtual int OnSLMExposureChanged(const Device* caller, double newExposure) = 0;
1309  virtual int OnMagnifierChanged(const Device* caller) = 0;
1310 
1311  virtual unsigned long GetClockTicksUs(const Device* caller) = 0;
1312  virtual MM::MMTime GetCurrentMMTime() = 0;
1313 
1314  // sequence acquisition
1315  virtual int AcqFinished(const Device* caller, int statusCode) = 0;
1316  virtual int PrepareForAcq(const Device* caller) = 0;
1317  virtual int InsertImage(const Device* caller, const ImgBuffer& buf) = 0;
1318  virtual int InsertImage(const Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, unsigned nComponents, const char* serializedMetadata, const bool doProcess = true) = 0;
1319  virtual int InsertImage(const Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const Metadata* md = 0, const bool doProcess = true) = 0;
1321  virtual int InsertImage(const Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const char* serializedMetadata, const bool doProcess = true) = 0;
1322  virtual void ClearImageBuffer(const Device* caller) = 0;
1323  virtual bool InitializeImageBuffer(unsigned channels, unsigned slices, unsigned int w, unsigned int h, unsigned int pixDepth) = 0;
1325  virtual int InsertMultiChannel(const Device* caller, const unsigned char* buf, unsigned numChannels, unsigned width, unsigned height, unsigned byteDepth, Metadata* md = 0) = 0;
1326 
1327  // autofocus
1328  // TODO This interface needs improvement: the caller pointer should be
1329  // passed, and it should be clarified whether the use of these methods is
1330  // to be limited to autofocus or not. - Mark T.
1331  virtual const char* GetImage() = 0;
1332  virtual int GetImageDimensions(int& width, int& height, int& depth) = 0;
1333  virtual int GetFocusPosition(double& pos) = 0;
1334  virtual int SetFocusPosition(double pos) = 0;
1335  virtual int MoveFocus(double velocity) = 0;
1336  virtual int SetXYPosition(double x, double y) = 0;
1337  virtual int GetXYPosition(double& x, double& y) = 0;
1338  virtual int MoveXYStage(double vX, double vY) = 0;
1339  virtual int SetExposure(double expMs) = 0;
1340  virtual int GetExposure(double& expMs) = 0;
1341  virtual int SetConfig(const char* group, const char* name) = 0;
1342  virtual int GetCurrentConfig(const char* group, int bufLen, char* name) = 0;
1343  virtual int GetChannelConfig(char* channelConfigName, const unsigned int channelConfigIterator) = 0;
1344 
1345  // direct access to specific device types
1346  // TODO With the exception of GetParentHub(), these should be removed in
1347  // favor of methods providing indirect access to the required
1348  // functionality. Eventually we should completely avoid access to raw
1349  // pointers to devices of other device adapters (because we loose
1350  // information on errors, because direct access ignores any
1351  // synchronization implemented in the Core, and because it would be bad
1352  // if device adapters stored the returned pointer). - Mark T.
1353  virtual MM::ImageProcessor* GetImageProcessor(const MM::Device* caller) = 0; // Use not recommended
1354  virtual MM::AutoFocus* GetAutoFocus(const MM::Device* caller) = 0; // Use not recommended
1355 
1356  virtual MM::Hub* GetParentHub(const MM::Device* caller) const = 0;
1357 
1358  virtual MM::State* GetStateDevice(const MM::Device* caller, const char* deviceName) = 0; // Use not recommended
1359  virtual MM::SignalIO* GetSignalIODevice(const MM::Device* caller, const char* deviceName) = 0; // Use not recommended
1360 
1361  // asynchronous error handling
1362  // TODO We do need a framework for handling asynchronous errors, but this
1363  // interface is poorly thought through. I'm working on a better design.
1364  // - Mark T.
1366  MM_DEPRECATED(virtual void NextPostedError(int& /*errorCode*/, char* /*pMessage*/, int /*maxlen*/, int& /*messageLength*/)) = 0;
1368  MM_DEPRECATED(virtual void PostError(const int, const char*)) = 0;
1370  MM_DEPRECATED(virtual void ClearPostedErrors(void)) = 0;
1371  };
1372 
1373 } // namespace MM
1374 
1375 #endif //MMMMDEVICE_H
1376 
Definition: MMDevice.h:609
Definition: MMDevice.h:1245
Definition: MMDevice.h:97
Definition: MMDevice.h:869
Definition: MMDevice.h:709
Definition: MMDevice.h:972
Definition: MMDevice.cpp:18
Definition: MMDevice.h:208
Definition: ImageMetadata.h:282
Definition: ImgBuffer.h:39
Definition: MMDevice.h:241
Definition: MMDevice.h:843
Definition: MMDevice.h:342
Definition: MMDevice.h:1137
Definition: MMDevice.h:989
Definition: MMDevice.h:795
Definition: MMDevice.h:1190
Definition: MMDevice.h:586
Definition: MMDevice.h:352
Definition: MMDevice.h:888
Definition: MMDevice.h:821