2 using System.Collections.Generic;
5 using Seci.Definitions;
7 namespace Seci.Managers
22 public static String ConfigName {
get {
return _currentConfig.ConfigName; } set { _currentConfig.ConfigName = value; } }
25 public static ComponentList Components {
get {
return ComponentMgr.Components; } set { ComponentMgr.Components = value; } }
51 Managers.ConfigurationMgr.saveConfig(manager, autoSave);
53 Seci.Helpers.MessageLogger.WriteMessage(
"SeciInterface",
"Configuration saved: " + _currentConfig.ConfigName);
63 private static void saveConfig(Boolean manager, Boolean isAutosave)
71 fileName = Status.ConfigDir +
"autosave";
75 fileName = Status.ConfigDir + _currentConfig.ConfigName;
81 for (
int i = _currentConfig.LVPanels.Count - 1; i >= 0; --i)
83 if (!String.IsNullOrEmpty(_currentConfig.LVPanels[i].OwningComponent))
85 _currentConfig.LVPanels.RemoveAt(i);
91 SerialisableList<GraphDefinition> tempGraphs = (SerialisableList<GraphDefinition>)_currentConfig.GraphDefinitions.Clone();
93 for (
int i = _currentConfig.GraphDefinitions.Count - 1; i >= 0; --i)
95 if (!String.IsNullOrEmpty(_currentConfig.GraphDefinitions[i].OwningComponent))
97 _currentConfig.GraphDefinitions.RemoveAt(i);
104 for (
int i = _currentConfig.AssociatedFiles.Count - 1; i >= 0; --i)
106 if (!String.IsNullOrEmpty(_currentConfig.AssociatedFiles[i].OwningComponent))
108 _currentConfig.AssociatedFiles.RemoveAt(i);
113 for (
int i = 0; i < _currentConfig.AssociatedFiles.Count; ++i)
115 _currentConfig.AssociatedFiles[i].ConvertFileToByteArray();
121 for (
int i = _currentConfig.Executables.Count - 1; i >= 0; --i)
123 if (!String.IsNullOrEmpty(_currentConfig.Executables[i].OwningComponent))
125 _currentConfig.Executables.RemoveAt(i);
132 _currentConfig.Blocks = Managers.BlockMgr.Blocks;
133 _currentConfig.Groups = Managers.BlockMgr.Groups;
136 _currentConfig.Components = Managers.ComponentMgr.Components;
139 _currentConfig.Alerts = Managers.AlertsMgr.GetAlertsCopyForSaving();
142 _currentConfig.SavedAsManager = manager;
145 _currentConfig.OldSeciFirstTime =
false;
148 Helpers.ConfigurationIO.SaveConfig(_currentConfig, isAutosave, fileName);
151 _currentConfig.GraphDefinitions = tempGraphs;
162 return Helpers.ConfigurationIO.OkayToSave(ConfigName, manager);
176 Managers.ConfigurationMgr.openConfig(fileName);
180 Standard.DaeMonitor.Initialise();
183 Seci.Helpers.MessageLogger.WriteMessage(
"SeciInterface",
"Configuration opened: " + fileName);
185 if (Seci.Definitions.Status.LogToDatabase)
187 Seci.Helpers.DatabaseLogger.LogConfigName(fileName.Substring(fileName.LastIndexOf(
'\\') + 1));
189 Seci.Helpers.DatabaseLogger.WriteBlockDetails();
197 for (
int i = 0; i < _currentConfig.LVPanels.Count; ++i)
199 if (_currentConfig.LVPanels[i].StartRunning)
201 startVI(_currentConfig.LVPanels[i]);
219 Configuration temp = Helpers.ConfigurationIO.LoadConfig(fileName);
222 _currentConfig.ConfigName = temp.ConfigName;
223 _currentConfig.GraphDefinitions = temp.GraphDefinitions;
226 _currentConfig.Tabs = temp.Tabs;
227 if (temp.
TabOrder != null && temp.
TabOrder.Count > 0 && _currentConfig.Tabs.Count == 0)
229 foreach (String tab
in temp.
TabOrder)
231 _currentConfig.Tabs.Add(
new Tab(tab,
true));
236 AlertsMgr.SetAlerts(temp.Alerts);
239 ConfigurationMgr.Components = temp.Components;
245 BlockMgr.SetBlocks(temp.Blocks);
248 for (
int i = 0; i < temp.Executables.Count; ++i)
250 ExecutableMgr.AddExecutable(temp.Executables[i]);
254 for (
int i = 0; i < temp.AssociatedFiles.Count; ++i)
256 AssocFileMgr.AddFile(temp.AssociatedFiles[i]);
257 AssocFileMgr.RecreateFile(temp.AssociatedFiles[i]);
261 loadVIsAndInitialise(temp.
LVPanels);
262 ConfigurationMgr.LoadComponentsVisExes();
265 for (
int i = 0; i < temp.Blocks.Count; ++i)
269 temp.Blocks[i].ReadType = LabViewMgr.GetControlType(temp.Blocks[i].ParentVI, temp.Blocks[i].ReadControl);
271 catch (KeyNotFoundException err)
273 Helpers.ErrorLogger.SeciError(
"openConfig",
new Exception(temp.
Blocks[i].BlockName +
"'s read control is invalid"));
278 if (LabView.LabViewApp.VIsNotLoaded != null)
280 foreach (String name
in LabView.LabViewApp.VIsNotLoaded)
282 BlockMgr.Blocks.RemoveByVI(name);
287 SerialisableList<BlockGroup> used =
new SerialisableList<BlockGroup>();
291 for (
int i = 0; i < temp.Blocks.Count; ++i)
293 if (!groupExists(used, temp.
Blocks[i].Group))
310 for (
int i = temp.
Groups.Count - 1; i >= 0; --i)
313 for (
int j = 0; j < used.Count; ++j)
315 if (used[j].Name == temp.
Groups[i].Name)
324 temp.Groups.RemoveAt(i);
329 BlockMgr.Groups = temp.Groups;
337 BlockMgr.SetBlocks(BlockMgr.Blocks);
340 Seci.Standard.DaeMonitor.WriteBlockList();
344 Helpers.ErrorLogger.SeciError(
"openConfig", e);
346 throw new ArgumentException(e.Message);
350 private static bool groupExists(SerialisableList<BlockGroup> groups,
string name)
352 for (
int i = 0; i < groups.Count; ++i)
354 if (groups[i].Name == name)
364 for (
int i = 0; i < ComponentMgr.Components.Count; ++i)
368 for (
int j = 0; j < ComponentMgr.Components[i].Tabs.Count; ++j)
370 Boolean tabexists =
false;
372 foreach (
Tab t
in _currentConfig.Tabs)
383 _currentConfig.Tabs.Add(ComponentMgr.Components[i].Tabs[j]);
402 for (
int i = 0; i < panels.Count; ++i)
408 if (Panel.FilePath.Substring(0, Panel.FilePath.LastIndexOf(
'\\')).ToLower().EndsWith(
".llb"))
411 fi =
new FileInfo(Panel.FilePath.Substring(0, Panel.FilePath.LastIndexOf(
'\\')));
416 fi =
new FileInfo(Panel.FilePath);
421 LabView.LabViewApp.LoadVI(Panel,
true);
425 LabView.LabViewApp.ShowVI(Panel.FilePath);
428 if (Panel.StartRunning)
436 LabView.LabViewApp.VIsNotLoaded.Add(fi.FullName);
443 throw new ArgumentException(e.Message);
451 private static void startVI(Seci.LabView.LabViewPanelInfo Panel)
453 LabView.LabViewApp.StartVI(Panel.FilePath);
456 System.Threading.Thread.Sleep(Panel.DelayAfter * 1000);
469 if (!LabView.LabViewApp.IsNull)
471 Seci.Helpers.MessageLogger.WriteMessage(
"SeciInterface",
"Configuration closed");
474 Standard.MessageQueue.Messages.Clear();
477 LabView.LabViewApp.StopLabView();
482 Standard.Dae.KillIcp();
485 ExecutableMgr.CloseAll();
487 BlockMgr.Blocks.Clear();
489 BlockMgr.Groups.Clear();
491 AssocFileMgr.AssociatedFiles.Clear();
493 AlertsMgr.ClearAlerts();
495 _currentConfig.TabOrder =
new SerialisableList<string>();
496 _currentConfig.GraphDefinitions =
new SerialisableList<GraphDefinition>();
497 _currentConfig.ConfigName =
"";
499 ComponentMgr.Components.Clear();
505 #region Tabs 'n' Graphs
515 _currentConfig.TabOrder =
new SerialisableList<string>();
516 _currentConfig.TabOrder.AddRange(tabs);
520 _currentConfig.TabOrder = null;
530 List<String> temp =
new List<string>(_currentConfig.TabOrder.ToArray());
534 public static void SetTabs(SerialisableList<Tab> tabs)
536 _currentConfig.Tabs = tabs;
541 return _currentConfig.Tabs;
546 foreach (
Tab t
in _currentConfig.Tabs)
548 if (tabname == t.
Name)
550 t.VisibleForUser = visible;
556 public static void SwapTabs(String name1, String name2)
561 for (
int i = 0; i < _currentConfig.Tabs.Count; ++i)
563 if (_currentConfig.Tabs[i].Name == name1)
568 if (_currentConfig.Tabs[i].Name == name2)
574 if (toreplace != -1 && selected != -1)
576 Tab temp = _currentConfig.Tabs[selected];
577 _currentConfig.Tabs[selected] =
new Seci.Definitions.Tab(_currentConfig.Tabs[toreplace].Name, _currentConfig.Tabs[toreplace].VisibleForUser);
578 _currentConfig.Tabs[toreplace] = temp;
590 _currentConfig.GraphDefinitions =
new SerialisableList<GraphDefinition>();
591 _currentConfig.GraphDefinitions.AddRange(graphs);
599 internal static void AddGraphDefinitions(SerialisableList<GraphDefinition> graphs)
603 if (_currentConfig.GraphDefinitions == null)
605 _currentConfig.GraphDefinitions =
new SerialisableList<GraphDefinition>();
609 for (
int i = 0; i < graphs.Count; ++i)
611 _currentConfig.GraphDefinitions.Add(graphs[i]);
627 List<GraphDefinition> temp =
new List<GraphDefinition>(_currentConfig.GraphDefinitions.ToArray());
635 internal static void RemoveComponentGraphs(String compName)
637 if (_currentConfig.GraphDefinitions != null)
639 for (
int i = _currentConfig.GraphDefinitions.Count - 1; i >= 0; --i)
641 if (!String.IsNullOrEmpty(_currentConfig.GraphDefinitions[i].OwningComponent) && _currentConfig.GraphDefinitions[i].OwningComponent.ToLower() == compName.ToLower())
643 _currentConfig.GraphDefinitions.RemoveAt(i);
651 #region Old Seci Corrections
662 for (
int i = 0; i < blocks.Count; ++i)
664 blocks[i] = correctOldSeciBlock(blocks[i]);
682 return LabView.LabViewApp.GetCorrectBlockDetails(block);
696 foreach (LabView.LabViewPanelInfo panel in panels)
698 if (panel.FilePath == filename)
700 if (getPrevPosition && panel.OldBounds != null)
702 return panel.OldBounds;
715 foreach (LabView.LabViewPanelInfo panel in panels)
717 if (panel.FilePath == filename)
719 panel.OldBounds = panel.Bounds;
720 panel.Bounds =
new int[] { x, y };
739 internal static int RemoteConfigurationChange(String configName)
741 String fileName = Status.ConfigDir + configName;
744 FileInfo fi =
new FileInfo(fileName);
751 if (ConfigChangeRequested != null)
753 String[] vars = { fileName };
756 ConfigChangeRequested(vars);
770 if (Components != null)
772 List<String> names =
new List<String>();
774 for (
int i = 0; i < Components.Count; ++i)
776 names.Add(Components[i].ConfigName);
791 for (
int i = 0; i < Components[compName].Blocks.Count; ++i)
793 Components[compName].Blocks[i].OwningComponent = Components[Components.Count - 1].ConfigName;
795 BlockMgr.Blocks.AddDictionary(Components[compName].Blocks);
805 if (Components != null)
807 for (
int i = 0; i < Components.Count; ++i)
809 loadComponentVIs(Components[i].ConfigName);
810 loadComponentExes(Components[i].ConfigName);
811 loadAssocFiles(Components[i].ConfigName);
825 for (
int i = 0; i < Components[compName].LVPanels.Count; ++i)
831 if (Panel.FilePath.Substring(0, Panel.FilePath.LastIndexOf(
'\\')).ToLower().EndsWith(
".llb"))
834 fi =
new FileInfo(Panel.FilePath.Substring(0, Panel.FilePath.LastIndexOf(
'\\')));
839 fi =
new FileInfo(Panel.FilePath);
845 Panel.OwningComponent = compName;
846 if (LabView.LabViewApp.LoadVI(Panel,
true))
851 LabView.LabViewApp.ShowVI(Panel.FilePath);
855 if (Panel.StartRunning)
857 LabView.LabViewApp.StartVI(Panel.FilePath);
870 for (
int i = 0; i < Components[compName].Executables.Count; ++i)
872 Components[compName].Executables[i].OwningComponent = compName;
873 ExecutableMgr.AddExecutable(Components[compName].Executables[i]);
884 for (
int i = 0; i < Components[compName].AssociatedFiles.Count; ++i)
886 Components[compName].AssociatedFiles[i].OwningComponent = compName;
887 AssocFileMgr.AddFile(Components[compName].AssociatedFiles[i]);
888 AssocFileMgr.RecreateFile(Components[compName].AssociatedFiles[i]);
SerialisableList< BlockGroup > Groups
static void openConfig(String fileName)
Open a configuration or component. Calls LoadConfig to open the configuration file and create a SeciC...
The manager class for all things component related
static List< GraphDefinition > GetGraphDefinitions()
Method for getting the graph definitions from the configuration.
static void loadVIsAndInitialise(SerialisableList< LabView.LabViewPanelInfo > panels)
Loads all (if any) LabVIEW VIs in the configuration when it is opened. Also loads any VIs in any comp...
SerialisableList< String > TabOrder
A serialisable list for containing objects of type SeciConfiguration. This class wraps a standard Lis...
This class is used for storing the information for any blocks that are created and provides methods f...
static bool groupExists(SerialisableList< BlockGroup > groups, string name)
static List< String > GetNames()
Gets a list of the names of the components that are part of the current configuration.
This class is used for wrapping standard executables that are included as part of a configuration...
SerialisableList< LabView.LabViewPanelInfo > LVPanels
static void SetGraphDefinitions(List< GraphDefinition > graphs)
Method for adding graph definitions to the configuration for saving.
static void SwapTabs(String name1, String name2)
static void AddComponentTabs()
static Boolean SaveConfiguration(Boolean manager, Boolean autoSave)
Save the current configuration or component with the current user rights.
The manager class for all things executable related
static BlockDictionary Blocks
Class for holding the standard run-time settings for SECI. A large percentage of the information held...
This class contains all the information that defines the configuration at the SECI level and contains...
static void LoadComponentsVisExes()
Loads the VIs and executables associated to the component
static void addBlocks(String compName)
Set the owning name of the blocks then add to the block dictionary.
static void loadComponentVIs(String compName)
When adding a component to a configuration this method loads all (if any) LabVIEW VIs in the componen...
static Boolean OpenConfiguration(String fileName)
Opens a configuration or component from a xml file.
static void SetConfigPanelPosition(String filename, int x, int y)
The manager class for Block related stuff.
static ComponentList Components
static Boolean OkayToSave(Boolean manager)
Checks that the current user has permission to overwrite the configuration. Uses DotNet XPath methods...
static void loadComponentExes(String compName)
When loading or adding a component this method loads any executables that are part of the ...
static BlockDictionary correctOldSeciBlocks(BlockDictionary blocks)
Method for converting blocks from old SECI in to a format for new Seci.
static RemotingEventHandler ConfigChangeRequested
This event signals that a different configuration has been requested.
static void loadAssocFiles(String compName)
When loading or adding a component this method loads any associated files that are part of the compon...
static void CreateNewConfiguration()
Creates a new configuration or component.
static int MaxNumberGraphs
Specialised version of the Dictionary class which can be converted to XML. Also has some additional s...
static void startVI(Seci.LabView.LabViewPanelInfo Panel)
This method starts the VI and waits a specified number of seconds.
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...
static int[] GetConfigPanelPosition(String filename, Boolean getPrevPosition)
static void saveConfig(Boolean manager, Boolean isAutosave)
This method saves the configuration or component in a XML file.
This class is used for storing files as part of a configuration. Typically, the files stored are ini ...
static void SetTabOrder(List< String > tabs)
Method for setting the tab order in the configuration.
delegate void RemotingEventHandler(String[] vars)
This delegate handles any events that come in via the remoting interface that need to be handled by t...
static List< String > GetTabOrder()
Method for getting the tab order from the configuration.
The manager class for the configuration
static SerialisableList< Tab > GetTabs()
static void SetTabs(SerialisableList< Tab > tabs)
static void CloseConfiguration(Boolean killIcp)
Closes the configuration - this also kills the LabVIEW process. Whether to kill the ICP...
static void SetTabVisibility(String tabname, Boolean visible)
static Boolean UseDaeMonitorVI
The manager class for associated files.