• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

Sending data to instrument after receiving query messages

Started by ateequeali, November 09, 2018, 02:04:30 pm

Previous topic - Next topic

ateequeali

Hi,

The instrument sends us Query messages which we store. We parse those messages and send order messages based on those to the machine in a seperate thread. We have encountered an issue where the first few order messages are processed successfully by the instrument but some order messages error out stating Header record missing or Invalid Terminator Code. From the application point of view, all records are being sent for the order messages, however the header record appears to be missing when looking at the instrument log.

We believe that the reason for the issue might be the thread we are using, such that the main thread for nrComm is receiving messages which the seperate thread is simultaneously sending messages. The reason for using a seperate thread is because we are unable to send messages to the instrument after session ends as we don't have control over the nrComm library. Is there any event that is raised after a message is successfully received and the session is closed? Our main requirement is to send order messages in response to query messages received from the instrument.


Roman Novgorodov

Hello

Thank you for detailed description.
But some things still are not clear for me.

Can you show a protocol description or specification?

If you are working with something like ASTM, you can see NrAstm.SessionStart and NrASTM.SessionEnd events.

Protocol can not depend on speed of reply, because serial line can lost data and has low speed.
Usual any protocol waits a timeout and you need to form reply in this interval.

Please note that NrComm used in several serious projects those implement varous tasks for control external devices with different protocols (Modbus, Kermit, Wid and some other custom protocols). And all works well if implemented correctly :-).

Shortly I need to see protocol and simple demo with your implementaiton.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

ateequeali

Thank you for your response. We are working with ASTM and using the NrAstm library.
We did use NrAstm.SessionStart and NrAstm.SessionEnd events before creating and sending the Header, Patient, Order and Trailer records. We are doing a NrAstm.WaitForAck after sending each record. However, would it be an issue if we did not do a NrAstm.WaitForAck for SessionStart? We just noticed that the receiver sends an ACK for the ENQ signal sent by Sender. Does NrAstm.SessionStart send an ENQ signal out to the receiver?

Outline of our implementation below:
Connect to port - NrComm.Active = true
Receiving data using following events in NrAstm - OnBeginSession, OnDataFrame, OnRecord and OnEndSession
Message is then stored into a database in OnEndSession

Sending Data:
We read from the database and look for query messages received in a seperate thread
When query message is found; we start a session using NrAstm.SessionStart and then create and send Header, Patient, Order and Trailer records seperately and lastly we do a NrAstm.SessionEnd after sending the Trailer record.  We do a NrAstm.WaitForAck after sending each record.

Let me know if you see any issue with this implementation.

Your help is greatly appreciated.

Roman Novgorodov

Hello

You description looks correct.
Also you can try to use OnACK event handler instead WaitForAck.

Roman Novgorodov
DeepSoftware llc.
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

ateequeali

Thanks for the help, Roman. We got it to work. Our issue was that we were not processing the Ack recieved on SessionStart.

ateequeali

Hi Roman,

It appears we are having an issue with the DataFrames. When sending multiple messages, the record sequence number seems to be getting reset, although the records for the message are being sent in the same session. e.g.
Session Start
Send Header - Header record is sent as 1H
Send Patient - Patient record is being sent as 1P instead of 2P
Send Order - Order record is sent as 2O instead of 3O
Send Delimiter - Delimiter record is send as 3L instead of 4L
Session End

Can you tell me why this is so?

Roman Novgorodov

Hello

Can you post here log the file of whole process?
I will see sequence of called Astm methods.

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.