@@ -65,7 +65,7 @@ public Form1()
6565 private void Form1_Load ( object sender , EventArgs e )
6666 {
6767 //初始化日志工具
68- LogHelper = new SoftLogHelper ( )
68+ RuntimeLogHelper = new SoftLogHelper ( )
6969 {
7070 LogSaveFileName = Application . StartupPath + @"\log.txt" ,
7171 } ;
@@ -78,7 +78,7 @@ private void Form1_Load(object sender, EventArgs e)
7878 //加载账户信息
7979 UserServer . ServerAccounts . FileSavePath = Application . StartupPath + @"\accounts.txt" ;
8080 UserServer . ServerAccounts . LoadByFile ( ) ;
81- UserServer . ServerAccounts . LogHelper = LogHelper ;
81+ UserServer . ServerAccounts . LogHelper = RuntimeLogHelper ;
8282 }
8383 private void Form1_FormClosing ( object sender , FormClosingEventArgs e )
8484 {
@@ -449,6 +449,15 @@ private void DataProcessingWithStartB(AsyncStateBase object1, string object2)
449449 net_soft_update_Server . LogHelper . ClearLogText ( ) ;
450450 net_simplify_server . SendMessage ( object1 , "成功" ) ;
451451 }
452+ else if ( headCode == CommonHeadCode . SimplifyHeadCode . 运行日志查看 )
453+ {
454+ net_simplify_server . SendMessage ( object1 , RuntimeLogHelper . GetLogText ( ) ) ;
455+ }
456+ else if ( headCode == CommonHeadCode . SimplifyHeadCode . 运行日志清空 )
457+ {
458+ RuntimeLogHelper . ClearLogText ( ) ;
459+ net_simplify_server . SendMessage ( object1 , "成功" ) ;
460+ }
452461 else
453462 {
454463 net_simplify_server . SendMessage ( object1 , object2 ) ;
@@ -680,9 +689,9 @@ private void MelsecNetMultiInnitialization()
680689 IpEndPoints . Add ( new System . Net . IPEndPoint ( System . Net . IPAddress . Parse ( "192.168.10." + i ) , 6000 ) ) ;
681690 }
682691
683- //每隔1000秒钟访问一次
692+ //每隔1秒钟访问一次
684693 MelsecMulti = new HslCommunication . Profinet . MelsecNetMultiAsync ( 0 , 0 , HslCommunication . Profinet . MelsecDataType . D , 6000 , 20 , 700 , 1000 , IpEndPoints . ToArray ( ) ) ;
685- MelsecMulti . OnReceivedData += MelsecMulti_OnReceivedData ;
694+ MelsecMulti . OnReceivedData += MelsecMulti_OnReceivedData ; //所有机台的数据都返回时触发
686695 }
687696
688697 private void MelsecMulti_OnReceivedData ( byte [ ] object1 )
@@ -696,7 +705,13 @@ private void MelsecMulti_OnReceivedData(byte[] object1)
696705 * 每台设备的前两个字节都为0才说明本次数据访问正常,为0x00,0x01说明连接失败,其他说明说明三菱本身的异常
697706 *
698707 ********************************************************************************************/
708+ for ( int i = 0 ; i < 100 ; i ++ )
709+ {
710+ int startIndex = i * 42 ;
711+ ushort netState = BitConverter . ToUInt16 ( object1 , startIndex ) ; //为0,说明数据正常,不为0说明网络访问失败或是指令出错
699712
713+
714+ }
700715 }
701716
702717
@@ -711,6 +726,6 @@ private void MelsecMulti_OnReceivedData(byte[] object1)
711726 /// <summary>
712727 /// 用来记录一般的事物日志
713728 /// </summary>
714- private SoftLogHelper LogHelper { get ; set ; }
729+ private SoftLogHelper RuntimeLogHelper { get ; set ; }
715730 }
716731}
0 commit comments