DESKTOP-Kang před 6 roky
rodič
revize
f3818a60df

binární
Dev/OHV/Assambly/OHVConnector.dll


binární
Dev/OHV/Assambly/OHVConnector.pdb


+ 1 - 1
Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml

@@ -203,7 +203,7 @@
                         <Grid Grid.Row="1">
                             <Border BorderBrush="{x:Null}" BorderThickness="2" Margin="5"/>
                             <StackPanel VerticalAlignment="Top"  HorizontalAlignment="Center">
-                                <TextBlock Text="{Binding CurrentTag, Fal-lbackValue=0.00}" FontSize="20" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                <TextBlock Text="{Binding CurrentTag, FallbackValue=0.00}" FontSize="20" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                             </StackPanel>
                         </Grid>
                     </Grid>

+ 0 - 185
Dev/OHV/VehicleControlSystem/ControlLayer/DB/Redis.cs

@@ -1,185 +0,0 @@
-using GSG.NET.Extensions;
-using GSG.NET.ObjectBase;
-using OHV.Common.Shareds;
-using StackExchange.Redis;
-using System;
-using System.Threading;
-
-namespace VehicleControlSystem.ControlLayer.DB
-{
-    public class Redis : SingletonBase<Redis>, IDisposable
-    {
-        ConnectionMultiplexer redisMaster = null;
-        IDatabase database = null;
-
-        private Redis()
-        {
-        }
-
-        public void Dispose()
-        {
-            this.redisMaster.Dispose();
-        }
-
-        public void Init()
-        {
-            redisMaster = ConnectionMultiplexer.Connect( "127.0.0.1:6379" + ",allowAdmin=true,password=..." );
-            database = redisMaster.GetDatabase();
-        }
-
-        public bool SetValue(string key, string val) => database.StringSet( key, val );
-        public string GetValue( string key ) => database.StringGet( key );
-        //public int GetIntValue( string key ) => cacheClient.Get<int>( key );
-
-
-        #region GetLogData
-
-        /// <summary>
-        /// 0.1% 단위
-        /// 100% 1.9Nm
-        /// </summary>
-        /// <returns></returns>
-        public double TorqueFront()
-        {
-            return LoadFacterFront() * 1.9 / 100;
-        }
-
-        /// <summary>
-        /// 0.1% 단위 
-        /// </summary>
-        /// <returns></returns>
-        public double TorqueRear()
-        {
-            return LoadFacterRear() * 1.9 / 100;
-        }
-
-        public double LoadFacterFront()
-        {
-            var ret = database.HashGet( "7028", "7" );
-            return Math.Abs( CastTo<double>.From<RedisValue>( ret ) * 0.1 ); 
-        }
-
-        public double LoadFacterRear()
-        {
-            var ret = database.HashGet( "7028", "7" );
-            return Math.Abs( CastTo<double>.From<RedisValue>( ret ) * 0.1 );
-        }
-
-        public double ActualVelocityToFrontRPM()
-        {
-            var ret = database.HashGet( "7026", "7" );
-            return CastTo<double>.From<RedisValue>( ret ) * 60 * 10 / ( 2 * Math.PI ) / 0.06;
-        }
-        public double ActualVelocityToRearRPM()
-        {
-            var ret = database.HashGet( "7026", "8" );
-            return CastTo<double>.From<RedisValue>( ret ) * 60 * 10 / ( 2 * Math.PI ) / 0.06;
-        }
-        public double ActualVelocityToSpeed()
-        {
-            var ret = database.HashGet( "4034", "7" );
-            return CastTo<double>.From<RedisValue>( ret ) * 0.0001; //m/sec
-        }
-
-        public int CurrentBCRValue()
-        {
-            var ret = database.HashGet( "7121", "7" );
-            return CastTo<int>.From<RedisValue>( ret );
-        }
-
-        public bool GetDriveMove()
-        {
-            var ret = database.HashGet( "3011", "7" );
-            if ( ret == 0 )
-                return false;
-            else
-                return true;
-        }
-
-        #endregion
-
-        #region Event
-        /// <summary>
-        /// Jog 사용 시
-        /// </summary>
-        /// <param name="dir">1=Forward, -1=Backward, 0=Stop</param>
-        /// <returns></returns>
-        public bool SetManualOPCommand(int dir ) => database.HashSet( "4091", "7", dir.ToString() );
-
-        /// <summary>
-        ///  Servo Motor Control
-        /// </summary>
-        /// <param name="cmd">1=On, 2=Off, 3=Stop, -1=Fault Reset</param>
-        /// <returns></returns>
-        public bool SetServoCommand( int cmd ) => database.HashSet( "4092", "7", cmd.ToString() );
-
-        /// <summary>
-        /// System Operation Change
-        /// </summary>
-        /// <param name="op">-1=NoEvent, 0=open, 1=start, 2=goAutoOP, 3=goManualOP, 4=close, 5=finish</param>
-        /// <returns></returns>
-        public bool SetSystemOperation( int op ) => database.HashSet( "112", "7", op.ToString() );
-
-        public bool RouteMapMoveTo(string point )
-        {
-            database.HashSet( "3033", "7", point );
-            Thread.Sleep( 50 );
-            return database.HashSet( "3031", "7", 1 );
-        }
-
-        #endregion
-
-        public int GetCurrentPoint()
-        {
-            var ret =  database.HashGet( "3012", "7" );
-            return CastTo<int>.From<RedisValue>( ret );
-        }
-
-        /// <summary>
-        /// Steering 뱡향 요청
-        /// </summary>
-        /// <returns>1=Left, -1=Right, 0=현상유지</returns>
-        public int GetSteering()
-        {
-            var ret = database.HashGet( "3050", "7" );
-            return CastTo<int>.From<RedisValue>(ret);
-        }
-
-        /// <summary>
-        /// Steering 뱡향 상태 쓰기
-        /// </summary>
-        /// <returns>1=Left, -1=Right, 0=Error</returns>
-        public bool SetActualSteeringPos( eSteeringState state )
-        {
-            int sV = 0;
-            switch ( state )
-            {
-                case eSteeringState.None:
-                    sV = 0;
-                    break;
-                case eSteeringState.Left:
-                    sV = 1;
-                    break;
-                case eSteeringState.Right:
-                    sV = -1;
-                    break;
-                default:
-                    break;
-            }
-            return database.HashSet( "3060", "7", sV );
-        }
-
-        /// <summary>
-        /// System State
-        /// </summary>
-        /// <returns>0=StartUp, 1=DeviceOpened, 2=DiviceOpenFailed, 3=ManualOP, 4=AutomaticOp, 5=DeviceCloseed, 6=Finished</returns>
-        public int GetSystemState()
-        {
-            var ret = database.HashGet( "111", "7" );
-            return CastTo<int>.From<RedisValue>(ret);
-        }
-
-
-
-}
-}

