-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCoreCallback.h
More file actions
149 lines (119 loc) · 5.82 KB
/
CoreCallback.h
File metadata and controls
149 lines (119 loc) · 5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
///////////////////////////////////////////////////////////////////////////////
// FILE: CoreCallback.h
// PROJECT: Micro-Manager
// SUBSYSTEM: MMCore
//-----------------------------------------------------------------------------
// DESCRIPTION: Callback object for MMCore device interface. Encapsulates
// (bottom) internal API for calls going from devices to the
// core.
//
// AUTHOR: Nenad Amodaj, nenad@amodaj.com, 01/23/2006
// COPYRIGHT: University of California, San Francisco, 2006-2014
//
// LICENSE: This file is distributed under the "Lesser GPL" (LGPL) license.
// License text is included with the source distribution.
//
// This file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
#pragma once
#include "Devices/DeviceInstances.h"
#include "CoreUtils.h"
#include "MMCore.h"
#include "DeviceUtils.h"
#include <chrono>
#include <map>
#include <mutex>
#include <string>
namespace mmcore {
namespace internal {
class DeviceManager;
class SerializedMetadata;
///////////////////////////////////////////////////////////////////////////////
// CoreCallback class
// ------------------
class CoreCallback : public MM::Core
{
public:
CoreCallback(CMMCore* c);
~CoreCallback();
int GetDeviceProperty(const char* deviceName, const char* propName, char* value);
int SetDeviceProperty(const char* deviceName, const char* propName, const char* value);
/**
* Writes a message to the Micro-Manager log file.
*/
int LogMessage(const MM::Device* caller, const char* msg,
bool debugOnly) const;
/**
* Returns a direct pointer to the device with the specified name.
*/
MM::Device* GetDevice(const MM::Device* caller, const char* label);
MM::PortType GetSerialPortType(const char* portName) const;
int SetSerialProperties(const char* portName,
const char* answerTimeout,
const char* baudRate,
const char* delayBetweenCharsMs,
const char* handshaking,
const char* parity,
const char* stopBits);
int WriteToSerial(const MM::Device* caller, const char* portName, const unsigned char* buf, unsigned long length);
int ReadFromSerial(const MM::Device* caller, const char* portName, unsigned char* buf, unsigned long bufLength, unsigned long &bytesRead);
int PurgeSerial(const MM::Device* caller, const char* portName);
int SetSerialCommand(const MM::Device*, const char* portName, const char* command, const char* term);
int GetSerialAnswer(const MM::Device*, const char* portName, unsigned long ansLength, char* answerTxt, const char* term);
/*Deprecated*/ unsigned long GetClockTicksUs(const MM::Device* caller);
MM::MMTime GetCurrentMMTime();
void Sleep(const MM::Device* caller, double intervalMs);
// continuous acquisition support
int InsertImage(const MM::Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytesPerPixel,
const char* serializedMetadata);
int InsertImage(const MM::Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytesPerPixel, unsigned nComponents,
const char* serializedMetadata);
bool InitializeImageBuffer(unsigned channels, unsigned slices, unsigned int w, unsigned int h, unsigned int pixDepth);
int AcqFinished(const MM::Device* caller, int statusCode);
int PrepareForAcq(const MM::Device* caller);
// Deprecated
int GetFocusPosition(double& pos);
// notification handlers
int OnPropertiesChanged(const MM::Device* caller);
int OnPropertyChanged(const MM::Device* device, const char* propName, const char* value);
int OnStagePositionChanged(const MM::Device* device, double pos);
int OnXYStagePositionChanged(const MM::Device* device, double xpos, double ypos);
int OnExposureChanged(const MM::Device* device, double newExposure);
int OnSLMExposureChanged(const MM::Device* device, double newExposure);
int OnMagnifierChanged(const MM::Device* device);
int OnShutterOpenChanged(const MM::Device* device, bool open);
// Deprecated
MM::SignalIO* GetSignalIODevice(const MM::Device* caller,
const char* label);
MM::Hub* GetParentHub(const MM::Device* caller) const;
void GetLoadedDeviceOfType(const MM::Device* caller, MM::DeviceType devType,
char* deviceName, const unsigned int deviceIterator);
// Reset per-acquisition image-metadata state: per-camera ImageNumber
// counters and the ElapsedTime-ms reference point.
void ResetImageInsertionState();
private:
CMMCore* core_;
// Serializes OnPropertyChanged calls to reduce (but not eliminate)
// races between the state cache update and the subsequent config
// lookups used to determine which notifications to post.
std::mutex onPropertyChangedLock_;
// Guards imageNumbers_ and startTime_.
std::mutex imageInsertionStateMutex_;
std::map<std::string, long> imageNumbers_;
std::chrono::time_point<std::chrono::steady_clock> startTime_;
void AddCameraMetadata(const MM::Device* caller, SerializedMetadata& md);
SerializedMetadata BuildSequenceImageMetadata(const MM::Device* caller,
unsigned width, unsigned height,
unsigned byteDepth, unsigned nComponents,
const char* origSerializedMd);
MM::ImageProcessor* GetImageProcessor(const MM::Device* caller);
};
} // namespace internal
} // namespace mmcore