BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
BioImager.PMicroscope Class Reference

Public Member Functions

bool Initialize ()
 
bool SetPosition (Point3D p)
 
bool SetPosition (PointD p)
 
bool GetPosition3D (out Point3D p, bool update)
 
bool GetPosition (out PointD p, bool update)
 
bool SetFilterWheelPosition (int p)
 
bool GetFilterWheelPosition (out int p)
 
bool TakeImage (string path)
 
bool SetExposure (float f)
 
bool GetSize (out int width, out int height)
 

Static Public Member Functions

static string run_cmd (string cmd, string args)
 
static void StartCommand (string cmd, string args)
 
static void Start ()
 
static void Stop ()
 

Static Public Attributes

static Process deviceServer
 
static PointD location
 
static double focus
 

Detailed Description

Definition at line 13 of file PythonMicroscope.cs.

Member Function Documentation

◆ GetFilterWheelPosition()

bool BioImager.PMicroscope.GetFilterWheelPosition ( out int  p)

Definition at line 149 of file PythonMicroscope.cs.

150 {
151 string s = run_cmd("getfilterwheel.py", Properties.Settings.Default.PFilterWheel);
152 if (s.Contains("OK"))
153 {
154 string[] sts = s.Split();
155 p = int.Parse(sts[2]);
156 return true;
157 }
158 else
159 {
160 p = -1;
161 return false;
162 }
163 }

◆ GetPosition()

bool BioImager.PMicroscope.GetPosition ( out PointD  p,
bool  update 
)

Definition at line 120 of file PythonMicroscope.cs.

121 {
122 if (!update)
123 {
124 p = location;
125 return true;
126 }
127 string s = run_cmd("getstagexy.py", Properties.Settings.Default.PStage);
128 if (s.Contains("OK"))
129 {
130 string[] sts = s.Split();
131 p = new PointD(double.Parse(sts[0]), double.Parse(sts[2]));
132 location = p;
133 return true;
134 }
135 else
136 {
137 p = new PointD();
138 return false;
139 }
140 }

◆ GetPosition3D()

bool BioImager.PMicroscope.GetPosition3D ( out Point3D  p,
bool  update 
)

Definition at line 99 of file PythonMicroscope.cs.

100 {
101 if(!update)
102 {
103 p = new Point3D(location.X, location.Y, focus);
104 return true;
105 }
106 string s = run_cmd("getstagexyz.py", Properties.Settings.Default.PStage);
107 if (s.Contains("OK"))
108 {
109 string[] sts = s.Split();
110 p = new Point3D(double.Parse(sts[0]), double.Parse(sts[2]), double.Parse(sts[4]));
111 focus = p.Z;
112 return true;
113 }
114 else
115 {
116 p = new Point3D();
117 return false;
118 }
119 }

◆ GetSize()

bool BioImager.PMicroscope.GetSize ( out int  width,
out int  height 
)

Definition at line 180 of file PythonMicroscope.cs.

181 {
182 string s = run_cmd("getcamrect.py",Properties.Settings.Default.PCamera);
183 width = 0;
184 height = 0;
185 if (!s.Contains("OK"))
186 return false;
187 string[] sts = s.Split();
188 width = int.Parse(sts[0]);
189 height = int.Parse(sts[2]);
190 return true;
191 }

◆ Initialize()

bool BioImager.PMicroscope.Initialize ( )

Definition at line 66 of file PythonMicroscope.cs.

67 {
68 //We start the device server
69 Start();
70 string s = run_cmd("initialize.py", Properties.Settings.Default.PStage);
71 if (!s.Contains("OK"))
72 return false;
73 return true;
74 }

◆ run_cmd()

static string BioImager.PMicroscope.run_cmd ( string  cmd,
string  args 
)
static

Definition at line 18 of file PythonMicroscope.cs.

19 {
20 ProcessStartInfo start = new ProcessStartInfo();
21 start.FileName = "python.exe";
22 start.Arguments = string.Format("{0} {1}", cmd, args);
23 start.WorkingDirectory = Application.StartupPath + "/PythonMicroscope/microscope";
24 start.UseShellExecute = false;
25 start.RedirectStandardOutput = true;
26 start.CreateNoWindow = true;
27 string res;
28 using (Process process = Process.Start(start))
29 {
30 using (StreamReader reader = process.StandardOutput)
31 {
32 res = reader.ReadToEnd();
33 Console.Write(res);
34 }
35 }
36 Application.DoEvents();
37 return res;
38 }

