2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Runtime.Remoting;
5 using System.Runtime.Remoting.Channels;
6 using System.Runtime.Remoting.Channels.Http;
7 using System.Runtime.Remoting.Channels.Tcp;
8 using Seci.Definitions;
10 [assembly: CLSCompliant(
true)]
12 namespace Seci.Managers
19 private static int _maxLVFileAge = 7;
27 public static Boolean WebDashboardEnabled {
get; set; }
28 public static Boolean WebDashboardShowTitle {
get; set; }
32 public static Boolean IsBusy {
get; set; }
37 public delegate
void ValuesUpdatedEventHandler(Boolean timeout);
52 Status.ReadAppSettings();
54 Status.ExecutionDir = exeDir;
55 Status.ErrorDir = Status.BaseLogDir +
"\\Seci messages\\";
56 Status.ConfigDir = exeDir +
"\\Configurations\\";
57 Status.LabViewErrorDir = Status.BaseLogDir +
"\\LabVIEW messages\\";
58 Status.HelpDir = exeDir +
"\\Help\\";
60 Status.CreateDirectories();
63 clearOutLabViewLogs();
67 _valuesUpdater.OnValuesUpdated +=
new Tools.ValuesUpdater.ValuesUpdatedEventHandler(daeValuesUpdated);
70 _lvmqUpdater.OnChangeToLVMessages +=
new EventHandler(messageQNewLVMessage);
71 _lvmqUpdater.OnLabviewNotThere +=
new EventHandler(messageQLabviewNotThere);
74 enableDotNetRemoting();
75 Seci.Helpers.MessageLogger.WriteMessage(
"SeciGui",
"User started SECI");
77 if (Seci.Definitions.Status.LogToDatabase)
80 Seci.Helpers.DatabaseLogger.StartLogger();
92 DateTime today = DateTime.Today;
93 List<String> validFiles =
new List<String>();
95 for (
int i = 0; i < _maxLVFileAge; ++i)
97 DateTime pastDate = today.Subtract(
new TimeSpan(i, 0, 0, 0));
98 validFiles.Add(pastDate.Day +
" " + pastDate.ToString(
"MMMM") +
" - " + pastDate.DayOfWeek +
".txt");
104 List<FileInfo> filist =
new List<FileInfo>(di.GetFiles(
"*.txt"));
106 foreach (FileInfo fi
in filist)
108 if (!validFiles.Contains(fi.Name))
126 if (Seci.Definitions.Status.LogToDatabase)
128 Seci.Helpers.DatabaseLogger.StopDatabaseLoggerThread();
129 System.Threading.Thread.Sleep(1000);
130 Seci.Helpers.DatabaseLogger.CloseDatabase();
144 if (OnValuesUpdated != null)
146 OnValuesUpdated(timeout);
160 if (OnNewLVMessage != null)
162 OnNewLVMessage(sender, e);
170 if (OnLVNotThere != null)
172 OnLVNotThere(sender, e);
187 IDictionary properties =
new Hashtable();
188 properties.Add(
"port", 8084);
189 properties.Add(
"secure",
true);
190 properties.Add(
"impersonate",
true);
193 TcpServerChannel secureChannel =
new TcpServerChannel(properties, null);
194 ChannelServices.RegisterChannel(secureChannel,
true);
197 RemotingConfiguration.RegisterWellKnownServiceType(typeof(Remoting.ReadWriteRemoting),
"SECISecure.rem", WellKnownObjectMode.Singleton);
201 HttpChannel Channel =
new HttpChannel(8085);
202 ChannelServices.RegisterChannel(Channel,
false);
205 RemotingConfiguration.RegisterWellKnownServiceType(typeof(Remoting.ReadOnlyRemoting),
"SECI.rem", WellKnownObjectMode.Singleton);
226 Standard.MessageQueue.InitialiseMessQVI();
234 Standard.BeamLogger.InitialiseBeamlogger();
237 Standard.BeamlineParameters.Initialise();
238 Standard.SampleParameters.Initialise();
239 Standard.UserDetails.Initialise();
244 Standard.DaeMonitor.Initialise();
261 Standard.Dae.Initialise(Status.LabViewDir + Status.DaeFile);
264 Standard.Dae.RunEnded -=
new Standard.DaeEventHandler(runStartedOrEnded);
265 Standard.Dae.RunEnded +=
new Standard.DaeEventHandler(runStartedOrEnded);
267 Standard.Dae.RunStarted -=
new Seci.Standard.DaeEventHandler(runStartedOrEnded);
268 Standard.Dae.RunStarted +=
new Seci.Standard.DaeEventHandler(runStartedOrEnded);
278 Tools.ValuesUpdater.LogValuesAtStartOrEndRun(time, runNumber);
281 #region Background Threads
288 public static void StartThreads(Boolean startBlockUpdater, Boolean startLVMQUpdater)
290 if (startBlockUpdater)
292 _valuesUpdater.StartUpdater();
293 _valuesUpdaterEnabled =
true;
296 if (startLVMQUpdater)
298 _lvmqUpdater.StartUpdater();
299 _lvmqUpdaterEnabled =
true;
308 if (_valuesUpdaterEnabled)
310 _valuesUpdater.PauseUpdater();
313 if (_lvmqUpdaterEnabled)
315 _lvmqUpdater.PauseUpdater();
324 if (_valuesUpdaterEnabled)
326 _valuesUpdater.ResumeUpdater();
329 if (_lvmqUpdaterEnabled)
331 _lvmqUpdater.ResumeUpdater();
337 Seci.Helpers.DatabaseLogger.ClearQueues();
350 if (
Status.CheckManagerPassword(password))
352 Status.ManagerLoggedIn =
true;
363 if (ClearGraphRequested != null)
365 ClearGraphRequested(null);
static void ClearDatabaseQueues()
This class is used for checking to see if the LabVIEW messages received from the message panel VI hav...
static Boolean InitialiseLabView(Boolean loadStandardVIs)
Initialise LabVIEW and load any default VIs.
static void daeValuesUpdated(Boolean timeout)
This method is run when the ValuesUpdater raises a OnValuesUpdated event. The event is just passed on...
static Boolean enableDotNetRemoting()
Enables Dot Net remoting for web access etc.
static void InitialiseSeci(String exeDir)
Initialises SECI. Needs to be called before SECI does anything else.
static EventHandler OnNewLVMessage
Delegate for passing "new LabVIEW message" event to the GUI level.
static void ResumeThreads()
Resume the ValuesUpdater and LVMQUpdater after pausing.
Class for holding the standard run-time settings for SECI. A large percentage of the information held...
static String LabViewErrorDir
static Boolean LogInAsManager(String password)
Method for logging in as manager. Tests password against that of the manager account and returns true...
static Boolean _lvmqUpdaterEnabled
static Tools.ValuesUpdater _valuesUpdater
static String ExecutionDir
static void clearOutLabViewLogs()
This clears out any logfiles that are older than a certain amount
static void initialiseDae()
Initialise the DAE. This loads the DAE VI and starts it running. Also adds a event handler for watchi...
static void messageQLabviewNotThere(object sender, EventArgs e)
static Boolean _valuesUpdaterEnabled
static void CloseSeci()
Closes SECI by making sure everything is closed etc.
static ValuesUpdatedEventHandler OnValuesUpdated
static EventHandler OnLVNotThere
delegate void RemotingEventHandler(String[] vars)
This delegate handles any events that come in via the remoting interface that need to be handled by t...
A general manager class for SECI. Contains the stuff that does not fit into any of the other manager ...
static void messageQNewLVMessage(object sender, EventArgs e)
This method is run when the LVMQUpdater raises a OnNewLVMessage event. The event is just passed on to...
static void StartThreads(Boolean startBlockUpdater, Boolean startLVMQUpdater)
Start the ValuesUpdater and LVMQUpdater running.
static void PauseThreads()
Pause the ValuesUpdater and LVMQUpdater.
static void runStartedOrEnded(DateTime time, string runNumber)
Logs the block values at the start or end of the run.
static LabView.LvmqUpdater _lvmqUpdater
static RemotingEventHandler ClearGraphRequested
static void ClearGraphs()
static Boolean UseDaeMonitorVI