Gammatech Posted July 12, 2010 Share Posted July 12, 2010 Hello, I have periodic text messages coming into the system on the serial line from a remote operator. Currently I put them into a Channel called TextMsg (with only 25 history) so that they are all in the order that they came in with the latest one at row zero. On a user page I have a Table component that has FormatDateTime("%a %d %b %Y %H:%M:%S",TextMsg.Time) as the Second column and TextMsg as the Third column. Is there a way to display the Row number similar to the channel view in the first column? The reason for asking is that what I really want is for the user to select a message from those displayed, and be able to acknowledge it, and therefore set the time that it was acknowledged in another column. Possibly also delete it and even delete all. So that potentially there could be a dialogue between the DAQfactory system and the operator at the remote device. I already have a system to send preset replies or free format replies from the DAQFactory system. I have also tried it using a string array 'TextMsgList' but here I have to keep track of the size of the array and generally mess about so a channel seems the simplest method. I think I can store the Acknowledge time in an array which is indexed the same as the TextMsg Channel but would appreciate any suggestions. I wondered if the Alarm system could be used as it already has times for acknowledge and receipt(fired etc) Again any suggestions would be appreciated. Martin Link to comment Share on other sites More sharing options...
AzeoTech Posted July 12, 2010 Share Posted July 12, 2010 First, you can number your rows by making the first column expression something like: seqadd(1,numrows(textMsg),1) You probably can't use the alarm system if the names vary. If there were a preset number of possible names, then the alarm system would be the way to go possibly. Just create an alarm for each name and trigger them on a variable for each and have the incoming data processor set that variable when it sees a name. The thing is that alarm acknowledgement is for ALL alarms. You can't ack just one alarm when another is fired. If you choose not to use alarms, I'd probably use DAQFactory OOP, though perhaps not so much the object part but the structure part. With OOP you can create a structure to store all the parameters of a particular message. It'd look something like: class message local string message local messageTime local ackTime endclass and whatever else you want in there. Then when a message comes in you can do: private tempMessage = new(message) message.message = "abc" message.messageTime = systime() message.ackTime = 0 messages.addvalue(message) where messages is some global array (not string array). To get access to a particular message, just index into the array: messages[0].message In the table, don't index: messages.message Using this method will eliminate the issues with lining up multiple arrays. Link to comment Share on other sites More sharing options...
Gammatech Posted August 10, 2010 Author Share Posted August 10, 2010 Hello, I have been trying to get to grips with the suggestion to use the class structure for my messaging system. In my Initialization sequence that is autorun I have the following Class definition: Class TextMessage Local String ThisMessage = "Empty Message" Local MessageTime = SysTime() Local AckTime = 0 Local Number = 0 EndClass I also define a global variable to hold the individual messages of the above defined class Global MessageList In the continuously running loop that gets the incoming message from the serial line I have the code: // Instantiate the class Private TempMessage = New(TextMessage) // insert the latest message into the String field of the class structure TempMessage.ThisMessage = NewCleanMessage TempMessage.MessageTime = SysTime() TempMessage.AckTime = 0 TempMessage.Number = 1 // insert the class structure into the global list MessageList.AddValue(TempMessage) I also handle the message as I used to, inserting it into a string array NewCleanMessage = InsertTime(NewCleanMessage, SysTime(), -1) TextMsgList.InsertAt(0,NewCleanMessage) // bump on the Ack time list so that it stays synchronised TextMsgAckTime.InsertAt(0,"") so I know the messaging system is working. A table component having the global list array MessageList remains empty even as messages keep coming in as shown by my old system as above. The Table component has MessageList.TextMessage.Number in the first field, MessageList.TextMessage.NewMessage in the second field, MessageList.TextMessage.MessageTime in the third field and MessageList.TextMessage.AckTime in the fourth field. As text messages come into the system there is no change to the table and a Watch of the variables shows that MessageList as blank all of the time, implying it is declared but empty and any of the structure elements such as MessageList.TextMessage.ThisMessage show as C1000 channel or function not found. Where am I going wrong? Martin Link to comment Share on other sites More sharing options...
AzeoTech Posted August 11, 2010 Share Posted August 11, 2010 Class names are only used in the new() function. The syntax to access the fields of MessageList are for example: MessageList.thisMessage not: MessageList.TextMessage.thisMessage Link to comment Share on other sites More sharing options...
Gammatech Posted August 20, 2010 Author Share Posted August 20, 2010 Watching the global variable MessageList shows that this always stays blank, implying that it is declared but is empty. Watching MessageList.ThisMessage shows C1000 Channel or function not found just as my checks before. The table component also appears empty with all of the fields reduced to MessageList.ThisMessage for example as you explained above. This implies one or more of the code for the Class definition or the code for the loading of the elements of the class or the addition of the latest instance of the class to the global MessageList is wrong but as a novice to this type of structure I can't see any differences to the details from posts and manuals. Watching the initialised class structure TextMessage also shows C1000 Channel or function not found Adding a declaration in my autorun Initialisation Sequence Global TempMessage = New(TextMessage) doesn't throw up any errors and watching TempMessage shows Object(s) Any Ideas? Martin Link to comment Share on other sites More sharing options...
AzeoTech Posted August 20, 2010 Share Posted August 20, 2010 Maybe addvalue() isn't working. Try using insertAt(0,... ) instead. Also do NumRows(MessageList) to see if its growing Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.