2 using System.Collections;
3 using System.Collections.Generic;
6 using Seci.Definitions;
8 namespace Seci.Standard
21 private static SerialisableList<MessageInfo> _messages =
new SerialisableList<MessageInfo>();
24 private static int _timeoutTime = 1;
25 private static int _defaultPeriod = 60;
28 public static SerialisableList<MessageInfo> Messages {
get {
return _messages; } }
35 _filePath = Status.MessagePanelVI;
38 LabView.LabViewApp.LoadVI(_filePath,
true);
41 LabView.LabViewApp.StartVI(_filePath);
49 LabView.LabViewApp.ShowVI(_filePath);
57 LabView.LabViewApp.HideVI(_filePath);
68 Boolean updates = removeMessages();
69 Boolean newmessages = getMessageQ();
71 return (newmessages || updates);
87 Boolean MessagesChanged =
false;
91 LabView.LabViewApp.SetValue(_filePath,
"Hold",
false);
95 while (LabView.LabViewApp.GetValue(_filePath,
"Done")[0].ToLower() !=
"true")
97 System.Threading.Thread.Sleep(50);
109 for (
int i = 0; i < _messages.Count; ++i)
111 _messages[i].Count = 1;
115 System.Threading.Thread.Sleep(250);
118 Object[] temp = LabView.LabViewApp.GetCluster(_filePath,
"Queue");
120 for (
int i = 0; i < temp.GetLength(0); ++i)
122 Object[] Qmember = (Object[])temp[i];
126 newMess.Message = Qmember[0].ToString();
127 newMess.OriginalMess = Qmember[0].ToString();
128 newMess.YesText = Qmember[1].ToString();
129 newMess.NoText = Qmember[2].ToString();
130 newMess.Timeout = (Boolean)Qmember[3];
131 newMess.WaitForResponse = (Boolean)Qmember[4];
132 newMess.VIName = Qmember[5].ToString();
133 newMess.UserReplied = (Boolean)Qmember[6];
134 newMess.Timestamp = Qmember[8].ToString();
143 newMess.Message = newMess.Message.Replace(
'\n',
' ');
144 newMess.Message = newMess.Message.Replace(
'\r',
' ');
147 Boolean duplicate =
false;
149 for (
int j = 0; j < _messages.Count; ++j)
151 if ((_messages[j].Message == newMess.
Message) && (_messages[j].VIName == newMess.VIName))
154 if (_messages[j].Timestamp != newMess.
Timestamp)
156 _messages[j].Count += 1;
157 if (_messages[j].Count > 1000)
160 _messages[j].Count = 1000;
170 MessagesChanged =
true;
175 newMess.TimeAdded = DateTime.Now;
176 _messages.Add(newMess);
179 Seci.Helpers.ErrorLogger.LabViewError(newMess.VIName, newMess.Message);
182 MessagesChanged =
true;
186 catch (Exception err)
188 Seci.Helpers.ErrorLogger.SeciError(
"getMessageQ", err);
191 return MessagesChanged;
202 Boolean anyReplies =
false;
207 Object[] qVals = LabView.LabViewApp.GetCluster(_filePath,
"Queue");
209 List<int> repliedTo =
new List<int>();
211 for (
int i = 0; i < _messages.Count; ++i)
213 for (
int j = 0; j < qVals.GetLength(0); ++j)
215 Object[] Qmember = (Object[])qVals[j];
222 if (_messages[i].UserReplied && _messages[i].Message == Qmember[0].ToString() && _messages[i].VIName == Qmember[5].ToString())
227 Qmember[7] = _messages[i].Response;
230 else if (_messages[i].Timeout ==
true && _messages[i].Message == Qmember[0].ToString() && _messages[i].VIName == Qmember[5].ToString())
233 if (_messages[i].TimeAdded <= DateTime.Now.Subtract(
new TimeSpan(0, 0, _timeoutTime, 0, 0)))
235 if (!_messages[i].UserReplied)
245 else if (_messages[i].TimeAdded <= DateTime.Now.Subtract(
new TimeSpan(0, 0, _defaultPeriod, 0, 0)))
248 if (!_messages[i].UserReplied)
262 LabView.LabViewApp.SetCluster(_filePath,
"Queue", qVals);
265 for (
int i = repliedTo.Count - 1; i >= 0; i--)
267 if (_messages.Count > repliedTo[i])
269 _messages.RemoveAt(repliedTo[i]);
273 catch (Exception err)
275 Seci.Helpers.ErrorLogger.SeciError(
"removeMessages", err);
287 public static void SendReply(String questionMessage, String source, Boolean reply)
292 for (
int i = 0; i < _messages.Count; ++i)
294 if ((questionMessage == _messages[i].Message) && (source == _messages[i].VIName))
305 _messages[messNumb].Response = reply;
306 _messages[messNumb].UserReplied =
true;
309 Seci.Helpers.ErrorLogger.LabViewError(_messages[messNumb].VIName, _messages[messNumb].Message +
" - User replied " + _messages[messNumb].Response);
329 private int _count = 1;
334 public String Message {
get {
return _message; } set { _message = value; } }
335 public String OriginalMess {
get {
return _originalMess; } set { _originalMess = value; } }
336 public Boolean Timeout {
get {
return _timeout; } set { _timeout = value; } }
337 public Boolean WaitForResponse {
get {
return _waitForResponse; } set { _waitForResponse = value; } }
338 public String VIName {
get {
return _viName; } set { _viName = value; } }
339 public DateTime TimeAdded {
get {
return _timeAdded; } set { _timeAdded = value; } }
340 public String YesText {
get {
return _yesText; } set { _yesText = value; } }
341 public String NoText {
get {
return _noText; } set { _noText = value; } }
342 public int Priority {
get {
return _priority; } set { _priority = value; } }
343 public int Count {
get {
return _count; } set { _count = value; } }
344 public String Timestamp {
get {
return _timestamp; } set { _timestamp = value; } }
345 public Boolean Response {
get {
return _response; } set { _response = value; } }
346 public Boolean UserReplied {
get {
return _userReplied; } set { _userReplied = value; } }
Boolean _waitForResponse
Set if VI requires a response.
static void InitialiseMessQVI()
This method load the message panel VI and starts it running.
static Boolean getMessageQ()
This method get the latest message information from the messgae panel VI. The method checks for any n...
A simple custom exception used for LabVIEW exceptions
static void SendReply(String questionMessage, String source, Boolean reply)
This method handles any user replies to messages, just updates the SECI copy.
String _timestamp
Timestamp from LV.
String _message
Text to display.
This class is a wrapper for the Message Panel VI. This VI is where sample environment VIs should send...
Boolean _response
Result of the error form.
String _noText
Button 2 text (no)
int _priority
ErrorPriority.
static void ShowVI()
This method makes the message panel VI visible (only recommended when debugging). ...
Boolean _timeout
Set if error message should timeout.
static void HideVI()
This method hides the message panel VI.
static Boolean UpdateMessages()
This method is called when it is time to check for changes to the message panel VI. It checks to see if any new messages have arrived, if any old messages have timed out, and if the user has dismissed any messages.
This class is used to store the message data that is retrieved from the message panel vi...
static Boolean removeMessages()
This method checks to see if any messages have been responded to by the user or timed out...
DateTime _timeAdded
Time when added to the list.
String _originalMess
Originally received from message panel.
String _yesText
Button 1 text (yes)
String _viName
Name of VI that generated the error.
Boolean _userReplied
Set when result waiting to be sent out.