Forum Replies Created
-
AuthorPosts
-
JW
ParticipantHi Mikhail,
Recently when I implementing a TCP protocol, I encounter a problem with similar symptoms of this Modbus issue.
I am going to use the Modbus error as example. I label the following error message with line number.
————————————–
1. Request element group “ch1.011”
2. Send (12): 05 42 00 00 00 06 01 03 04 4C 00 64
3. Receive (7 / 7): 05 42 00 00 00 CB 01
4. Receive (202 / 202): 03 C8 42 0A 8A 3D 42 0A E6 66 42 0B 41 89 42 0B 9C AC ….
5. OK!
6. Request element group “ch1.012”
7. Send (12): 05 43 00 00 00 06 01 03 04 4C 00 64
8. Receive (0 / 7):
9. Communication error!
10. Request element group “ch1.012”
11. Send (12): 05 44 00 00 00 06 01 03 04 4C 00 64
12. Receive (7 / 7): 05 43 00 00 00 CB 01
13. Incorrect MBAP Header data!
14. Request element group “ch1.012”
15. Send (12): 05 45 00 00 00 06 01 03 04 4C 00 64
16. Receive (7 / 7): 03 C8 42 IA FC EE 42
17. Incorrect MBAP Header data!18. 2021-01-11 23:28:40 Disconnect from 127.0.0.1
————————————–Line 7 sent a request(05 43) but did not get proper reply.
Line 11 sent a new request(05 44). then line 12 receive data(05 43), but which is the reply of header of line 7 request(05 43). it was considered incorrect because it did not match with line 12 request.
Line 15 sent a new request again. then line 16 receive data, which is the body of the reply of header of line 7 request(05 43). it was considered incorrect again because it did not match with line 12 request nor the header format.The reason I got this error is as follow. (I guess the Modbus driver may have similar issue but not sure).
For such small amount of data, I assumed it will be always receive at 1 try.
So I use sock.recv(7) to get header, then calculate the length of data from header, e.g. 0xCB = 203, the reset of data should be 203-1=202, then I use sock.recv(202) to get the rest of the data body.But I found very rarely, it will only get e.g. maybe 100 bytes of data on sock.recv(202) or 5 bytes on sock.recv(7). This will not only create 1 error of incomplete reply, but also messed up the following sequence.
So I changed to use a while loop to receive data, to make I received the proper length of data. something like the sudo code below.
recv_data = bytearray()
while recv_data_length < expected_length:
recv_data += sock.recv(expected_length-recv_data_length)JW
Participant哪个版本的SCADA?
28000点中,使用函数的有多少? 我以前测试的情况是超过12000点使用函数,scadasever会崩溃,后来版本更新,好像可以使用更多一些。
我也有很多项目是2万点以上,但是大部分是没有函数的,暂时没有遇到这个问题。
另外可以检查自定义函数里面是否有不停创建新对象。
JW
Participant可以考虑以下几个措施同时采用
1. 对应的Channel不勾选Event on undefined;
2. Instance -> Server -> Saving parameters -> Unreliable on inactive 选择 disable, 或者根据需要设置1小时等长时间;
3. 对应的Channel设置以下公式,如果返回值是nan,会保留上一轮的值而不更新返回的值。
double.IsNaN(Cnl)?Val():Cnl
JW
Participant读取或计算得出的Val为NaN的话,会自动设置对于Stat为0,是某个版本开始加入的特性。
JW
Participant不要勾选Input channel的Event on undefined。
例如Modbus通信偶尔某次获取不到内容,对应通道Stat会变成0,如勾选了上述选项,会出现undefined事件。然后下次通讯成功获取信号后,会出现Normal事件。
JW
Participanttested both solutions, decided to use 2nd one.
the 1st one is more elegant but create a lot of log in auto control module event canceling the cmd.
the 2nd one is cumbersome when need to control a lot of relay points, but no other side effects.JW
Participantchanging the value of input channel doesn’t send command to linked output channel.
if you need auto sync, you will need auto control module.
if you just want to send cmd to device and set value of an input channel at the same time once you press a button, you can create a formula
int CmdExample(int c, int v) { SetVal(c,v); return v; }
set the device and cmd number of out channel 60000 same as out channel 21094
and enable formula of out channel 60000,
CmdExample(11094,5)
JW
ParticipantFor an event triggered by “Event on change”, the alarm message will be “Changed: #Vlaues”, this type of event won’t be in notifications.
I was just going ask about the crash on Linux server, is there any hope of fixing it or work around it?
error log of apache, for reference
[Fri Jul 16 20:42:33.128172 2021] [mpm_event:notice] [pid 4658:tid 140639949528128] AH00489: Apache/2.4.41 (Ubuntu) mod_mono/3.13 configured -- resuming normal operations [Fri Jul 16 20:42:33.128242 2021] [core:notice] [pid 4658:tid 140639949528128] AH00094: Command line: '/usr/sbin/apache2' [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: The namespace '' is not defined. Parameter name: namespaceUri at System.Xml.XmlBaseWriter.GetQualifiedNamePrefix (System.String namespaceUri, System.Xml.XmlDictionaryString xNs) [0x0003c] in <f996495ece6841e5bb72faf597645519>:0 at System.Xml.XmlBaseWriter.WriteQualifiedName (System.String localName, System.String namespaceUri) [0x0004d] in <f996495ece6841e5bb72faf597645519>:0 at System.ServiceModel.Channels.MessageFault.WriteFaultCode (System.Xml.XmlDictionaryWriter writer, System.ServiceModel.EnvelopeVersion version, System.ServiceModel.FaultCode code, System.Boolean sub) [0x000d4] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.MessageFault.WriteTo (System.Xml.XmlDictionaryWriter writer, System.ServiceModel.EnvelopeVersion version) [0x0001a] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.MessageFaultBodyWriter.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00012] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.BodyWriter.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.SimpleMessage.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.Message.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x0001e] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.Message.WriteBody (System.Xml.XmlDictionaryWriter writer) [0x00019] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.Message.OnWriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00059] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.Message.WriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00023] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.Message.WriteMessage (System.Xml.XmlWriter writer) [0x00007] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.WebMessageEncoder.WriteMessage (System.ServiceModel.Channels.Message message, System.IO.Stream stream) [0x000b1] in <5e7508d802c343d7b5ac28643e57b1dd>:0 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, System.TimeSpan timeout) [0x0003c] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, System.TimeSpan timeout) [0x00000] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x0000d] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (System.ServiceModel.Channels.IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0004b] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (System.IAsyncResult result) [0x00017] in <9513a2bb927146ddaa343ddc8a95d9c0>:0 at (wrapper managed-to-native) System.Runtime.Remoting.Messaging.AsyncResult.Invoke(System.Runtime.Remoting.Messaging.AsyncResult) at System.Runtime.Remoting.Messaging.AsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <533173d24dae460899d2b10975534bb0>:0 at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <533173d24dae460899d2b10975534bb0>:0 at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <533173d24dae460899d2b10975534bb0>:0 [Fri Jul 16 20:42:40.322492 2021] [:error] [pid 4663:tid 140639836563200] (70014)End of file found: read_data failed [Fri Jul 16 20:42:40.322532 2021] [:error] [pid 4663:tid 140639836563200] Command stream corrupted, last command was 1 [Fri Jul 16 20:42:40.340810 2021] [:error] [pid 4664:tid 140639929997056] (70014)End of file found: read_data failed [Fri Jul 16 20:42:40.340854 2021] [:error] [pid 4664:tid 140639929997056] Command stream corrupted, last command was 1 [Fri Jul 16 20:42:40.340888 2021] [:error] [pid 4664:tid 140639836563200] (104)Connection reset by peer: read_data failed [Fri Jul 16 20:42:40.340922 2021] [:error] [pid 4664:tid 140639836563200] Command stream corrupted, last command was -1
JW
ParticipantHi Mikhail, I am trying out this module
what’s the function of <ParamIDs></ParamIDs> tag? couldn’t understand the description of this tag.
Is it possible to limit the notification to certain channels only? e.g. I have 100 channels that cloud generated events. but I only want the notification module to make sound according to 3 channels.
Is is possible to have event on status 4 changed?
JW
Participantthanks Romiros, works perfectly!
JW
ParticipantI came up with the following solution.
One downside is that I can’t see which channels are called in the channel formula, but not a big deal.in dictionaries/formulas, declare the arrays I need to use,
public static int[] lst_1 = new int[]{1}; public static int[] lst_2 = new int[]{1,2}; public static int[] lst_3 = new int[]{1,2,3}; public static int[] lst_4 = new int[]{1,2,3,4};
then in channels,
LeakValList(lst_1) LeakValList(lst_2)
JW
ParticipantThanks Mikhail.
what’s the proper way to pass an array to a formula as input, while the size of array is not constant.
the input is usually multiple channel numbers. e.g. it can be {11,12} or {11,12,13}
JW
ParticipantQ1:
for real/discrete channel, Cnl and Val() are value before and after formula calculation;
but for calculated real/discrete, what’s the Cnl? last value or same as Val()?Q2:
Is it possible to return Val and Stat at the same time using 1 formula?JW
ParticipantChannel settings:
the value can be 0,1,2,3
the stat can be 0,121,122,123
https://drive.google.com/file/d/1IXNixhZteaGPdD4zrm4qe3Q6wMCXM3lJ/view?usp=sharing———————
Formulas:int LeakValList(int [] lst) { int na = 0; int active = 0; int inactive = 0; int normal = 0; for (int i = 0; i < lst.Length; i++) { if (Val(lst[i]) == 1) {active ++;} else if (Val(lst[i]) == 2) {inactive ++;} else if (Val(lst[i]) == 3) {normal ++;} else {na++;} } if (active > 0) {return 1;} else if (inactive > 0) {return 2;} else if (normal > 0) {return 3;} else {return 0;} } int LeakStat() { int s = (int) Val(); if (s > 0) {s = s + 120;} return s; }
I was using Cnl, now replaced with Val() for stat calculation, but seems the same.
-
This reply was modified 4 years, 2 months ago by
JW.
JW
ParticipantI encountered this issue too.
My solution is adding numbering to the beginning of each item to make sure them are in order.
The pro is the view id don’t need to be in order when you add more views.
The draw back is the title can become very long is there is many levels.
e.g.1. Overview of all sites 2. Site A/2.1. Option1 2. Site A/2.2. Option2 3. Site A/3.1. Option1 3. Site A/3.2. Option2
-
This reply was modified 4 years, 2 months ago by
-
AuthorPosts