+ 13 - 76
Dev/OHV/VehicleControlSystem/ControlLayer/Motion/GSIDrive.cs

@@ -40,39 +40,8 @@ namespace VehicleControlSystem.ControlLayer.Drive
         private double currentTorque = 0;
         public double CurrentTorque { get { return currentTorque; } set { SetField( ref this.currentTorque, value ); } }
 
-        double frontLoadFactor = 0;
-        public double FrontLoadFactor
-        {
-            get { return this.frontLoadFactor; }
-            set { SetField( ref this.frontLoadFactor, value ); }
-        }
-
-        double frontRpm = 0;
-        public double FrontRpm
-        {
-            get { return this.frontRpm; }
-            set { SetField( ref this.frontRpm, value ); }
-        }
-
-        double rearLoadFactor = 0;
-        public double RearLoadFactor
-        {
-            get { return this.rearLoadFactor; }
-            set { SetField( ref this.rearLoadFactor, value ); }
-        }
-
-        double rearRpm = 0;
-        public double RearRpm
-        {
-            get { return this.rearRpm; }
-            set { SetField( ref this.rearRpm, value ); }
-        }
-
         public bool IsErrorOn { get; set; }
 
-        eSteeringState reqSteeringState = eSteeringState.None;
-        public eSteeringState ReqSteeringState { get { return this.reqSteeringState; } set { SetField( ref this.reqSteeringState, value ); } }
-
         private eDriveServoState driveServoState;
         public eDriveServoState DriveServoState
         {
@@ -126,19 +95,19 @@ namespace VehicleControlSystem.ControlLayer.Drive
 
             switch ( property.Name )
             {
-                case "RequestSteering":
-                    {
-                        var v = CastTo<eSteeringState>.From<object>( newValue );
-                        this.ReqSteeringState = v;
-                    }
-                    break;
-
-                case "CurrentPointNo":
-                    {
-                        var v = CastTo<int>.From<object>( newValue );
-                        this.CurrentTag = v;
-                    }
-                    break;
+                //case "RequestSteering":
+                //    {
+                //        var v = CastTo<eSteeringState>.From<object>( newValue );
+                //        this.ReqSteeringState = v;
+                //    }
+                //    break;
+
+                //case "CurrentPointNo":
+                //    {
+                //        var v = CastTo<int>.From<object>( newValue );
+                //        this.CurrentTag = v;
+                //    }
+                //    break;
                 case "RearLoadFactor":
                     {
                         var v = CastTo<double>.From<object>( newValue );
@@ -214,38 +183,6 @@ namespace VehicleControlSystem.ControlLayer.Drive
             }
         }
 
-        void LoggingState()
-        {
-            var currentBCR = Redis.Instance.CurrentBCRValue();
-            var speed = Redis.Instance.ActualVelocityToSpeed();
-
-            var fTorque = Redis.Instance.TorqueFront();
-            var fRPM = Redis.Instance.ActualVelocityToFrontRPM();
-            var fLoadFacter = Redis.Instance.LoadFacterFront();
-            PhysicalCheckupLogger.Instance.FrontWheelLogging( speed.ToString(), fTorque.ToString(), fRPM.ToString(), fLoadFacter.ToString(), currentBCR.ToString() );
-
-            var fState = new DriveState();
-            fState.DirveName = "Front";
-            fState.Speed = speed;
-            fState.Torque = fTorque;
-            fState.Rpm = fRPM;
-            fState.Loadage = fLoadFacter;
-            this.FrontDriveState = fState;
-
-            var rTorque = Redis.Instance.TorqueRear();
-            var rRPM = Redis.Instance.ActualVelocityToRearRPM();
-            var rLoadFacter = Redis.Instance.LoadFacterRear();
-            PhysicalCheckupLogger.Instance.RearWheelLoggging( speed.ToString(), rTorque.ToString(), rRPM.ToString(), rLoadFacter.ToString(), currentBCR.ToString() );
-
-            var rState = new DriveState();
-            rState.DirveName = "Rear";
-            rState.Speed = speed;
-            rState.Torque = rTorque;
-            rState.Rpm = rRPM;
-            rState.Loadage = rLoadFacter;
-            this.RearDriveState = rState;
-        }
-
         public void SetCurrentSteeringState( eSteeringState state )
         {
             this.zmq.SetCurrentSteeringState( state );

+ 100 - 50
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -229,7 +229,7 @@ namespace VehicleControlSystem.ControlLayer
         public double BatteryVoltage
         {
             get { return this.batteryVoltage; }
-            set 
+            set
             {
                 //var d = Math.Truncate( value * 10 ) / 10;
                 //this.SetField( ref this.batteryVoltage, d );
@@ -290,10 +290,10 @@ namespace VehicleControlSystem.ControlLayer
         public double BatteryEnergy
         {
             get { return this.batteryEnergy; }
-            set 
+            set
             {
                 var d = Math.Truncate( value * 10 ) / 10;
-                this.SetField( ref this.batteryEnergy, d ); 
+                this.SetField( ref this.batteryEnergy, d );
             }
         }
 
@@ -1226,7 +1226,7 @@ namespace VehicleControlSystem.ControlLayer
             Thread.Sleep( 1000 );
             loggerPIO.E( "[Port] - 4 Ready On" );
 
-            this.iO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
             loggerPIO.I( "[Vehicle] - 4 Receivable" );
 
             //if ( !this.iO.WaitChangeInputIO( true, 20000, "IN_PIO_SEND_RUN" ) )
@@ -1238,7 +1238,7 @@ namespace VehicleControlSystem.ControlLayer
             Thread.Sleep( 1000 );
             loggerPIO.I( "[Port] - 5 Sending Run On" );
 
-            this.iO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true );
             loggerPIO.I( "[Vehicle] - 5 Receive Run On" );
 
             this.VehicleStateProperty = eVehicleState.Charge;
@@ -1293,7 +1293,7 @@ namespace VehicleControlSystem.ControlLayer
 
             this.PIOClear();
 
-            this.iO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", true );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", true );
             loggerPIO.I( "[Vehicle] Receive Complete On" );
 
             //if ( !this.iO.WaitChangeInputIO( true, 20000, "IN_PIO_SEND_COMPLITE" ) )
@@ -1306,7 +1306,7 @@ namespace VehicleControlSystem.ControlLayer
             loggerPIO.I( "[Port] Send Complete On" );
 
             Thread.Sleep( 1000 );
-            this.iO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false );
 
             this.OnChargingFull?.Invoke();
 
@@ -1420,14 +1420,11 @@ namespace VehicleControlSystem.ControlLayer
         public int PIOAndLoad( string targetName )
         {
 #if SIMULATION
-            this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
-            return 0;
-
             PIOClear();
             loggerPIO.I( $"Start Load PIO - [{targetName}]" );
             this.OnPIOStart?.Invoke( true );
 
-            this.iO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true );
             loggerPIO.I( "[Vehicle] - 4 Receive Run On" );
 
             Thread.Sleep( 1000 );//상대 IO 기다린다 생각.
@@ -1589,14 +1586,14 @@ namespace VehicleControlSystem.ControlLayer
 
             Thread.Sleep( 1000 );
 
-            this.iO.WriteOutputIO( "OUT_PIO_READY", true );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_READY", true );
             loggerPIO.I( "[Vehicle] - 1 Ready On" );
 
             Thread.Sleep( 1000 );
             this.OnConveyorStart?.Invoke( false );
 
             Thread.Sleep( 10000 );
-            this.conveyor.OnOffConveyor( false ); //Stop
+            this.refObjects.Conveyor.OnOffConveyor( false ); //Stop
             this.OnConveyorStop?.Invoke( false );
             PIOClear();
 
@@ -1935,6 +1932,58 @@ namespace VehicleControlSystem.ControlLayer
                         }
                     }
                     break;
