SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
Configuration.cs
Go to the documentation of this file.
1 using System;
2 using System.IO;
3 using System.Xml.Serialization;
4 
5 namespace Seci.Definitions
6 {
15  public class Configuration
16  {
20  private SerialisableList<LabView.LabViewPanelInfo> _lvPanels;
24  private SerialisableList<AssociatedFile> _associatedFiles;
26  private SerialisableList<Executable> _executables;
30  private Boolean _savedAsManager;
32  private String _configName;
35  private SerialisableList<String> _tabOrder;
37  private SerialisableList<Tab> _tabs;
39  private SerialisableList<GraphDefinition> _graphDefinitions;
41  private Boolean _oldSeciFirstTime = false;
43  private SerialisableList<BlockGroup> _groups;
44 
45  //Properties - do not change any of these names as this will break existing configs
46  public String ConfigName { get { return _configName; } set { _configName = value; } }
47  public SerialisableList<LabView.LabViewPanelInfo> LVPanels { get { return _lvPanels; } set { _lvPanels = value; } }
48  public BlockDictionary Blocks { get { return _blocks; } set { _blocks = value; } }
49  public ComponentList Components { get { return _components; } set { _components = value; } }
50  public SerialisableList<AssociatedFile> AssociatedFiles { get { return _associatedFiles; } set { _associatedFiles = value; } }
51  public SerialisableList<Executable> Executables { get { return _executables; } set { _executables = value; } }
52  public Boolean SavedAsManager { get { return _savedAsManager; } set { _savedAsManager = value; } }
53  public SerialisableList<String> TabOrder { get { return _tabOrder; } set { _tabOrder = value; } }
54  public SerialisableList<Tab> Tabs { get { return _tabs; } set { _tabs = value; } }
55  public SerialisableList<BlockGroup> Groups { get { return _groups; } set { _groups = value; } }
56  public SerialisableList<GraphDefinition> GraphDefinitions { get { return _graphDefinitions; } set { _graphDefinitions = value; } }
57  public Tools.AlertsBox Alerts { get { return _alerts; } set { _alerts = value; } }
58  public Boolean OldSeciFirstTime { get { return _oldSeciFirstTime; } set { _oldSeciFirstTime = value; } }
59 
64  public Configuration()
65  {
66  _components = new ComponentList();
67  _blocks = new BlockDictionary();
68  _lvPanels = new SerialisableList<LabView.LabViewPanelInfo>();
69  _associatedFiles = new SerialisableList<AssociatedFile>();
70  _executables = new SerialisableList<Executable>();
71  _tabOrder = new SerialisableList<String>();
72  _tabs = new SerialisableList<Tab>();
73  _groups = new SerialisableList<BlockGroup>();
74  _graphDefinitions = new SerialisableList<GraphDefinition>();
75  _alerts = new Tools.AlertsBox();
76  }
77 
83  public void DirtySave(String fileName)
84  {
85  FileStream stream = new FileStream(fileName, FileMode.Create);
86 
87  try
88  {
89  //Serialise the config
90  XmlSerializer serialize = new XmlSerializer(typeof(Configuration));
91  serialize.Serialize(stream, this);
92 
93  }
94  catch (Exception e)
95  {
96  //throw error up to next level
97  throw new ArgumentException(e.Message);
98  }
99  finally
100  {
101  stream.Close();
102  }
103  }
104 
105  #region Merge Configs/Comps
106 
113  //internal void MergeConfigs(String fileName)
114  //{
115  // try
116  // {
117  // //This function loads the config to merge as a component
118  // String compName = Managers.ComponentMgr.AddComponent(fileName);
119 
120  // //Then merges it in to the main config
121  // DoConfigMerge(_components[compName]);
122 
123  // //Then delete the component
124  // _components.Remove(_components[compName]);
125 
126  // }
127  // catch (Exception e)
128  // {
129  // //throw error up to next level
130  // throw new ArgumentException(e.Message);
131  // }
132  //}
133 
140  //internal void MergeComponent(String compName)
141  //{
142  // //Move all the VIs etc from component to main conf
143  // try
144  // {
145  // if (_components.Count > 0)
146  // {
147  // for (int i = 0; i < _components.Count; ++i)
148  // {
149  // if (_components[i]._configName == compName)
150  // {
151  // //Merge
152  // DoCompMerge(_components[i]);
153  // _components.RemoveAt(i);
154  // return;
155  // }
156  // }
157  // }
158  // }
159  // catch (Exception e)
160  // {
161  // //throw error up to next level
162  // throw new ArgumentException(e.Message);
163  // }
164  //}
165 
171  //internal void MergeAllComponents()
172  //{
173  // //Move all the VIs etc from component to main conf
174  // try
175  // {
176  // if (_components.Count > 0)
177  // {
178  // for (int i = 0; i < _components.Count; ++i)
179  // {
180  // //Merge
181  // DoCompMerge(_components[i]);
182  // }
183 
184  // //Finally, delete components
185  // _components = new ComponentList();
186  // }
187  // }
188  // catch (Exception e)
189  // {
190  // //throw error up to next level
191  // throw new ArgumentException(e.Message);
192  // }
193  //}
194 
201  //private void DoConfigMerge(SeciConfiguration configName)
202  //{
203  // //Calls the component merge method as that does the VIs, assocs and exes
204  // DoCompMerge(configName);
205 
206  // //Add any components
207  // if (configName.Components != null && !LabView.LabViewApp.IsNull)
208  // {
209  // List<String> currentConfs = new List<String>();
210  // currentConfs.AddRange(_components.Components);
211 
212  // for (int i = 0; i < configName.Components.Count; ++i)
213  // {
214  // if (!currentConfs.Contains(configName.Components.Components[i]))
215  // {
216  // Managers.ComponentMgr.AddComponent(Status.ConfigDir + configName.Components.Components[i]);
217  // }
218  // }
219  // }
220  //}
221 
230  //private void DoCompMerge(SeciConfiguration compName)
231  //{
232  // //First copy the LabView VIs - check for duplicates and discard
233  // List<String> vis = GetListOfVIs(false);
234 
235  // for (int i = 0; i < compName._lvPanels.Count; ++i)
236  // {
237  // if (!vis.Contains(compName._lvPanels[i].FilePath))
238  // {
239  // _lvPanels.Add(compName._lvPanels[i]);
240  // }
241  // }
242 
243  // //then assoc files - check for duplicates and discard
244  // List<String> asscs = Managers.AssocFileMgr.GetListOfAsscFiles(false);
245 
246  // for (int i = 0; i < compName._associatedFiles.Count; ++i)
247  // {
248  // if (!asscs.Contains(compName._associatedFiles[i].FileLocation))
249  // {
250  // _associatedFiles.Add(compName._associatedFiles[i]);
251  // }
252  // }
253 
254  // //then Exes
255  // List<String> exes = Managers.ExecutableMgr.GetListOfAllExes(false);
256 
257  // for (int i = 0; i < compName._executables.Count; ++i)
258  // {
259  // if (!exes.Contains(compName._executables[i].FilePath))
260  // {
261  // _executables.Add(compName._executables[i]);
262  // }
263  // }
264 
265  // //Sort out the blocks
266  // for (int i = 0; i < _blocks.Count; ++i)
267  // {
268  // if (_blocks[i].OwningComponent != null && _blocks[i].OwningComponent.ToLower() == compName.ConfigName.ToLower())
269  // {
270  // Console.WriteLine(i);
271  // _blocks[i].OwningComponent = null;
272  // }
273  // }
274  //}
275 
276  #endregion
277 
278  }
279 }
BlockDictionary _blocks
The BlockDictionary that stores the block information for this configuration and those of any compone...
ComponentList _components
Container for the components which are part of this configuration.
A serialisable list for containing objects of type SeciConfiguration. This class wraps a standard Lis...
Configuration()
Default Constructor. This constructor is required for XML serialisation and deserialisation.
SerialisableList< LabView.LabViewPanelInfo > _lvPanels
Container for the LabVIEW VI information that needs to be saved.
This class contains all the information that defines the configuration at the SECI level and contains...
SerialisableList< BlockGroup > _groups
Container for the groups. The groups are in order.
Tools.AlertsBox _alerts
Container for any alerts that have been set-up.
SerialisableList< String > _tabOrder
Specialised version of the Dictionary class which can be converted to XML. Also has some additional s...
Boolean _savedAsManager
Was the configuration saved by the manager account?
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...
SerialisableList< GraphDefinition > _graphDefinitions
Container for graph definitions.
void DirtySave(String fileName)
This method saves the configuration in a XML file (for use from old SECI). Can be removed when old SE...
String _configName
The name of the configuration.
SerialisableList< Executable > _executables
Container for any non-LabVIEW programmes.
SerialisableList< AssociatedFile > _associatedFiles
Container for associated file information.
SerialisableList< Tab > _tabs
Container for the tabs. The tabs are in order.