2 using System.Collections.Generic;
3 using System.ComponentModel;
7 using System.Windows.Forms;
9 using System.Collections;
11 using System.Runtime.Remoting;
12 using System.Runtime.Remoting.Channels;
13 using System.Runtime.Remoting.Channels.Tcp;
14 using System.Runtime.Remoting.Channels.Http;
15 using System.Threading;
17 namespace Sample_Environment_Control_Interface
22 private Seci.SerialisableList<Seci.LabView.MessageInfo>
_lvErrorMessages =
new Seci.SerialisableList<Seci.LabView.MessageInfo>();
39 #region "GUI Constructor, initialisation and closing"
43 GeneralSplashScreen.ShowSplashScreen(
"The Sample Environment Control Interface is loading...");
50 IntPtr dummyHandle = _errorForm.Handle;
53 GuiSettings.LoadSettings();
59 Seci.SeciInterface.Initialise(Environment.CurrentDirectory);
62 _errorForm.lvErrors.QuestionAsked +=
new Dialogs.Messages.LabView_Errors.QuestionHandler(
Pause_Timers);
63 _errorForm.lvErrors.QuestionAnswered +=
new Dialogs.Messages.LabView_Errors.QuestionHandler(
Resume_Timers);
66 toolStripStatusLabel.Text =
"";
74 Object[] args = { vars[0],
false };
88 showHideDAEMonitorToolStripMenuItem.Visible = Seci.SeciInterface.SeciStatus.UseDaeMonitorVi;
91 Seci.SeciInterface.LV_Initialise(
true);
99 GeneralSplashScreen.CloseForm();
105 this.DialogResult = DialogResult.Cancel;
111 Seci.SeciInterface.OpenGenie_Start();
113 Seci.SeciInterface.Messages_LogMessage(
"SeciGui",
"SECI started");
115 if (Sample_Environment_Control_Interface.Properties.Settings.Default.Crashed)
117 if (MessageBox.Show(
"SECI closed unexpectedly, do you wish to recover the last setup?",
"Crash Recovery", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
119 Seci.SeciInterface.Messages_LogMessage(
"SeciGui",
"Recovering last setup.");
120 OpenConfig(Seci.SeciInterface.SeciStatus.ConfigDir +
"autosave",
true);
121 Properties.Settings.Default.Crashed =
false;
122 Properties.Settings.Default.Save();
130 System.Diagnostics.Process[] procList;
132 procList = System.Diagnostics.Process.GetProcessesByName(
"LabView");
134 if (procList.GetLength(0) > 0)
136 if (MessageBox.Show(
"It appears that LabVIEW is running - SECI cannot start if LabVIEW is already running.\n\nWould you like SECI to close LabVIEW and continue loading? \n\nNote: any unsaved changes to VI's will be lost.",
"LabVIEW Running!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
160 if (this.DialogResult != DialogResult.Cancel && Properties.Settings.Default.Crashed !=
true)
162 if (
_changesMade || Seci.SeciInterface.Assoc_AnyModifications())
164 if (MessageBox.Show(
"There are unsaved changes to the configuration. Are you sure you wish to close SECI?",
"Unsaved Changes!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
172 if (MessageBox.Show(
"Close SECI?",
"Close?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
187 Seci.SeciInterface.Configuration_Close();
189 Seci.SeciInterface.Messages_LogMessage(
"SeciGui",
"User closed SECI");
207 Seci.SeciInterface.Threads_Start(
true,
true);
221 catch (Exception err)
223 WriteError(
"SeciInterface_OnNewLVMessage", err);
236 catch (Exception err)
238 WriteError(
"SeciInterface_ValuesUpdated", err);
244 Seci.SeciInterface.Threads_Pause();
247 System.Threading.Thread.Sleep(1000);
252 Seci.SeciInterface.Threads_Resume();
257 #region "Background Save"
261 if (Seci.SeciInterface.IsAComponent)
263 Seci.SeciInterface.Configuration_Save(
_manager,
false);
267 Seci.SeciInterface.Configuration_Save(
_manager,
false);
270 _currentLayout.Save(Seci.SeciInterface.SeciStatus.ConfigDir + Seci.SeciInterface.ConfigurationName +
".lay");
276 toolStripStatusLabel.Text =
"";
284 Seci.SeciInterface.Configuration_Save(
true,
true);
286 if (!Seci.SeciInterface.IsAComponent)
289 _currentLayout.Save(Seci.SeciInterface.SeciStatus.ConfigDir +
"autosave.lay");
293 FileInfo fi =
new FileInfo(Seci.SeciInterface.SeciStatus.ConfigDir +
"autosave.lay");
300 catch (Exception err)
308 #region "Write to Error log"
313 Seci.SeciInterface.Error_LogError(source, e);
314 _errorForm.addSeciMessage(DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), source, e.Message);
324 MainDashboard.UpdateControl();
325 Standard_RunInfo.UpdateControl();
328 _currentLayout.UpdateGUIvalues();
337 Boolean question =
false;
338 Boolean error =
false;
341 for (
int i = 0; i < _lvErrorMessages.Count; ++i)
357 toolStripQuestionLabel.Visible =
true;
361 toolStripQuestionLabel.Visible =
false;
366 toolStripErrorLabel.Visible =
true;
370 toolStripErrorLabel.Visible =
false;
384 statusStrip1.BringToFront();
389 Dialogs.Config.LoadPreviousVersion v =
new Sample_Environment_Control_Interface.Dialogs.Config.LoadPreviousVersion();
391 if (v.ShowDialog() == DialogResult.OK)
397 GeneralSplashScreen.ShowSplashScreen(
"Opening Configuration...");
399 GeneralSplashScreen.CloseForm();
400 MessageBox.Show(
"Previous version successfully loaded. Note: saving this configuration will overwrite the most recent version.",
"Loaded Previous Version", MessageBoxButtons.OK, MessageBoxIcon.Information);
402 catch (Exception err)
404 MessageBox.Show(
"Failed to open configuration/component!\nError message was: " + err.Message,
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
406 GeneralSplashScreen.CloseForm();
void backgroundSave_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
void backgroundSave_DoWork(object sender, DoWorkEventArgs e)
Seci.SerialisableList< Seci.LabView.MessageInfo > _lvErrorMessages
void OpenConfig(String filename, Boolean checkVIs)
void Form1_FormClosing(object sender, FormClosingEventArgs e)
void WriteError(String source, Exception e)
void toolStripLabel_DoubleClick(object sender, EventArgs e)
void setupGuiForSeciStartup()
static GUILayout _currentLayout
void SeciInterface_ValuesUpdated(object sender, EventArgs e)
static GUILayout CurrentLayout
static void Resume_Timers()
Boolean okayToCloseConfig()
Dialogs.Help.HelpForm help
void loadPreviousVersionToolStripMenuItem_Click(object sender, EventArgs e)
delegate void UpdateGuiDelegate()
delegate void OpenConfigRemotelyDelegate(String filename, Boolean checkVIs)
static void Pause_Timers()
void Form1_Load(object sender, EventArgs e)
void Interface_ConfigChangeRequested(string[] vars)
void backgroundAutosave_DoWork(object sender, DoWorkEventArgs e)
static Dialogs.Messages.SeciMessages _errorForm
void SeciInterface_OnNewLVMessage(object sender, EventArgs e)
static Dialogs.Messages.SeciMessages errorForm
void InitializeComponent()
Required method for Designer support - do not modify the contents of this method with the code editor...
void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)