+
+                case "CurrentPointNo":
+                    {
+                        var v = CastTo<int>.From<object>( newValue );
+                        logger.D( $"{this.CurrentTag} -> {v}" );
+                        this.CurrentTag = v;
+                    }
+                    break;
+
+                case "RearDriveState":
+                    {
+                        var v = CastTo<DriveState>.From<object>( newValue );
+                        this.RearDriveState = v;
+                    }
+                    break;
+
+                case "FrontLoadFactor":
+                    {
+                        var v = CastTo<double>.From<object>( newValue );
+                        this.FrontLoadFactor = v;
+                        this.FrontTorque = Math.Truncate( ( ( v * 1.9 ) / 1000 ) * 100 ) / 100;
+                    }
+                    break;
+
+                case "FrontRPM":
+                    {
+                        var v = CastTo<double>.From<object>( newValue );
+                        this.FrontRpm = v;
+
+                        var ll = ( ( ( ( v / 60 ) * ( 2 * Math.PI ) ) * 0.06 ) / 10 );
+                        this.FrontSpeed = Math.Truncate( ll * 100 ) / 100;
+                    }
+                    break;
+
+                case "RearLoadFactor":
+                    {
+                        var v = CastTo<double>.From<object>( newValue );
+                        this.RearLoadFactor = v;
+                        this.RearTorque = Math.Truncate( ( ( v * 1.9 ) / 1000 ) * 100 ) / 100;
+                    }
+                    break;
+
+                case "RearRPM":
+                    {
+                        var v = CastTo<double>.From<object>( newValue );
+                        this.RearRpm = v;
+
+                        var ll = ( ( ( ( v / 60 ) * ( 2 * Math.PI ) ) * 0.06 ) / 10 );
+                        this.RearSpeed = Math.Truncate( ll * 100 ) / 100;
+                    }
+                    break;
+
                 default:
                     break;
             }