◆ SetExposure()

bool BioImager.PMicroscope.SetExposure ( float  f)

Definition at line 172 of file PythonMicroscope.cs.

173 {
174 string s = run_cmd("setexposure.py", f.ToString());
175 if (s.Contains("OK"))
176 return true;
177 else
178 return false;
179 }

◆ SetFilterWheelPosition()

bool BioImager.PMicroscope.SetFilterWheelPosition ( int  p)

Definition at line 141 of file PythonMicroscope.cs.

142 {
143 string s = run_cmd("setfilterwheel.py", Properties.Settings.Default.PFilterWheel + " " + p);
144 if (s.Contains("OK"))
145 return true;
146 else
147 return false;
148 }

◆ SetPosition() [1/2]

bool BioImager.PMicroscope.SetPosition ( Point3D  p)

Definition at line 76 of file PythonMicroscope.cs.

77 {
78 string s = run_cmd("setstagexyz.py", Properties.Settings.Default.PStage + " " + p.X + " " + p.Y + " " + p.Z);
79 if (s.Contains("OK"))
80 {
81 focus = p.Z;
82 location = new PointD(p.X, p.Y);
83 return true;
84 }
85 else
86 return false;
87 }

◆ SetPosition() [2/2]

bool BioImager.PMicroscope.SetPosition ( PointD  p)

Definition at line 88 of file PythonMicroscope.cs.

89 {
90 string s = run_cmd("setstagexy.py", Properties.Settings.Default.PStage + " " + p.X + " " + p.Y);
91 if (s.Contains("OK"))
92 {
93 location = p;
94 return true;
95 }
96 else
97 return false;
98 }

◆ Start()

static void BioImager.PMicroscope.Start ( )
static

Definition at line 49 of file PythonMicroscope.cs.

50 {
51 ProcessStartInfo start = new ProcessStartInfo();
52 start.FileName = "python.exe";
53 start.Arguments = string.Format("{0} {1}", "device_server.py", "config.txt");
54 start.WorkingDirectory = Application.StartupPath + "/PythonMicroscope/microscope";
55 start.UseShellExecute = false;
56 start.RedirectStandardOutput = false;
57 start.CreateNoWindow = false;
58 deviceServer = Process.Start(start);
59 }

◆ StartCommand()

static void BioImager.PMicroscope.StartCommand ( string  cmd,
string  args 
)
static

Definition at line 39 of file PythonMicroscope.cs.

40 {
41 ProcessStartInfo start = new ProcessStartInfo();
42 start.FileName = "python.exe";
43 start.Arguments = string.Format("{0} {1}", cmd, args);
44 start.WorkingDirectory = Application.StartupPath + "/PythonMicroscope/microscope";
45 start.UseShellExecute = false;
46 start.RedirectStandardOutput = true;
47 start.CreateNoWindow = false;
48 }

◆ Stop()

static void BioImager.PMicroscope.Stop ( )
static

Definition at line 60 of file PythonMicroscope.cs.

61 {
62 if(deviceServer!=null)
63 if(!deviceServer.HasExited)
64 deviceServer.Kill();
65 }

◆ TakeImage()

bool BioImager.PMicroscope.TakeImage ( string  path)

Definition at line 164 of file PythonMicroscope.cs.

165 {
166 string s = run_cmd("takeimage.py", path);
167 if (s.Contains("OK"))
168 return true;
169 else
170 return false;
171 }

Member Data Documentation

◆ deviceServer

Process BioImager.PMicroscope.deviceServer
static

Definition at line 15 of file PythonMicroscope.cs.

◆ focus

double BioImager.PMicroscope.focus
static

Definition at line 17 of file PythonMicroscope.cs.

◆ location

PointD BioImager.PMicroscope.location
static

Definition at line 16 of file PythonMicroscope.cs.


The documentation for this class was generated from the following file: