2using System.Collections.Generic;
6using System.Threading.Tasks;
7using System.Diagnostics;
8using System.Windows.Forms;
18 public static string run_cmd(
string cmd,
string args)
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;
28 using (Process process = Process.Start(start))
30 using (StreamReader reader = process.StandardOutput)
32 res = reader.ReadToEnd();
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;
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;
70 string s =
run_cmd(
"initialize.py", Properties.Settings.Default.PStage);
71 if (!s.Contains(
"OK"))
78 string s =
run_cmd(
"setstagexyz.py", Properties.Settings.Default.PStage +
" " + p.X +
" " + p.Y +
" " + p.Z);
90 string s =
run_cmd(
"setstagexy.py", Properties.Settings.Default.PStage +
" " + p.X +
" " + p.Y);
106 string s =
run_cmd(
"getstagexyz.py", Properties.Settings.Default.PStage);
107 if (s.Contains(
"OK"))
109 string[] sts = s.Split();
110 p =
new Point3D(
double.Parse(sts[0]),
double.Parse(sts[2]),
double.Parse(sts[4]));
127 string s =
run_cmd(
"getstagexy.py", Properties.Settings.Default.PStage);
128 if (s.Contains(
"OK"))
130 string[] sts = s.Split();
131 p =
new PointD(
double.Parse(sts[0]),
double.Parse(sts[2]));
143 string s =
run_cmd(
"setfilterwheel.py", Properties.Settings.Default.PFilterWheel +
" " + p);
144 if (s.Contains(
"OK"))
151 string s =
run_cmd(
"getfilterwheel.py", Properties.Settings.Default.PFilterWheel);
152 if (s.Contains(
"OK"))
154 string[] sts = s.Split();
155 p =
int.Parse(sts[2]);
166 string s =
run_cmd(
"takeimage.py", path);
167 if (s.Contains(
"OK"))
174 string s =
run_cmd(
"setexposure.py", f.ToString());
175 if (s.Contains(
"OK"))
180 public bool GetSize(out
int width, out
int height)
182 string s =
run_cmd(
"getcamrect.py",Properties.Settings.Default.PCamera);
185 if (!s.Contains(
"OK"))
187 string[] sts = s.Split();
188 width =
int.Parse(sts[0]);
189 height =
int.Parse(sts[2]);
System.Windows.Forms.Application Application
static Process deviceServer
bool GetFilterWheelPosition(out int p)
bool TakeImage(string path)
bool GetPosition3D(out Point3D p, bool update)
bool SetPosition(PointD p)
bool GetPosition(out PointD p, bool update)
static void StartCommand(string cmd, string args)
bool SetExposure(float f)
bool SetPosition(Point3D p)
bool GetSize(out int width, out int height)
bool SetFilterWheelPosition(int p)
static string run_cmd(string cmd, string args)