@@ -1953,13 +2002,13 @@ namespace VehicleControlSystem.ControlLayer
                         this.CurrentPosition = v;
                     }
                     break;
-                case "CurrentTag":
-                    {
-                        var v = CastTo<int>.From<object>( newValue );
-                        logger.D( $"{this.CurrentTag} -> {v}" );
-                        this.CurrentTag = v;
-                    }
-                    break;
+                //case "CurrentTag":
+                //    {
+                //        var v = CastTo<int>.From<object>( newValue );
+                //        logger.D( $"{this.CurrentTag} -> {v}" );
+                //        this.CurrentTag = v;
+                //    }
+                //    break;
                 case "CurrentSpeed":
                     {
                         var v = CastTo<double>.From<object>( newValue );
@@ -2011,37 +2060,38 @@ namespace VehicleControlSystem.ControlLayer
                         this.RearDriveState = v;
                     }
                     break;
-                case "FrontLoadFactor":
-                    {
-                        var v = CastTo<double>.From<object>( newValue );
-                        this.FrontLoadFactor = v;
-                        this.FrontTorque = Math.Truncate( ( ( v * 1.9 ) / 1000 ) * 100 ) / 100;
-                    }
-                    break;
-                case "FrontRpm":
-                    {
-                        var v = CastTo<double>.From<object>( newValue );
-                        this.FrontRpm = v;
-
-                        var ll = ( ( ( ( v / 60 ) * ( 2 * Math.PI ) ) * 0.06 ) / 10 );
-                        this.FrontSpeed = Math.Truncate( ll * 100) / 100; 
-                    }
-                    break;
-                case "RearLoadFactor":
-                    {
-                        var v = CastTo<double>.From<object>( newValue );
-                        this.RearLoadFactor = v;
-                        this.RearTorque = Math.Truncate( ( ( v * 1.9 ) / 1000 ) * 100 ) / 100;
-                    }
-                    break;
-                case "RearRpm":
-                    {
-                        var v = CastTo<double>.From<object>( newValue );
-                        this.RearRpm = v;
 
-                        var ll = ( ( ( ( v / 60 ) * ( 2 * Math.PI ) ) * 0.06 ) / 10 );
-                        this.RearSpeed = Math.Truncate( ll * 100 ) / 100;
-                    }
+                //case "FrontLoadFactor":
+                //    {
+                //        var v = CastTo<double>.From<object>( newValue );
+                //        this.FrontLoadFactor = v;
+                //        this.FrontTorque = Math.Truncate( ( ( v * 1.9 ) / 1000 ) * 100 ) / 100;
+                //    }
+                //    break;
+                //case "FrontRpm":
+                //    {
+                //        var v = CastTo<double>.From<object>( newValue );
+                //        this.FrontRpm = v;
+
+                //        var ll = ( ( ( ( v / 60 ) * ( 2 * Math.PI ) ) * 0.06 ) / 10 );
+                //        this.FrontSpeed = Math.Truncate( ll * 100 ) / 100;
+                //    }
+                //    break;
+                //case "RearLoadFactor":
+                //    {
+                //        var v = CastTo<double>.From<object>( newValue );
+                //        this.RearLoadFactor = v;
+                //        this.RearTorque = Math.Truncate( ( ( v * 1.9 ) / 1000 ) * 100 ) / 100;
+                //    }
+                //    break;
+                //case "RearRpm":
+                //    {
+                //        var v = CastTo<double>.From<object>( newValue );
+                //        this.RearRpm = v;
+
+                //        var ll = ( ( ( ( v / 60 ) * ( 2 * Math.PI ) ) * 0.06 ) / 10 );
+                //        this.RearSpeed = Math.Truncate( ll * 100 ) / 100;
+                //    }
                     break;
                 default:
                     break;

+ 0 - 177
Dev/OHV/VehicleControlSystem/Managers/PhysicalCheckupLogger.cs

