2 using System.Collections.Generic;
4 using Seci.Definitions;
6 namespace Seci.Managers
18 private static DateTime _timeWentOutOfRange =
new DateTime();
19 private static Boolean _logValuesEnabled =
true;
22 public static SerialisableList<BlockGroup> Groups {
get {
return _groups; }
internal set { _groups = value; } }
24 public delegate
void EnableLoggingChangedEventHandler(Boolean enabled);
26 public static Boolean LogValuesEnabled
28 get {
return _logValuesEnabled; }
31 _logValuesEnabled = value;
32 if (OnEnableLoggingUpdated != null)
34 OnEnableLoggingUpdated(value);
39 #region Public Methods
48 if (Seci.Definitions.Status.LogToDatabase)
50 Seci.Helpers.DatabaseLogger.WriteBlockDetails();
76 Helpers.ErrorLogger.SeciError(
"GetAllBlocks", err);
92 public static List<String>
GetAllBlockValues(Boolean visibleOnly, Boolean includeSetpoint, Boolean includeGroup, Boolean includeWaitState)
94 List<String> blocks =
new List<String>();
96 if (_blocks.Count != 0)
98 blocks.AddRange(_blocks.GetFormattedBlockValues(visibleOnly, includeSetpoint, includeGroup, includeWaitState));
101 if (blocks.Count != 0)
118 return _blocks.GetBlockValue(blockname);
129 public static String
GetFormattedBlockValue(String blockname, Boolean includeSetpoint, Boolean includeGroup, Boolean includeWaiting)
131 return _blocks.GetFormattedBlockValue(blockname, includeSetpoint, includeGroup, includeWaiting);
141 return _blocks.GetSetpointValue(block);
155 if (_blocks.Contains(blockname.ToLower()))
157 _blocks[blockname.ToLower()].SetRunControlLimits(enabled, low, high);
172 if (_blocks.Contains(blockname.ToLower()))
174 _blocks[blockname.ToLower()].SetRunControl(enabled);
183 for (
int i = 0; i < _groups.Count; ++i)
185 if (name.ToLower().Trim() == _groups[i].Name.ToLower().Trim())
196 SerialisableList<BlockGroup> newList =
new SerialisableList<BlockGroup>();
197 foreach (
string name
in neworder)
211 internal static void UpdateBlockValues()
213 Boolean allInRange =
true;
215 for (
int i = 0; i < Managers.BlockMgr.Blocks.Count; ++i)
218 if (Managers.BlockMgr.Blocks[i].BlockEnabled)
223 Managers.BlockMgr.Blocks[i].CurrentValue = Seci.LabView.LabViewApp.GetValue(Managers.BlockMgr.Blocks[i].ParentVI, Managers.BlockMgr.Blocks[i].ReadControl)[0];
224 Managers.BlockMgr.Blocks[i].PrevReadError =
false;
225 if (Managers.BlockMgr.Blocks[i].WriteControl != null)
229 Managers.BlockMgr.Blocks[i].SetPointValue = Seci.LabView.LabViewApp.GetValue(Managers.BlockMgr.Blocks[i].ParentVI, Managers.BlockMgr.Blocks[i].WriteControl)[0];
231 catch (Exception err)
233 Managers.BlockMgr.Blocks[i].SetPointValue = null;
238 if (Seci.Definitions.Status.LogToDatabase)
241 Seci.Helpers.DatabaseLogger.AddCurrentValue(Managers.BlockMgr.Blocks[i].BlockName, Managers.BlockMgr.Blocks[i].CurrentValue, Managers.BlockMgr.Blocks[i].SetPointValue);
244 catch (Exception err)
246 Managers.BlockMgr.Blocks[i].CurrentValue = Definitions.BlockInfo.ErrorString;
247 Managers.BlockMgr.Blocks[i].SetPointValue = null;
248 if (!Managers.BlockMgr.Blocks[i].PrevReadError)
251 Managers.BlockMgr.Blocks[i].PrevReadError =
true;
252 Seci.Helpers.ErrorLogger.SeciError(
"UpdateBlockValues (" + Managers.BlockMgr.Blocks[i].BlockName +
")", err);
258 if (Managers.BlockMgr.Blocks[i].OutOfRange())
264 Standard.Dae.BeginWaiting();
268 AlertsMgr.CheckBlockInRange(Managers.BlockMgr.Blocks[i]);
271 if (_logValuesEnabled)
273 Managers.BlockMgr.Blocks[i].LogValue(DateTime.Now, Definitions.Status.ShortInstrument, Standard.Dae.RunNumber);
281 Standard.Dae.EndWaiting();
284 if (Standard.Dae.RunStatus ==
"WAITING")
286 AlertsMgr.CheckInWaiting(
true);
290 AlertsMgr.CheckInWaiting(
false);
static EnableLoggingChangedEventHandler OnEnableLoggingUpdated
static List< String > GetAllBlockValues(Boolean visibleOnly, Boolean includeSetpoint, Boolean includeGroup, Boolean includeWaitState)
Get all the current block values, including any in the components. Format of String is "blockname: va...
object Clone()
Clone - Default method of ICloneable Used to clone (deep copy) the block dictionary. This allows for cancelling when editing the blocks.
static void SetBlocks(BlockDictionary blocks)
This method set the blocks in SECI after they have been created or modified
static String GetBlockValue(String blockname)
Gets the value of a specified block in the configuration or its components.
static String GetBlockSetpoint(String block)
Gets the set-point value of a specified block in the configuration or its components.
static Boolean ToggleRunContol(String blockname, Boolean enabled)
Toggle whether run-control is enabled - uses limits set previously.
The manager class for Block related stuff.
static String GetFormattedBlockValue(String blockname, Boolean includeSetpoint, Boolean includeGroup, Boolean includeWaiting)
Gets a formatted string of form "BlockName: value units".
static void ReorderBlockGroups(List< string > neworder)
static BlockDictionary GetBlocksClone()
Creates a new BlockDictionary containing all the blocks, including any which are in a component...
Specialised version of the Dictionary class which can be converted to XML. Also has some additional s...
static bool BlockGroupExists(string name)
static Boolean SetBlockRunControl(String blockname, Boolean enabled, Double low, Double high)
Sets the run-control limits for a block, includes any blocks in components. This is the recommended m...