2 using System.Collections.Generic;
6 namespace Seci.Managers
14 public static ComponentList Components {
get {
return _components; } set { _components = value; } }
27 for (
int i = 0; i < _components.Count; ++i)
29 if (fileName.ToLower().EndsWith(
"\\" + _components[i].ConfigName.ToLower()))
36 _components.Add(Helpers.ConfigurationIO.DeserialiseConfig(fileName));
38 String compName = _components[_components.Count - 1].ConfigName;
45 var comp = _components[_components.Count - 1];
46 if (comp.Groups != null)
48 for (
int i = 0; i < comp.Groups.Count; ++i)
58 if (comp.Blocks != null)
60 for (
int i = 0; i < comp.Blocks.Count; ++i)
70 ConfigurationMgr.AddComponentTabs();
73 AlertsMgr.AddComponentBox(null, _components[compName].Alerts, compName);
76 loadComponentVIs(compName);
79 loadComponentExes(compName);
82 loadAssocFiles(compName);
92 throw new ArgumentException(e.Message);
106 for (
int i = 0; i < _components.Count; ++i)
108 if (_components[i].ConfigName == compName)
111 Seci.Managers.SeciMgr.PauseThreads();
112 System.Threading.Thread.Sleep(1000);
119 if (!String.IsNullOrEmpty(
BlockMgr.
Blocks[j].OwningComponent) && BlockMgr.Blocks[j].OwningComponent.ToLower() == compName.ToLower())
121 BlockMgr.Blocks.Remove(BlockMgr.Blocks[j].BlockName);
129 var panels = Seci.Managers.LabViewMgr.GetAllPanelsInfo();
131 for (
int j = 0; j < panels.Count; ++j)
134 if (panels[j].OwningComponent == compName)
136 LabView.LabViewApp.CloseVI(panels[j].FilePath);
146 for (
int j = 0; j < _components[i].Executables.Count; ++j)
148 _components[i].Executables[j].Dispose();
149 ExecutableMgr.RemoveExecutable(_components[i].Executables[j].FilePath);
153 for (
int j = 0; j < _components[i].AssociatedFiles.Count; ++j)
155 AssocFileMgr.RemoveFile(_components[i].AssociatedFiles[j].FileLocation);
159 ConfigurationMgr.RemoveComponentGraphs(compName);
162 _components.Remove(_components[i]);
165 Seci.Managers.SeciMgr.ResumeThreads();
171 catch (Exception err)
173 Seci.Helpers.ErrorLogger.SeciError(
"RemoveComponent", err);
185 if (_components != null)
187 List<String> names =
new List<String>();
189 for (
int i = 0; i < _components.Count; ++i)
191 names.Add(_components[i].ConfigName);
206 for (
int i = 0; i < _components[compName].Blocks.Count; ++i)
208 _components[compName].Blocks[i].OwningComponent = _components[_components.Count - 1].ConfigName;
210 BlockMgr.Blocks.AddDictionary(_components[compName].Blocks);
220 if (_components != null)
222 for (
int i = 0; i < _components.Count; ++i)
224 loadComponentVIs(_components[i].ConfigName);
225 loadComponentExes(_components[i].ConfigName);
226 loadAssocFiles(_components[i].ConfigName);
240 for (
int i = 0; i < _components[compName].LVPanels.Count; ++i)
246 if (Panel.FilePath.Substring(0, Panel.FilePath.LastIndexOf(
'\\')).ToLower().EndsWith(
".llb"))
249 fi =
new FileInfo(Panel.FilePath.Substring(0, Panel.FilePath.LastIndexOf(
'\\')));
254 fi =
new FileInfo(Panel.FilePath);
260 Panel.OwningComponent = compName;
261 if (LabView.LabViewApp.LoadVI(Panel,
true))
266 LabView.LabViewApp.ShowVI(Panel.FilePath);
270 if (Panel.StartRunning)
272 LabView.LabViewApp.StartVI(Panel.FilePath);
285 for (
int i = 0; i < _components[compName].Executables.Count; ++i)
287 _components[compName].Executables[i].OwningComponent = compName;
288 ExecutableMgr.AddExecutable(_components[compName].Executables[i]);
299 for (
int i = 0; i < _components[compName].AssociatedFiles.Count; ++i)
301 _components[compName].AssociatedFiles[i].OwningComponent = compName;
302 AssocFileMgr.AddFile(_components[compName].AssociatedFiles[i]);
303 AssocFileMgr.RecreateFile(_components[compName].AssociatedFiles[i]);
314 for (
int i = 0; i < _components[compName].GraphDefinitions.Count; ++i)
316 _components[compName].GraphDefinitions[i].OwningComponent = compName;
319 ConfigurationMgr.AddGraphDefinitions(_components[compName].GraphDefinitions);
324 String fileName = Definitions.Status.ConfigDir + _components[compName].ConfigName;
327 for (
int i = 0; i < _components[compName].Blocks.Count; ++i)
329 _components[compName].Blocks[i].OwningComponent = null;
333 for (
int i = 0; i < _components[compName].LVPanels.Count; ++i)
335 _components[compName].LVPanels[i].OwningComponent = null;
339 Helpers.ConfigurationIO.SaveConfig(_components[compName],
false, fileName);
342 for (
int i = 0; i < _components[compName].Blocks.Count; ++i)
344 _components[compName].Blocks[i].OwningComponent = _components[compName].ConfigName;
348 for (
int i = 0; i < _components[compName].LVPanels.Count; ++i)
350 _components[compName].LVPanels[i].OwningComponent = _components[compName].ConfigName;
The manager class for all things component related
A serialisable list for containing objects of type SeciConfiguration. This class wraps a standard Lis...
static BlockDictionary Blocks
static List< String > GetNames()
Gets a list of the names of the components that are part of the current configuration.
static void loadComponentVIs(String compName)
When adding a component to a configuration this method loads all (if any) LabVIEW VIs in the componen...
static void SaveComponent(String compName)
static void LoadComponentsVisExes()
Loads the VIs and executables associated to the component
The manager class for Block related stuff.
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 loadComponentExes(String compName)
When loading or adding a component this method loads any executables that are part of the ...
static void addGraphs(String compName)
When loading or adding a component this method adds any graphs that are part of the component...
static Boolean RemoveComponent(String compName)
Removes a component from the current configuration. Removes any VIs, blocks, or executables associate...
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...
static void addBlocks(String compName)
Set the owning name of the blocks then add to the block dictionary.
static bool BlockGroupExists(string name)
static Boolean AddComponent(String fileName)
Open a component and add it to the current configuration.