@@ -1,177 +0,0 @@
-using FluentFTP;
-using GSG.NET.Logging;
-using GSG.NET.ObjectBase;
-using GSG.NET.TCP;
-using GSG.NET.Utils;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace VehicleControlSystem.Managers
-{
-    /// <summary>
-    /// 아날로그 입력 정보를 종합하여 로그로 남기는 역할
-    /// FTP 를 이용하여 파일 전송
-    /// </summary>
-    class PhysicalCheckupLogger : SingletonBase<PhysicalCheckupLogger>, IDisposable
-    {
-        Logger frontlogger = Logger.GetLogger( "PhysicalCheckup_Front" );
-        Logger rearlogger = Logger.GetLogger( "PhysicalCheckup_Rear" );
-        Logger logger = Logger.GetLogger();
-
-
-        TcpConnector h = new TcpConnector();
-        const byte CR = 0x0d;
-
-        public string PLCAddress { get; set; } = "192.168.0.20";
-        public int PLCPort { get; set; } = 8501;
-        public string PLCFolderName { get; set; }
-        public string FTPFolderName { get; set; }
-
-        private PhysicalCheckupLogger()
-        {
-        }
-
-        public void Dispose()
-        {
-            this.h.CloseSocket();
-        }
-
-        public void FrontWheelLogging( string speed, string torque, string RPM, string LoadFactor, string MCR ) => frontlogger.I( $"Speed : {speed} / Torque : {torque} / RPM : {RPM} / LoadFactor : {LoadFactor} / MCR : {MCR}" );
-        public void RearWheelLoggging( string speed, string torque, string RPM, string LoadFactor, string MCR ) => rearlogger.I( $"Speed : {speed} / Torque : {torque} / RPM : {RPM} / LoadFactor : {LoadFactor} / MCR : {MCR}" );
-
-        public async Task UploadPhysicalCheckupLogAsync()
-        {
-            var token = new CancellationToken();
-
-            using ( var ftp = new FtpClient( "192.168.127.188" ) )
-            {
-                await ftp.ConnectAsync( token );
-
-                // upload a folder and all its files
-                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()
-        {
-            using ( var ftp = new FtpClient( "192.168.0.20", "KVID", "1234" ) )
-            {
-                ftp.Connect();
-
-                // download a folder and all its files
-                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" );
-            }
-        }
-
-        public void FTPServerDeleteFile()
-        {
-            using ( var ftp = new FtpClient( "192.168.0.20", "KV", "1234" ) )
-            {
-                ftp.Connect();
-                ftp.DeleteDirectory( "/0_CARD/log0/" );
-            }
-        }
-
-        public void Connecte()
-        {
-            h.Connect( new TcpComm
-            {
-                Active = true,
-                Ip = "192.168.0.20",
-                PortNo = 8501,
-            } );
-        }
-
-        /// <summary>
-        /// 주행 시작 시 진단 PLC Bit On
-        /// </summary>
-        /// <returns></returns>
-        public bool SetPLCStartDrive()
-        {
-            try
-            {
-                if ( !h.Connected )
-                {
-                    h.Connect( new TcpComm
-                    {
-                        Active = true,
-                        Ip = "192.168.0.20",
-                        PortNo = 8501,
-                    } );
-                }
-
-                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 )
-            {
-                h.CloseSocket();
-                logger.E( $"[PLC] - Set Value Connection Error {e}" );
-                return false;
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// 주행 정지 시 진단 PLC Bit Off
-        /// </summary>
-        /// <returns></returns>
-        public bool ResetPLCStartDrive()
-        {
-            try
-            {
-                if ( !h.Connected )
-                {
-                    h.Connect( new TcpComm
-                    {
-                        Active = true,
-                        Ip = "192.168.0.20",
-                        PortNo = 8501,
-                    } );
-                }
-
-                if ( !h.Connected )
-                    return false;
-
-                var mb = new MemoryBuffer();
-                mb.AppendAscii( "WR MR100 0" );
-                mb.Append( CR );
-                this.h.WriteFlush( mb.ToBytes );
-
-                //h.CloseSocket();
-
-            }
-            catch ( Exception e )
-            {
-                h.CloseSocket();
-                logger.E( $"[PLC] - Reset Value Connection Error {e}" );
-                return false;
-            }
-
-            return true;
-        }
-
-    }
-}

+ 1 - 1
Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs

@@ -105,7 +105,7 @@ namespace VehicleControlSystem.Managers
         {
             while ( isThreadAlive )
             {
-                Thread.Sleep( 500 );
+                Thread.Sleep( 300 );
                 try
                 {
                     var state = this.autoManager.OperationModeProperty;

+ 1 - 0
Dev/OHV/VehicleControlSystem/VCSystem.cs

@@ -91,6 +91,7 @@ namespace VehicleControlSystem
             //Steering
             this.steering = new Steering( this.IO, this.sql, this.eventAggregator );
 
+            //ZeroMQ
             this.zmqManager = new ZmqManager( vehicle, this.bMUManager );
             this.zmqManager.Init();
 

+ 0 - 2
Dev/OHV/VehicleControlSystem/VehicleControlSystem.csproj

@@ -129,7 +129,6 @@
     <Compile Include="ControlLayer\Clamp.cs" />
     <Compile Include="ControlLayer\ControlObjectBase.cs" />
     <Compile Include="ControlLayer\Conveyor.cs" />
-    <Compile Include="ControlLayer\DB\Redis.cs" />
     <Compile Include="ControlLayer\IO\BitBlock.cs" />
     <Compile Include="ControlLayer\IO\Delegates.cs" />
     <Compile Include="ControlLayer\IO\EzBoard.cs" />
@@ -159,7 +158,6 @@
     <Compile Include="ControlLayer\Vehicle.cs" />
     <Compile Include="Managers\AutoManager.cs" />
     <Compile Include="Managers\HostManager.cs" />
-    <Compile Include="Managers\PhysicalCheckupLogger.cs" />
     <Compile Include="Managers\RouteManager.cs" />
     <Compile Include="Managers\Scheduler.cs" />
     <Compile Include="VCSystem.cs" />

+ 16 - 3
Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/Config/log4net.xml

@@ -3,8 +3,7 @@
 	<root name="root">
 		<level value="ALL" />
 		<appender-ref ref="FileAppender" />
-		<!--<appender-ref ref="WarnFileAppender" />-->
-		<!--<appender-ref ref="MongoAppender" />-->
+    <!--<appender-ref ref="remotingAppender"/>-->
 	</root>
 
 	<logger name="PhysicalCheckup_Front" additivity="false">
@@ -25,8 +24,22 @@
 	•FATAL  •FATAL  •FATAL  •FATAL  •FATAL  •FATAL
 	•OFF    •OFF    •OFF    •OFF    •OFF    •OFF    •OFF
 	-->
+  <appender name="remotingAppender" type="log4net.Appender.RemotingAppender">
+    <!-- The remoting URL to the remoting server object -->
+    <sink value="tcp://172.20.0.198:8085/Log4netRemotingServerService"/>
+    <!-- Send all events, do not discard events when the buffer is full -->
+    <lossy value="false"/>
+    <!-- The number of events to buffer before sending -->
+    <bufferSize value="10"/>
+    <!-- Do not store event data that is slow to generate -->
+    <onlyFixPartialEventData value="true"/>
+    <!-- Specify an evaluator to send the events immediately under certain conditions, e.g. when an error event ocurrs -->
+    <!--<evaluator type="log4net.Core.LevelEvaluator">
+			<threshold value="WARN"/>
+		</evaluator>-->
+  </appender>
 
-	<appender name="Front_BufferingForwarder" type="log4net.Appender.BufferingForwardingAppender">
+  <appender name="Front_BufferingForwarder" type="log4net.Appender.BufferingForwardingAppender">
 		<bufferSize value="512"/>
 		<lossy value="false"/>
 		<Fix value ="268"/>

binární
Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/DataLogger.ico


+ 101 - 7
Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/FormMain.Designer.cs

@@ -28,9 +28,21 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
             this.lblPLCCommState = new System.Windows.Forms.Label();
             this.label55 = new System.Windows.Forms.Label();
             this.btnBit = new System.Windows.Forms.Button();
+            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
+            this.contextMenuNotify = new System.Windows.Forms.ContextMenuStrip(this.components);
+            this.loggerHIDEToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.eXITToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+            this.loggerHIDEToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+            this.eXITToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+            this.label57 = new System.Windows.Forms.Label();
+            this.contextMenuNotify.SuspendLayout();
+            this.contextMenu.SuspendLayout();
             this.SuspendLayout();
             // 
             // lblPLCCommState
@@ -39,7 +51,7 @@
             this.lblPLCCommState.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
             this.lblPLCCommState.Font = new System.Drawing.Font("Segoe UI Symbol", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.lblPLCCommState.ForeColor = System.Drawing.Color.Black;
-            this.lblPLCCommState.Location = new System.Drawing.Point(12, 34);
+            this.lblPLCCommState.Location = new System.Drawing.Point(12, 58);
             this.lblPLCCommState.Name = "lblPLCCommState";
             this.lblPLCCommState.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
             this.lblPLCCommState.Size = new System.Drawing.Size(86, 30);
@@ -53,7 +65,7 @@
             this.label55.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
             this.label55.Font = new System.Drawing.Font("Segoe UI Symbol", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.label55.ForeColor = System.Drawing.Color.White;
-            this.label55.Location = new System.Drawing.Point(12, 9);
+            this.label55.Location = new System.Drawing.Point(12, 33);
             this.label55.Name = "label55";
             this.label55.Size = new System.Drawing.Size(86, 24);
             this.label55.TabIndex = 12;
@@ -62,7 +74,7 @@
             // 
             // btnBit
             // 
-            this.btnBit.Location = new System.Drawing.Point(104, 12);
+            this.btnBit.Location = new System.Drawing.Point(104, 36);
             this.btnBit.Name = "btnBit";
             this.btnBit.Size = new System.Drawing.Size(124, 48);
             this.btnBit.TabIndex = 13;
@@ -70,18 +82,92 @@
             this.btnBit.UseVisualStyleBackColor = true;
             this.btnBit.Click += new System.EventHandler(this.button1_Click);
             // 
+            // notifyIcon1
+            // 
+            this.notifyIcon1.ContextMenuStrip = this.contextMenuNotify;
+            this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
+            this.notifyIcon1.Text = "DriveLogger";
+            this.notifyIcon1.Visible = true;
+            // 
+            // contextMenuNotify
+            // 
+            this.contextMenuNotify.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.loggerHIDEToolStripMenuItem,
+            this.eXITToolStripMenuItem});
+            this.contextMenuNotify.Name = "contextMenuStrip1";
+            this.contextMenuNotify.Size = new System.Drawing.Size(111, 48);
+            // 
+            // loggerHIDEToolStripMenuItem
+            // 
+            this.loggerHIDEToolStripMenuItem.Name = "loggerHIDEToolStripMenuItem";
+            this.loggerHIDEToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
+            this.loggerHIDEToolStripMenuItem.Text = "SHOW";
+            this.loggerHIDEToolStripMenuItem.Click += new System.EventHandler(this.loggerHIDEToolStripMenuItem_Click);
+            // 
+            // eXITToolStripMenuItem
+            // 
+            this.eXITToolStripMenuItem.Name = "eXITToolStripMenuItem";
+            this.eXITToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
+            this.eXITToolStripMenuItem.Text = "EXIT";
+            this.eXITToolStripMenuItem.Click += new System.EventHandler(this.eXITToolStripMenuItem_Click);
+            // 
+            // contextMenu
+            // 
+            this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.loggerHIDEToolStripMenuItem1,
+            this.eXITToolStripMenuItem1});
+            this.contextMenu.Name = "contextMenu";
+            this.contextMenu.Size = new System.Drawing.Size(143, 48);
+            // 
+            // loggerHIDEToolStripMenuItem1
+            // 
+            this.loggerHIDEToolStripMenuItem1.Name = "loggerHIDEToolStripMenuItem1";
+            this.loggerHIDEToolStripMenuItem1.Size = new System.Drawing.Size(142, 22);
+            this.loggerHIDEToolStripMenuItem1.Text = "Logger HIDE";
+            this.loggerHIDEToolStripMenuItem1.Click += new System.EventHandler(this.loggerHIDEToolStripMenuItem1_Click);
+            // 
+            // eXITToolStripMenuItem1
+            // 
+            this.eXITToolStripMenuItem1.Name = "eXITToolStripMenuItem1";
+            this.eXITToolStripMenuItem1.Size = new System.Drawing.Size(142, 22);
+            this.eXITToolStripMenuItem1.Text = "EXIT";
+            this.eXITToolStripMenuItem1.Click += new System.EventHandler(this.eXITToolStripMenuItem1_Click);
+            // 
+            // label57
+            // 
+            this.label57.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
+            this.label57.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.label57.Dock = System.Windows.Forms.DockStyle.Top;
+            this.label57.Font = new System.Drawing.Font("Segoe UI Symbol", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.label57.ForeColor = System.Drawing.Color.White;
+            this.label57.Location = new System.Drawing.Point(0, 0);
+            this.label57.Name = "label57";
+            this.label57.Size = new System.Drawing.Size(238, 29);
+            this.label57.TabIndex = 14;
+            this.label57.Text = "OHV Drive Logger";
+            this.label57.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
             // FormMain
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
+            this.AutoSize = true;
             this.BackColor = System.Drawing.SystemColors.ActiveBorder;
-            this.ClientSize = new System.Drawing.Size(245, 72);
+            this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
+            this.ClientSize = new System.Drawing.Size(238, 92);
+            this.ContextMenuStrip = this.contextMenu;
+            this.ControlBox = false;
+            this.Controls.Add(this.label57);
             this.Controls.Add(this.btnBit);
             this.Controls.Add(this.lblPLCCommState);
             this.Controls.Add(this.label55);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+            this.MaximizeBox = false;
             this.Name = "FormMain";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
-            this.Text = "OHV Drive Logger";
+            this.Text = "Drive Logger";
+            this.contextMenuNotify.ResumeLayout(false);
+            this.contextMenu.ResumeLayout(false);
             this.ResumeLayout(false);
 
         }
@@ -91,6 +177,14 @@
         public System.Windows.Forms.Label lblPLCCommState;
         private System.Windows.Forms.Label label55;
         private System.Windows.Forms.Button btnBit;
+        private System.Windows.Forms.NotifyIcon notifyIcon1;
+        private System.Windows.Forms.ContextMenuStrip contextMenuNotify;
+        private System.Windows.Forms.ToolStripMenuItem loggerHIDEToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem eXITToolStripMenuItem;
+        private System.Windows.Forms.ContextMenuStrip contextMenu;
+        private System.Windows.Forms.ToolStripMenuItem loggerHIDEToolStripMenuItem1;
+        private System.Windows.Forms.ToolStripMenuItem eXITToolStripMenuItem1;
+        private System.Windows.Forms.Label label57;
     }
 }
 

+ 22 - 1
Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/FormMain.cs

@@ -66,7 +66,6 @@ namespace OHVDriveLogger
             this.zmq.Init();
 
             this.threadCancel.AddGo( Th_DoWorker );
-
         }
 
         private void Plc_OnDisconnect( string id )
@@ -101,6 +100,8 @@ namespace OHVDriveLogger
                 plc.WriteBit( "DRIVE_LOGGING_ONOFF", false );
             else
                 plc.WriteBit( "DRIVE_LOGGING_ONOFF", true );
+
+            //logger.I( $"Test" );
         }
 
         void Th_DoWorker()
@@ -174,5 +175,25 @@ namespace OHVDriveLogger
             FTPLogger.Instance.FTPUpload();
             LockUtils.Wait( 100 );
         }
