MMCore  1.4
CoreCallback.h
1 // FILE: CoreCallback.h
3 // PROJECT: Micro-Manager
4 // SUBSYSTEM: MMCore
5 //-----------------------------------------------------------------------------
6 // DESCRIPTION: Callback object for MMCore device interface. Encapsulates
7 // (bottom) internal API for calls going from devices to the
8 // core.
9 //
10 // AUTHOR: Nenad Amodaj, nenad@amodaj.com, 01/23/2006
11 
12 // COPYRIGHT: University of California, San Francisco, 2006-2014
13 //
14 // LICENSE: This file is distributed under the "Lesser GPL" (LGPL) 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 #ifndef _CORECALLBACK_H_
26 #define _CORECALLBACK_H_
27 
28 #include "Devices/DeviceInstances.h"
29 #include "CoreUtils.h"
30 #include "MMCore.h"
31 #include "MMEventCallback.h"
32 #include "../MMDevice/DeviceUtils.h"
33 
34 namespace mm
35 {
36  class DeviceManager;
37 }
38 
39 
41 // CoreCallback class
42 // ------------------
43 
44 class CoreCallback : public MM::Core
45 {
46 public:
48  ~CoreCallback();
49 
50  int GetDeviceProperty(const char* deviceName, const char* propName, char* value);
51  int SetDeviceProperty(const char* deviceName, const char* propName, const char* value);
52 
56  int LogMessage(const MM::Device* caller, const char* msg,
57  bool debugOnly) const;
58 
62  MM::Device* GetDevice(const MM::Device* caller, const char* label);
63 
64  MM::PortType GetSerialPortType(const char* portName) const;
65 
66  int SetSerialProperties(const char* portName,
67  const char* answerTimeout,
68  const char* baudRate,
69  const char* delayBetweenCharsMs,
70  const char* handshaking,
71  const char* parity,
72  const char* stopBits);
73 
74  int WriteToSerial(const MM::Device* caller, const char* portName, const unsigned char* buf, unsigned long length);
75  int ReadFromSerial(const MM::Device* caller, const char* portName, unsigned char* buf, unsigned long bufLength, unsigned long &bytesRead);
76  int PurgeSerial(const MM::Device* caller, const char* portName);
77  int SetSerialCommand(const MM::Device*, const char* portName, const char* command, const char* term);
78  int GetSerialAnswer(const MM::Device*, const char* portName, unsigned long ansLength, char* answerTxt, const char* term);
79 
80  unsigned long GetClockTicksUs(const MM::Device* caller);
81 
82  // MMTime, in epoch beginning at 2000 01 01
83  MM::MMTime GetCurrentMMTime();
84 
85  void Sleep(const MM::Device* caller, double intervalMs);
86 
87  // continuous acquisition support
88  int InsertImage(const MM::Device* caller, const ImgBuffer& imgBuf); // Note: _not_ mm::ImgBuffer
89  int InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const char* serializedMetadata, const bool doProcess = true);
90  int InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, unsigned nComponents, const char* serializedMetadata, const bool doProcess = true);
91 
92  /*Deprecated*/ int InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const Metadata* pMd = 0, const bool doProcess = true);
93  /*Deprecated*/ int InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, unsigned nComponents, const Metadata* pMd = 0, const bool doProcess = true);
94 
95  /*Deprecated*/ int InsertMultiChannel(const MM::Device* caller, const unsigned char* buf, unsigned numChannels, unsigned width, unsigned height, unsigned byteDepth, Metadata* pMd = 0);
96  void ClearImageBuffer(const MM::Device* caller);
97  bool InitializeImageBuffer(unsigned channels, unsigned slices, unsigned int w, unsigned int h, unsigned int pixDepth);
98 
99  int AcqFinished(const MM::Device* caller, int statusCode);
100  int PrepareForAcq(const MM::Device* caller);
101 
102  // autofocus support
103  const char* GetImage();
104  int GetImageDimensions(int& width, int& height, int& depth);
105  int GetFocusPosition(double& pos);
106  int SetFocusPosition(double pos);
107  int MoveFocus(double v);
108  int SetXYPosition(double x, double y);
109  int GetXYPosition(double& x, double& y);
110  int MoveXYStage(double vX, double vY);
111  int SetExposure(double expMs);
112  int GetExposure(double& expMs);
113  int SetConfig(const char* group, const char* name);
114  int GetCurrentConfig(const char* group, int bufLen, char* name);
115  int GetChannelConfig(char* channelConfigName, const unsigned int channelConfigIterator);
116 
117  // notification handlers
118  int OnPropertiesChanged(const MM::Device* caller);
119  int OnPropertyChanged(const MM::Device* device, const char* propName, const char* value);
120  int OnStagePositionChanged(const MM::Device* device, double pos);
121  int OnXYStagePositionChanged(const MM::Device* device, double xpos, double ypos);
122  int OnExposureChanged(const MM::Device* device, double newExposure);
123  int OnSLMExposureChanged(const MM::Device* device, double newExposure);
124  int OnMagnifierChanged(const MM::Device* device);
125 
126 
127  void NextPostedError(int& errorCode, char* pMessage, int maxlen, int& messageLength);
128  void PostError(const int errorCode, const char* pMessage);
129  void ClearPostedErrors();
130 
131 
132  MM::ImageProcessor* GetImageProcessor(const MM::Device* caller);
133  MM::State* GetStateDevice(const MM::Device* caller, const char* label);
134  MM::SignalIO* GetSignalIODevice(const MM::Device* caller,
135  const char* label);
136  MM::AutoFocus* GetAutoFocus(const MM::Device* caller);
137  MM::Hub* GetParentHub(const MM::Device* caller) const;
138  void GetLoadedDeviceOfType(const MM::Device* caller, MM::DeviceType devType,
139  char* deviceName, const unsigned int deviceIterator);
140 
141 private:
142  CMMCore* core_;
143  MMThreadLock* pValueChangeLock_;
144 
145  Metadata AddCameraMetadata(const MM::Device* caller, const Metadata* pMd);
146 
147  int OnConfigGroupChanged(const char* groupName, const char* newConfigName);
148  int OnPixelSizeChanged(double newPixelSizeUm);
149  int OnPixelSizeAffineChanged(std::vector<double> newPixelSizeAffine);
150 };
151 
152 #endif // _CORECALLBACK_H_
Definition: CoreCallback.h:34
The Micro-Manager Core.
Definition: MMCore.h:127
Definition: CoreCallback.h:44