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.Scripting.Script Class Reference

Public Member Functions

 Script (string file, string scriptStr)
 
 Script (string file)
 
void Run ()
 It creates a new thread and starts it. More...
 
void Stop ()
 The function stops the thread. More...
 
override string ToString ()
 

Static Public Member Functions

static void Run (Script rn)
 
static object RunString (string st)
 

Public Attributes

string name
 
string file
 
string scriptString
 
dynamic script
 
object obj
 
string output = ""
 
bool done = false
 
Exception ex = null
 
Thread thread
 
ScriptType type = ScriptType.script
 

Static Public Attributes

static List< string > usings = new List<string>()
 

Detailed Description

Definition at line 16 of file Scripting.cs.

Constructor & Destructor Documentation

◆ Script() [1/2]

BioImager.Scripting.Script.Script ( string  file,
string  scriptStr 
)

Definition at line 30 of file Scripting.cs.

31 {
32 name = Path.GetFileName(file);
33 scriptString = scriptStr;
34 if (file.EndsWith(".txt") || file.EndsWith(".ijm"))
35 type = ScriptType.imagej;
36 }

◆ Script() [2/2]

BioImager.Scripting.Script.Script ( string  file)

Definition at line 39 of file Scripting.cs.

40 {
41 name = Path.GetFileName(file);
42 scriptString = File.ReadAllText(file);
43 this.file = file;
44 if (file.EndsWith(".txt") || file.EndsWith(".ijm"))
45 type = ScriptType.imagej;
46 }

Member Function Documentation

◆ Run() [1/2]

void BioImager.Scripting.Script.Run ( )

It creates a new thread and starts it.

Definition at line 133 of file Scripting.cs.

134 {
135 if (!Scripts.ContainsKey(name))
136 Scripts.Add(name, this);
137 scriptName = this.name;
138 thread = new Thread(new ThreadStart(RunScript));
139 thread.Start();
140 }

◆ Run() [2/2]

static void BioImager.Scripting.Script.Run ( Script  rn)
static

It creates a new thread and starts it.

The thread is started by calling the RunScript function.

Definition at line 51 of file Scripting.cs.

52 {
53 scriptName = rn.name;
54 Thread t = new Thread(new ThreadStart(RunScript));
55 t.Start();
56 }

Referenced by BioImager.Scripting.Run().

◆ RunString()

static object BioImager.Scripting.Script.RunString ( string  st)
static

It takes a string, adds a bunch of using statements, wraps the string in a class, and then compiles and runs the class

Parameters
stThe string to be executed
Returns
The return value of the last statement in the script.

Definition at line 99 of file Scripting.cs.

100 {
101 try
102 {
103 string loader =
104 @"//css_reference " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + @".dll
105 using System;
106 using System.Windows.Forms;
107 using System.Drawing;
108 using System.Threading;
109 using Bio;";
110 foreach (string s in usings)
111 {
112 loader += usings + Environment.NewLine;
113 }
114 loader += @"
115 public class Loader
116 {
117 public object Load()
118 {" +
119 st + @";
120 return true;
121 }
122 }";
123 dynamic script = CSScript.Evaluator.LoadCode(loader);
124 return script.Load();
125 }
126 catch (Exception e)
127 {
128 MessageBox.Show(e.Message, e.Source);
129 return e;
130 }
131 }

Referenced by BioImager.Scripting.RunString().

◆ Stop()

void BioImager.Scripting.Script.Stop ( )

The function stops the thread.

Definition at line 142 of file Scripting.cs.

143 {
144 if (thread != null)
145 thread.Abort();
146 }

Referenced by BioImager.Scripting.Stop().

◆ ToString()

override string BioImager.Scripting.Script.ToString ( )

If the thread is not null, return the name and the thread state. Otherwise, return the name

Returns
The name of the thread and the state of the thread.

Definition at line 151 of file Scripting.cs.

152 {
153 if (thread != null)
154 {
155 return name.ToString() + ", " + thread.ThreadState.ToString();
156 }
157 else
158 return name.ToString();
159 }

Referenced by BioImager.Scripting.RefreshItems(), and BioImager.Scripting.RefreshStatus().

Member Data Documentation

◆ done

bool BioImager.Scripting.Script.done = false

Definition at line 24 of file Scripting.cs.

◆ ex

Exception BioImager.Scripting.Script.ex = null

Definition at line 26 of file Scripting.cs.

◆ file

string BioImager.Scripting.Script.file

Definition at line 19 of file Scripting.cs.

◆ name

◆ obj

object BioImager.Scripting.Script.obj

Definition at line 22 of file Scripting.cs.

◆ output

string BioImager.Scripting.Script.output = ""

Definition at line 23 of file Scripting.cs.

◆ script

dynamic BioImager.Scripting.Script.script

Definition at line 21 of file Scripting.cs.

◆ scriptString

string BioImager.Scripting.Script.scriptString

Definition at line 20 of file Scripting.cs.

◆ thread

Thread BioImager.Scripting.Script.thread

Definition at line 27 of file Scripting.cs.

◆ type

ScriptType BioImager.Scripting.Script.type = ScriptType.script

Definition at line 28 of file Scripting.cs.

Referenced by microscope.stages.linkam._CommsInfo.view_of_info().

◆ usings

List<string> BioImager.Scripting.Script.usings = new List<string>()
static

Definition at line 25 of file Scripting.cs.


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