SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
Status.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.IO;
5 
6 namespace Seci.Definitions
7 {
12  public static class Status
13  {
14  //Members
15  private static Boolean _managerLoggedIn;
16  private static String _instrument;
17  private static String _shortInstrument;
18  private static Boolean _isTS2Instrument;
19 
20  //File info
21  private static String _labViewDir;
22  private static String _labViewIniFilePath;
23  private static String _executionDir;
24  private static String _errorDir;
25  private static String _labViewErrorDir; //Directory for the LabVIEW messages to be logged
26  private static String _configDir;
27  private static String _helpDir;
28  private static String _daeFile;
29  private static String _messagePanelVI;
30  private static String _beamLoggerVI;
31  private static String _daeMonitorVI;
32  private static String _sampleParametersVI;
33  private static String _beamlineParametersVI;
34  private static String _userDetailsVI;
35  private static String _openGenieLocation;
36  private static String _rbfinderLocation;
37  private static String _rbDataFilepath;
38 
39  //Settings
40  private static int _blockUpdateRate;
41  private static Boolean _usingNewDae;
42  private static String[] _nexusGroups;
43  private static Boolean _useDaeMonitorVI;
44  private static Boolean _isMuonInstrument;
45  private static String _managerPassword;
46  private static String _beamStatusWebpage;
47  private static String _ts1StatusWebpage;
48  private static String _ts2StatusWebpage;
49  private static String _mcrNewsWebpage;
50  private static String _bugzillaWebpage;
51  private static String _genieWebpage;
52  private static Boolean _delayStartup;
53  private static int _maxNumberPlotsPerGraph;
54  private static int _maxNumberGraphs;
55  private static int _maxNumberGenieGraphs;
56  private static Boolean _logToDatabase;
57  private static Boolean _logAllBlocksToSingleFile;
58  private static String _journalLocation;
59  private static String _statusBlockName = "Status";
60  private static String _sampleSheetWebpage;
61  private static String _eraWebpage;
62  private static String _maintenanceWebpage;
63  private static String _LTRWebpage;
64  private static String _InstMonWebpage;
65  private static int _rbDateLeeway;
66  private static Boolean _killIcpOnConfigChange = false;
67  private static Boolean _killIcpOnExit = true;
68  private static String _baseLogDir = @"C:\data\log\";
69  private static Boolean _enableDashboardTitleEdit = true;
70  private static String _pythonPath = "";
71  private static String _pythonArgs = "";
72  private static String _dashboardType = "STANDARD";
73  private static Boolean _autoloadLastConfig = true;
74  private static Boolean _showScriptingPage = true;
75  private static int _viHostRefreshRate = 250;
76  private static Boolean _isPythonAvailable = false;
77 
78  //Properties
79  public static Boolean ManagerLoggedIn { get { return _managerLoggedIn; } set { _managerLoggedIn = value; } }
80  public static String Instrument { get { return _instrument; } }
81  public static String ShortInstrument { get { return _shortInstrument; } }
82  public static Boolean IsTS2Instrument { get { return _isTS2Instrument; } }
83  public static String LabViewDir { get { return _labViewDir; } set { _labViewDir = value; } }
84  public static String LabViewIniFilePath { get { return _labViewIniFilePath; } set { _labViewIniFilePath = value; } }
85  public static String LabViewErrorDir { get { return _labViewErrorDir; } set { _labViewErrorDir = value; } }
86  public static Boolean UsingNewDae { get { return _usingNewDae; } set { _usingNewDae = value; } }
87  public static String ExecutionDir { get { return _executionDir; } set { _executionDir = value; } }
88  public static String ErrorDir { get { return _errorDir; } set { _errorDir = value; } }
89  public static String ConfigDir { get { return _configDir; } set { _configDir = value; } }
90  public static String HelpDir { get { return _helpDir; } set { _helpDir = value; } }
91  public static String DaeFile { get { return _daeFile; } }
92  public static String MessagePanelVI { get { return _messagePanelVI; } }
93  public static String BeamLoggerVI { get { return _beamLoggerVI; } }
94  public static String SampleParametersVI { get { return _sampleParametersVI; } }
95  public static String UserDetailsVI { get { return _userDetailsVI; } }
96  public static String DaeMonitorVI { get { return _daeMonitorVI; } }
97  public static String BeamlineParametersVI { get { return _beamlineParametersVI; } }
98  public static String[] NexusGroups { get { return _nexusGroups; } }
99  public static Boolean UseDaeMonitorVI { get { return _useDaeMonitorVI; } set { _useDaeMonitorVI = value; } }
100  public static Boolean IsMuonInstrument { get { return _isMuonInstrument; } }
101  public static int BlockUpdateRate { get { return _blockUpdateRate; } }
102  public static String OpenGenieLocation { get { return _openGenieLocation; } set { _openGenieLocation = value; } }
103  public static String RBFinderLocation { get { return _rbfinderLocation; } }
104  public static String RBDataFilepath { get { return _rbDataFilepath; } }
105  public static String BeamStatusWebpage { get { return _beamStatusWebpage; } }
106  public static String Ts1StatusWebpage { get { return _ts1StatusWebpage; } }
107  public static String Ts2StatusWebpage { get { return _ts2StatusWebpage; } }
108  public static String McrNewsWebpage { get { return _mcrNewsWebpage; } }
109  public static String BugzillaWebpage { get { return _bugzillaWebpage; } }
110  public static String GenieWebpage { get { return _genieWebpage; } }
111  public static Boolean DelayStartup { get { return _delayStartup; } }
112  public static int MaxNumberPlotsPerGraph { get { return _maxNumberPlotsPerGraph; } }
113  public static int MaxNumberGraphs { get { return _maxNumberGraphs; } }
114  public static int MaxNumberGenieGraphs { get { return _maxNumberGenieGraphs; } }
115  public static Boolean LogToDatabase { get { return _logToDatabase; } }
116  public static Boolean LogAllBlocksToSingleFile { get { return _logAllBlocksToSingleFile; } }
117  public static String JournalLocation { get { return _journalLocation; } }
118  public static String StatusBlockName { get { return _statusBlockName; } }
119  public static String SampleSheetWebpage { get { return _sampleSheetWebpage; } }
120  public static String EraSheetWebpage { get { return _eraWebpage; } }
121  public static int RBDateLeeway { get { return _rbDateLeeway; } }
122  public static Boolean KillIcpOnConfigChange { get { return _killIcpOnConfigChange; } }
123  public static Boolean KillIcpOnExit { get { return _killIcpOnExit; } }
124  public static String BaseLogDir { get { return _baseLogDir; } }
125  public static Boolean EnableDashboardTitleEdit { get { return _enableDashboardTitleEdit; } }
126  public static String PythonPath { get { return _pythonPath; } }
127  public static String PythonArgs { get { return _pythonArgs; } }
128  public static String DashboardType { get { return _dashboardType; } }
129  public static Boolean AutoloadLastConfig { get { return _autoloadLastConfig; } }
130  public static Boolean ShowScriptingPage { get { return _showScriptingPage; } }
131  public static int ViHostRefreshRate { get { return _viHostRefreshRate; } }
132  public static Boolean IsPythonAvailable { get { return _isPythonAvailable; } }
133  public static String MaintenanceWebpage { get { return _maintenanceWebpage; } }
134  public static String LTRWebpage { get { return _LTRWebpage; } }
135  public static String InstMonWebpage { get { return _InstMonWebpage; } }
136 
141  public static Boolean ReadAppSettings()
142  {
143  //if the ndx name does not match the instrument name
144  Dictionary<String, string> instnames = new Dictionary<string,string>();
145  instnames.Add("EVS", "VESUVIO");
146  instnames.Add("NDW613", "VESUVIO");
147 
148  try
149  {
150  //Read settings from App.config
151  System.Configuration.AppSettingsReader reader = new System.Configuration.AppSettingsReader();
152 
153  _instrument = reader.GetValue("InstrumentName", typeof(System.String)).ToString();
154  if (String.IsNullOrEmpty(_instrument))
155  {
156  //Name not specified so try to obtain it from the host name
157  String name = System.Environment.MachineName;
158  if (name.ToLower().StartsWith("ndx"))
159  {
160  _instrument = name.Substring(3);
161  }
162  else
163  {
164  _instrument = name;
165  }
166  }
167 
168  _shortInstrument = reader.GetValue("InstShortName", typeof(System.String)).ToString();
169  if (String.IsNullOrEmpty(_shortInstrument))
170  {
171  String name = Environment.GetEnvironmentVariable("SHORTNAME");
172  if (!String.IsNullOrEmpty(name))
173  {
174  _shortInstrument = name;
175  }
176  else
177  {
178  _shortInstrument = "UNK";
179  }
180  }
181 
182  _isTS2Instrument = (Boolean)reader.GetValue("IsTs2Instrument", typeof(System.Boolean));
183  _labViewDir = reader.GetValue("LabVIEWDir", typeof(System.String)).ToString();
184  _labViewIniFilePath = reader.GetValue("LabViewIniFilepath", typeof(System.String)).ToString();
185  _usingNewDae = (Boolean)reader.GetValue("UseNewDAE", typeof(System.Boolean));
186  _daeFile = reader.GetValue("DAEVI", typeof(System.String)).ToString();
187  _messagePanelVI = reader.GetValue("MessagePanelVI", typeof(System.String)).ToString();
188  _beamLoggerVI = reader.GetValue("BeamLoggerVI", typeof(System.String)).ToString();
189  _daeMonitorVI = reader.GetValue("DAEMonitorVI", typeof(System.String)).ToString();
190  _sampleParametersVI = reader.GetValue("SampleParametersVI", typeof(System.String)).ToString();
191  _beamlineParametersVI = reader.GetValue("BeamlineParametersVI", typeof(System.String)).ToString();
192  _userDetailsVI = reader.GetValue("UserDetailsVI", typeof(System.String)).ToString();
193  _useDaeMonitorVI = (Boolean)reader.GetValue("UseDAEMonitorVI", typeof(System.Boolean));
194  _blockUpdateRate = Convert.ToInt32(reader.GetValue("BlockUpdateRate", typeof(System.Int32)));
195  _isMuonInstrument = (Boolean)reader.GetValue("IsMuonInstrument", typeof(System.Boolean));
196  _managerPassword = reader.GetValue("ManagerPassword", typeof(System.String)).ToString();
197  _openGenieLocation = reader.GetValue("OpenGENIELocation", typeof(System.String)).ToString();
198  _rbfinderLocation = reader.GetValue("RBFinderLocation", typeof(System.String)).ToString();
199  _rbDataFilepath = reader.GetValue("RBDataFilepath", typeof(System.String)).ToString();
200  _beamStatusWebpage = reader.GetValue("BeamStatusUrl", typeof(String)).ToString();
201  _ts1StatusWebpage = reader.GetValue("TS1GraphUrl", typeof(String)).ToString();
202  _ts2StatusWebpage = reader.GetValue("TS2GraphUrl", typeof(String)).ToString();
203  _mcrNewsWebpage = reader.GetValue("McrUrl", typeof(String)).ToString();
204  _bugzillaWebpage = reader.GetValue("BugzillaUrl", typeof(String)).ToString();
205  _genieWebpage = reader.GetValue("GenieUrl", typeof(String)).ToString();
206  _delayStartup = (Boolean)reader.GetValue("DelayStartup", typeof(System.Boolean));
207  _maxNumberPlotsPerGraph = Convert.ToInt32(reader.GetValue("MaxNumberPlotsPerGraph", typeof(System.Int32)));
208  _maxNumberGraphs = Convert.ToInt32(reader.GetValue("MaxNumberGraphs", typeof(System.Int32)));
209  _maxNumberGenieGraphs = Convert.ToInt32(reader.GetValue("MaxNumberGenieGraphs", typeof(System.Int32)));
210  _logToDatabase = (Boolean)reader.GetValue("LogBlocksToDatabase", typeof(System.Boolean));
211  _logAllBlocksToSingleFile = (Boolean)reader.GetValue("LogBlocksToSingleFile", typeof(System.Boolean));
212  _journalLocation = reader.GetValue("JournalLocation", typeof(String)).ToString();
213  _sampleSheetWebpage = reader.GetValue("SamplesheetWebpage", typeof(String)).ToString();
214  _eraWebpage = reader.GetValue("ERAWebpage", typeof(String)).ToString();
215  _rbDateLeeway = Convert.ToInt32(reader.GetValue("RBDateLeeway", typeof(System.Int32)));
216  _killIcpOnConfigChange = (Boolean)reader.GetValue("KillIcpOnConfigChange", typeof(System.Boolean));
217  _killIcpOnExit = (Boolean)reader.GetValue("KillIcpOnExit", typeof(System.Boolean));
218  _baseLogDir = reader.GetValue("ErrorLogDir", typeof(String)).ToString();
219  _enableDashboardTitleEdit = (Boolean)reader.GetValue("DashboardTitleEnabled", typeof(System.Boolean));
220  _autoloadLastConfig = (Boolean)reader.GetValue("AutoloadLastConfig", typeof(System.Boolean));
221  _showScriptingPage = (Boolean)reader.GetValue("ShowScriptingPage", typeof(System.Boolean));
222  _viHostRefreshRate = Convert.ToInt32(reader.GetValue("ViHostRefreshRate", typeof(System.Int32)));
223  _isPythonAvailable = (Boolean)reader.GetValue("PythonAvailable", typeof(System.Boolean));
224  _LTRWebpage = reader.GetValue("LTRWebpage", typeof(String)).ToString();
225  _InstMonWebpage = reader.GetValue("InstMonWebpage", typeof(String)).ToString() + "?Instrument=" + _instrument.ToUpper();
226 
227  if (instnames.ContainsKey(_instrument.ToUpper()))
228  {
229  _maintenanceWebpage = reader.GetValue("MaintenanceWebpage", typeof(String)).ToString().Replace("INSTNAME", instnames[_instrument.ToUpper()].ToUpper());
230  }
231  else
232  {
233  _maintenanceWebpage = reader.GetValue("MaintenanceWebpage", typeof(String)).ToString().Replace("INSTNAME", _instrument.ToUpper());
234  }
235 
236  //Adjust anthing that is located in program files
237  String location = Environment.GetEnvironmentVariable(Environment.SpecialFolder.ProgramFiles.ToString());
238  if (IntPtr.Size == 8)
239  {
240  //It is a 64bit machine
241  location = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
242  }
243 
244  _rbfinderLocation = _rbfinderLocation.Replace("progfiles", location);
245  _openGenieLocation = _openGenieLocation.Replace("progfiles", location);
246  _labViewIniFilePath = _labViewIniFilePath.Replace("progfiles", location);
247 
248  //Find the nexus group names
249  String temp = reader.GetValue("NexusGroups", typeof(System.String)).ToString();
250 
251  if (temp != null)
252  {
253  _nexusGroups = temp.Split(';');
254  }
255 
256  //Get the python stuff
257  try
258  {
259  _pythonPath = reader.GetValue("PythonPath", typeof(System.String)).ToString();
260  _pythonArgs = reader.GetValue("PythonArgs", typeof(System.String)).ToString();
261  }
262  catch
263  {
264  //Oh well, carry on...
265  }
266 
267  //Dashboard type
268  try
269  {
270  _dashboardType = reader.GetValue("DashboardType", typeof(System.String)).ToString().ToUpper();
271  }
272  catch
273  {
274  _dashboardType = "STANDARD";
275  }
276 
277  return true;
278  }
279  catch (Exception err)
280  {
281  Seci.Helpers.ErrorLogger.SeciError("ReadAppSettings", err);
282  return false;
283  }
284  }
285 
291  internal static void CreateDirectories()
292  {
293  //Check folders exist, if not create them
294  DirectoryInfo DI = new DirectoryInfo(_errorDir);
295 
296  //ErrorDir
297  if (!DI.Exists)
298  {
299  DI.Create();
300  }
301 
302  DI = new DirectoryInfo(_configDir);
303 
304  //ConfigDir
305  if (!DI.Exists)
306  {
307  DI.Create();
308  }
309 
310  DI = new DirectoryInfo(_labViewErrorDir);
311 
312  //LabVIEWErrorDir
313  if (!DI.Exists)
314  {
315  DI.Create();
316  }
317  }
318 
325  internal static Boolean CheckManagerPassword(String password)
326  {
327  if (password == _managerPassword)
328  {
329  return true;
330  }
331  else
332  {
333  return false;
334  }
335  }
336 
337  }
338 }
static String _daeFile
Definition: Status.cs:28
static String _ts1StatusWebpage
Definition: Status.cs:47
static String _labViewErrorDir
Definition: Status.cs:25
static Boolean _logAllBlocksToSingleFile
Definition: Status.cs:57
static String _openGenieLocation
Definition: Status.cs:35
static int _blockUpdateRate
Definition: Status.cs:40
static String _shortInstrument
Definition: Status.cs:17
static Boolean _isMuonInstrument
Definition: Status.cs:44
static String _bugzillaWebpage
Definition: Status.cs:50
static Boolean _usingNewDae
Definition: Status.cs:41
static String _labViewDir
Definition: Status.cs:21
static String _journalLocation
Definition: Status.cs:58
static String _rbDataFilepath
Definition: Status.cs:37
static String _sampleParametersVI
Definition: Status.cs:32
static String _sampleSheetWebpage
Definition: Status.cs:60
static String[] _nexusGroups
Definition: Status.cs:42
Class for holding the standard run-time settings for SECI. A large percentage of the information held...
Definition: Status.cs:12
static String _executionDir
Definition: Status.cs:23
static int _maxNumberGraphs
Definition: Status.cs:54
static String _mcrNewsWebpage
Definition: Status.cs:49
static String _configDir
Definition: Status.cs:26
static Boolean _isTS2Instrument
Definition: Status.cs:18
static Boolean _logToDatabase
Definition: Status.cs:56
static String _instrument
Definition: Status.cs:16
static String _eraWebpage
Definition: Status.cs:61
static int _maxNumberGenieGraphs
Definition: Status.cs:55
static String _beamStatusWebpage
Definition: Status.cs:46
static Boolean _useDaeMonitorVI
Definition: Status.cs:43
static String _InstMonWebpage
Definition: Status.cs:64
static String _genieWebpage
Definition: Status.cs:51
static int _maxNumberPlotsPerGraph
Definition: Status.cs:53
static String _userDetailsVI
Definition: Status.cs:34
static String _rbfinderLocation
Definition: Status.cs:36
static String _maintenanceWebpage
Definition: Status.cs:62
static Boolean ReadAppSettings()
This method reads the settings that are set via the App.config file.
Definition: Status.cs:141
static int _rbDateLeeway
Definition: Status.cs:65
static String _ts2StatusWebpage
Definition: Status.cs:48
static String _daeMonitorVI
Definition: Status.cs:31
static String _helpDir
Definition: Status.cs:27
static String _labViewIniFilePath
Definition: Status.cs:22
static String _errorDir
Definition: Status.cs:24
static String _LTRWebpage
Definition: Status.cs:63
static String _messagePanelVI
Definition: Status.cs:29
static String _managerPassword
Definition: Status.cs:45
static Boolean _delayStartup
Definition: Status.cs:52
static Boolean _managerLoggedIn
Definition: Status.cs:15
static String _beamlineParametersVI
Definition: Status.cs:33
static String _beamLoggerVI
Definition: Status.cs:30