+
+        private void loggerHIDEToolStripMenuItem_Click( object sender, EventArgs e )
+        {
+            this.Show();
+        }
+
+        private void eXITToolStripMenuItem_Click( object sender, EventArgs e )
+        {
+            this.Close();
+        }
+
+        private void loggerHIDEToolStripMenuItem1_Click( object sender, EventArgs e )
+        {
+            this.Hide();
+        }
+
+        private void eXITToolStripMenuItem1_Click( object sender, EventArgs e )
+        {
+            this.Close();
+        }
     }
 }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 8962 - 0
Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/FormMain.resx


+ 0 - 83
Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/ZmqManager.cs

@@ -16,13 +16,7 @@ namespace OHVDriveLogger
         Logger logger = Logger.GetLogger();
 
         SubscriberSocket sub = null;
-        RequestSocket req = null;
-        ResponseSocket rep = null;
-
         NetMQPoller poller = null;
-        NetMQMonitor monitor = null;
-
-        ThreadCancel threadCancel = new ThreadCancel();
 
         private bool isReqConnected;
         public bool IsReqConnected
@@ -106,57 +100,18 @@ namespace OHVDriveLogger
             sub.Connect( "tcp://127.0.0.1:5565" );
             sub.Connect( "tcp://127.0.0.1:5570" );
             sub.Subscribe( "" ); //All
