Przeglądaj źródła

GSI 현장 업데이트

SK.Kang 6 lat temu
rodzic
commit
2ea40f8782

+ 0 - 5
Dev/Connection/OHVProtocolServer/OHVConnector/Manager.cs

@@ -331,11 +331,6 @@ namespace OHVConnector
                 stx = h.ReadByte(); //STX
             }
             while ( stx != STX );
-            if ( stx == 0xBF )
-            {
-                OnLog( this.Config.ID, $"{stx}" );
-                return;
-            }
 
             string revID = string.Empty;
             string sendID = string.Empty;

+ 2 - 1
Dev/Connection/OHVProtocolServer/OHVConnector/OCSMessage.cs

@@ -104,7 +104,8 @@ namespace OHVConnector
             mb.AppendAscii( this.Kind.ToString() );
             mb.AppendAscii( this.Tag );
             mb.AppendAscii( MakeSubcode() );
-            mb.Append( GetCheckSum( mb.ToBytes ) );
+            string checkSum = Convert.ToString( GetCheckSum( mb.ToBytes ), 16 ).ToLower();
+            mb.AppendAscii( checkSum );
             mb.Append( ETX );
 
             return mb;

+ 8 - 9
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -926,15 +926,15 @@ namespace VehicleControlSystem.ControlLayer
                 return false;
             }
 
-            this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
+            this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
             result = this.PIOAndLoad( sub.TargetID );
             if ( result != 0 )
             {
-                this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
+                this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
                 this.OccurVehicleAlarm( result );
                 return false;
             }
-            this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
+            this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
 
             result = this.clamp.Lock_Sync();
             if ( result != 0 )
@@ -971,16 +971,16 @@ namespace VehicleControlSystem.ControlLayer
                 return false;
             }
 
-            this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
+            this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
 
             result = this.PIOAndUnload( sub.TargetID );
             if ( result != 0 )
             {
-                this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
+                this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
                 this.OccurVehicleAlarm( result );
                 return false;
             }
-            this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
+            this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
 
             sql.CommandDAL.UpdateState( sub.CmdID, eCommandState.Complete );
             sql.SubCmdDAL.Delete( sub );
@@ -994,11 +994,11 @@ namespace VehicleControlSystem.ControlLayer
         {
             this.VehicleStateProperty = eVehicleState.Charge;
 
-            this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
+            this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
 
             this.PIOBatteryCharge( subCmd );
 
-            this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
+            this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
 
             sql.CommandDAL.UpdateState( subCmd.CmdID, eCommandState.Complete );
             sql.SubCmdDAL.Delete( subCmd );
@@ -1029,7 +1029,6 @@ namespace VehicleControlSystem.ControlLayer
             if ( !this.iO.IsOn( "IN_PIO_READY" ) )
             {
                 loggerPIO.E( "[Port] - 1 Ready not On" );
-                this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
                 this.OccurVehicleAlarm( 25 );
                 return 0;
             }

+ 56 - 32
Dev/OHV/VehicleControlSystem/Managers/PhysicalCheckupLogger.cs

@@ -49,15 +49,13 @@ namespace VehicleControlSystem.Managers
                 await ftp.ConnectAsync( token );
 
                 // upload a folder and all its files
-                await ftp.UploadDirectoryAsync( @"C:\LOG\OHV\Vehicle\PhysicalCheckup\", @"/DriveInfo", FtpFolderSyncMode.Update );
+                await ftp.UploadDirectoryAsync( @"C:\LOG\FTP\", @"/DriveLog", FtpFolderSyncMode.Update );
 
                 // upload a folder and all its files, and delete extra files on the server
                 //ftp.UploadDirectory( @"C:\website\assets\", @"/public_html/assets", FtpFolderSyncMode.Mirror );
 
                 //ToDo: Delete Files
             }
-
-
         }
 
         public void DownloadPLCLog()
@@ -66,17 +64,24 @@ namespace VehicleControlSystem.Managers
             {
                 ftp.Connect();
 
-
                 // download a folder and all its files
-                ftp.DownloadDirectory( @"C:\website\logs\", @"/public_html/logs", FtpFolderSyncMode.Update );
+                ftp.DownloadDirectory( @"C:\LOG\FTP\", @"/0_CARD/log0/", FtpFolderSyncMode.Update );
 
                 // download a folder and all its files, and delete extra files on disk
                 //await ftp.DownloadDirectoryAsync( @"C:\website\dailybackup\", @"/public_html/", FtpFolderSyncMode.Mirror );
 
-                ftp.DeleteFile( "/full/or/relative/path/to/file" );
+                //ftp.DeleteFile( "/full/or/relative/path/to/file" );
             }
         }
 
+        public void FTPServerDeleteFile()
+        {
+            using ( var ftp = new FtpClient( "192.168.0.20", "KV", "1234" ) )
+            {
+                ftp.Connect();
+                ftp.DeleteDirectory( "/0_CARD/log0/" );
+            }
+        }
 
         /// <summary>
         /// 주행 시작 시 진단 PLC Bit On
@@ -84,22 +89,31 @@ namespace VehicleControlSystem.Managers
         /// <returns></returns>
         public bool SetPLCStartDrive()
         {
-            this.h.Connect( new TcpComm
+            try
             {
-                Active = true,
-                Ip = this.PLCAddress,
-                PortNo = this.PLCPort,
-            } );
-
-            if ( !h.Connected )
+                var h = new TcpConnector();
+                h.Connect( new TcpComm
+                {
+                    Active = true,
+                    Ip = this.PLCAddress,
+                    PortNo = this.PLCPort,
+                } );
+
+                if ( !h.Connected )
+                    return false;
+
+                var mb = new MemoryBuffer();
+                mb.AppendAscii( "WR MR100 1" );
+                mb.Append( CR );
+                this.h.WriteFlush( mb.ToBytes );
+
+                h.CloseSocket();
+            }
+            catch ( Exception e)
+            {
+                logger.E( $"[PLC] - Set Value Connection Error {e}" );
                 return false;
-
-            var mb = new MemoryBuffer();
-            mb.AppendAscii( "WR MR100 1" );
-            mb.Append( CR );
-            this.h.WriteFlush( mb.ToBytes );
-
-            h.CloseSocket();
+            }
 
             return true;
         }
@@ -110,22 +124,32 @@ namespace VehicleControlSystem.Managers
         /// <returns></returns>
         public bool ResetPLCStartDrive()
         {
-            this.h.Connect( new TcpComm
+            try
             {
-                Active = true,
-                Ip = this.PLCAddress,
-                PortNo = this.PLCPort,
-            } );
+                var h = new TcpConnector();
+                h.Connect( new TcpComm
+                {
+                    Active = true,
+                    Ip = this.PLCAddress,
+                    PortNo = this.PLCPort,
+                } );
 
-            if ( !h.Connected )
-                return false;
+                if ( !h.Connected )
+                    return false;
 
-            var mb = new MemoryBuffer();
-            mb.AppendAscii( "WR MR100 0" );
-            mb.Append( CR );
-            this.h.WriteFlush( mb.ToBytes );
+                var mb = new MemoryBuffer();
+                mb.AppendAscii( "WR MR100 0" );
+                mb.Append( CR );
+                this.h.WriteFlush( mb.ToBytes );
 
-            h.CloseSocket();
+                h.CloseSocket();
+
+            }
+            catch ( Exception e )
+            {
+                logger.E( $"[PLC] - Reset Value Connection Error {e}" );
+                return false;
+            }
 
             return true;
         }