BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
BioImager.MicroscopeConsole Class Reference

Classes

struct  Command
 

Static Public Member Functions

static void SetStagePosition (PointD p)
 
static Command RunCommand (Command c)
 

Static Public Attributes

static bool synchronous = true
 
static Process console = null
 

Detailed Description

Definition at line 8 of file MicroscopeConsole.cs.

Member Function Documentation

◆ RunCommand()

static Command BioImager.MicroscopeConsole.RunCommand ( Command c)
static

Definition at line 78 of file MicroscopeConsole.cs.

79 {
80 Process[] prs = Process.GetProcessesByName("MicroscopeConsole.exe");
81 if (prs.Length == 1)
82 console = prs[0];
83 if (console == null)
84 {
85 Start();
86 }
87 if (c.type.ToString().StartsWith("Get"))
88 {
89 string arg = JsonConvert.SerializeObject(c);
90 console.StandardInput.WriteLine("Command:" + arg);
91 A:
92 try
93 {
94 do
95 {
96 if (console.HasExited)
97 break;
98 string st = console.StandardOutput.ReadLine();
99 if(st != null)
100 if (st.Length > 0)
101 {
102 return JsonConvert.DeserializeObject<Command>(st);
103 }
104 Thread.Sleep(20);
105 } while (true);
106 }
107 catch (Exception e)
108 {
109 Console.WriteLine(e.Message);
110 goto A;
111 }
112
113 string er = console.StandardError.ReadToEnd();
114 string o = console.StandardOutput.ReadToEnd();
115 Console.WriteLine(er);
116 console = null;
117 return new Command();
118 }
119 else
120 {
121 string arg = JsonConvert.SerializeObject(c);
122 console.StandardInput.WriteLine("Command:" + arg);
123 if (synchronous)
124 {
125 //Now we need to wait till the command is finished.
126 do
127 {
128 if (console.HasExited)
129 break;
130 string st = console.StandardOutput.ReadLine();
131 if (st != null)
132 if (st.Length > 0)
133 {
134 return JsonConvert.DeserializeObject<Command>(st);
135 }
136 Application.DoEvents();
137 } while (true);
138 }
139 return new Command();
140 }
141 }
System.Windows.Forms.Application Application
Definition ImageView.cs:14

◆ SetStagePosition()

static void BioImager.MicroscopeConsole.SetStagePosition ( PointD p)
static

Definition at line 57 of file MicroscopeConsole.cs.

58 {
59 RunCommand(new Command(Command.Type.SetStage, new double[] { p.X, p.Y }));
60 }
static Command RunCommand(Command c)

Member Data Documentation

◆ console

Process BioImager.MicroscopeConsole.console = null
static

Definition at line 11 of file MicroscopeConsole.cs.

◆ synchronous

bool BioImager.MicroscopeConsole.synchronous = true
static

Definition at line 10 of file MicroscopeConsole.cs.


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