-
             sub.ReceiveReady += Sub_ReceiveReady;
 
-            req = new RequestSocket();
-            this.monitor = new NetMQMonitor( req, "inproc://rep.inproc", SocketEvents.Disconnected | SocketEvents.Connected );
-            this.monitor.Connected += ( s, a ) => { this.IsReqConnected = true; };
-            this.monitor.Disconnected += ( s, a ) => { this.IsReqConnected = false; };
-            this.monitor.StartAsync();
-
-            req.Connect( "tcp://127.0.0.1:5567" );
-
             this.poller = new NetMQPoller { this.sub };
             this.poller.RunAsync();
         }
 
-        private void Rep_ReceiveReady( object sender, NetMQSocketEventArgs e )
-        {
-            var ret = e.Socket.ReceiveMultipartStrings();
-            logger.D( $"[rep] - {ret[1]}" );
-
-            if ( ret[0].Equals( "setm" ) )
-            {
-                var v = ret[1].Split( '/' );
-                switch ( v[0] )
-                {
-                    case "4012":
-                        if ( v[1].Equals( "3" ) )
-                            IsDriveMoving = true;
-                        else
-                            IsDriveMoving = false;
-                        break;
-
-                    default:
-                        break;
-                }
-                rep.SendMoreFrame( "setm" ).SendFrame( $"ok/{v[0]}" );
-            }
-        }
-
         public void Dispose()
         {
-            this.threadCancel.Cancel();
-
-            this.monitor.Stop();
-            this.monitor.Dispose();
-
             this.poller.Stop();
             this.poller.Dispose();
 
             this.sub.Dispose();
-            this.req.Dispose();
         }
 
         private void Sub_ReceiveReady( object sender, NetMQ.NetMQSocketEventArgs e )
@@ -211,43 +166,5 @@ namespace OHVDriveLogger
                 logger.E( excpetion );
             }
         }
-
-        void Th_SubPoller()
-        {
-            while ( !this.threadCancel.Canceled )
-            {
-                LockUtils.Wait( 1000 );
-                //this.pub.SendMoreFrame( "1000" ).SendFrame( "Test" );
-                LockUtils.Wait( 100 );
-
-                NetMQMessage msg = new NetMQMessage();
-                if ( this.sub.TryReceiveMultipartMessage( TimeSpan.FromSeconds( 1 ), ref msg ) )
-                {
-                    var m = msg;
-                }
-            }
-        }
-
-        public bool Request( string topic, out string response )
-        {
-            response = string.Empty;
-
-            if ( !this.IsReqConnected )
-                return false;
-
-            if ( this.req.HasOut )
-                this.req.SendFrame( topic );
-
-            if ( this.req.TryReceiveFrameString( TimeSpan.FromSeconds( 5 ), out response ) )
-                return true;
-            else
-            {
-                this.req.Disconnect( "tcp://127.0.0.1:5567" );
-
-                //this.req = new RequestSocket();
-                this.req.Connect( "tcp://127.0.0.1:5567" );
-                return false;
-            }
-        }
     }
 }