Explorar el Código

현장 업데이트

unque781 hace 6 años
padre
commit
b2abd7c290

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

@@ -26,6 +26,7 @@ namespace OHVConnector
         R,
         H,
         Z,
+        G, //MTL 이동 명령
     }
 
     public class OCSMessage

BIN
Dev/OHV/Assambly/OHVConnector.dll


BIN
Dev/OHV/Assambly/OHVConnector.pdb


+ 2 - 1
Dev/OHV/OHV.Module.Interactivity/PopUp/BatteryConfigViewModel.cs

@@ -149,7 +149,8 @@ namespace OHV.Module.Interactivity.PopUp
                             this.Current = CastTo<double>.From<object>( obj.Args );
                             break;
                         case "BatteryState":
-                            this.BatteryState = ((eBatteryState)CastTo<double>.From<object>( obj.Args )).ToString();
+                            var bms = CastTo<double>.From<object>( obj.Args );
+                            this.BatteryState = Convert.ToString((eBatteryState)bms);
                             break;
                         case "BatteryChargeTime":
                             this.AverageTimeToFull = CastTo<double>.From<object>( obj.Args );

+ 1 - 1
Dev/OHV/OHV.SqliteDAL/SqliteManager.cs

@@ -35,7 +35,7 @@ namespace OHV.SqliteDAL
             this.AxisConfigDAL = new GenericRepository<AxisConfig>();
             this.AxisPositionDataDAL = new GenericRepository<AxisPositionData>();
             this.AxisVelocityDataDAL = new GenericRepository<AxisVelocityData>();
-            this.AlarmDAL = new GenericRepository<Alarm>() ;
+            this.AlarmDAL = new GenericRepository<Alarm>();
             this.VehicleInfoDAL = new GenericRepository<VehicleInfo>();
             this.HisAlarmDAL = new GenericRepository<HisAlarm>();
             this.RouteDal = new GenericRepository<Route>();

+ 22 - 1
Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs

@@ -542,40 +542,61 @@ namespace OHV.Vehicle.Concept
                                 this.IsVehicleAlarm = false; 
                         }
                         break;
+
                     case "IsErrorProcessing":
                         {
                             var ll = CastTo<bool>.From<object>( args.Args );
                         }
                         break;
+
                     case "MachineMode":
                         this.MachineMode = CastTo<eMachineMode>.From<object>( args.Args );
                         break;
+
                     case "BatteryIsConnect":
                         this.RspBatteryConnected( args );
                         break;
+
                     case "BatteryStateOfCharge":
                         this.SOC = CastTo<double>.From<object>( args.Args );
                         break;
+
                     case "BatteryChargeTime":
                         {
                             var cTime = CastTo<double>.From<object>( args.Args );
-                            if ( cTime > 0 )
+                            //if ( cTime > 0 )
+                            //    this.BatteryState = eBatteryState.Charge;
+                            //else
+                            //    this.BatteryState = eBatteryState.Connect;
+                        }
+                        break;
+                        
+                    case "BatteryChargeState":
+                        {
+                            var isCharge = CastTo<bool>.From<object>( args.Args );
+                            if ( isCharge )
                                 this.BatteryState = eBatteryState.Charge;
                             else
                                 this.BatteryState = eBatteryState.Connect;
                         }
                         break;
+
                     case "BatteryDisChargeTime":
                         {
                             var dTime = CastTo<double>.From<object>( args.Args );
                         }
                         break;
+
                     case "CurrentTag":
                         {
                             this.CurrentTag = CastTo<int>.From<object>( args.Args );
                         }
                         break;
+
+                    default:
+                        break;
                 }
+
             }
         }
 

BIN
Dev/OHV/OHV.Vehicle/Config/AlarmDefind.xlsx


BIN
Dev/OHV/OHV.Vehicle/Config/IO.xlsx


+ 4 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/MQ/ZmqManager.cs

@@ -179,6 +179,7 @@ namespace VehicleControlSystem.ControlLayer.MQ
                 CurrentPointNo = GetCurrentPointNo();
                 SetCurrentSteeringState( this.steering.GetSteeringState() );
             };
+
             this.monitor.Disconnected += ( s, a ) => { this.IsReqConnected = false; };
             this.monitor.StartAsync();
 
@@ -265,6 +266,7 @@ namespace VehicleControlSystem.ControlLayer.MQ
                     var v = ret[1].Split( '/' );
 
                     rep.SendMoreFrame( "setm" ).SendFrame( $"ok/{v[0]}" ); //응답처리 부터 하자.
+
                     switch ( v[0] )
                     {
                         case "3050":
@@ -316,6 +318,7 @@ namespace VehicleControlSystem.ControlLayer.MQ
                                 this.SegmentID = iV;
                             }
                             break;
+
                         default:
                             break;
                     }
@@ -530,6 +533,7 @@ namespace VehicleControlSystem.ControlLayer.MQ
                     return false;
                 }
             }
+
             return true;
         }
 

+ 5 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Serial/DataModel/ReceivedData.cs

@@ -64,6 +64,11 @@ namespace VehicleControlSystem.ControlLayer.Serial.DataModel
                         var ll = Math.Truncate(((double)value / Scale ) * 100 ) / 100;
                         this.Orgvalue = ( ll ).ToString();
                     }
+                    //else if (DataKind == eDataKind.BatteryState)
+                    //{
+                    //    var bms = (eBatteryState)value;
+                    //    this.Orgvalue = bms.ToString();
+                    //}
                     else
                         this.Orgvalue = ( value * Scale ).ToString();
 

+ 4 - 3
Dev/OHV/VehicleControlSystem/ControlLayer/Steering.cs

@@ -131,7 +131,7 @@ namespace VehicleControlSystem.ControlLayer
                  {
                      LockUtils.Wait( 5 );
 
-                     if ( SwUtils.Gt( sTime , 3 * ConstUtils.ONE_SECOND ) ) //Wait 20Sec
+                     if ( SwUtils.Gt( sTime , 3 * ConstUtils.ONE_SECOND ) ) //Wait 3Sec
                          return false;
 
                      if ( isLeft )
@@ -153,6 +153,7 @@ namespace VehicleControlSystem.ControlLayer
                       else
                           this.OnSteeringError?.BeginInvoke( this , 0 , null , null );
 
+                      LockUtils.Wait( 200 );
                       GetSteeringState();
                       this.isExecuteSteering = false;
                   } );
@@ -164,8 +165,8 @@ namespace VehicleControlSystem.ControlLayer
         {
             this.iO.WriteOutputIO( "OUT_F_STEERING_DA" , true );
             this.iO.WriteOutputIO( "OUT_R_STEERING_DA" , true );
-            this.iO.WriteOutputIO( "OUT_F_STEERING_DA" , false , 800 );
-            this.iO.WriteOutputIO( "OUT_R_STEERING_DA" , false , 800 );
+            this.iO.WriteOutputIO( "OUT_F_STEERING_DA" , false , 400 );
+            this.iO.WriteOutputIO( "OUT_R_STEERING_DA" , false , 700 );
         }
 
         bool IsFrontLeft( ) => this.iO.IsOn( "IN_F_STEERING_DETECT_LEFT" );

+ 92 - 43
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -236,8 +236,8 @@ namespace VehicleControlSystem.ControlLayer
                         LockUtils.Wait( 200 );
                         this.OnCharging?.Invoke();
                     }
-                    else
-                        this.OnChargingFull?.Invoke();
+                    //else
+                    //    this.OnChargingFull?.Invoke();
                 }
             }
         }
@@ -288,14 +288,17 @@ namespace VehicleControlSystem.ControlLayer
         public double BatteryStateOfCharge
         {
             get { return this.batteryStateOfCharge; }
-            set { this.SetField( ref this.batteryStateOfCharge, value ); }
+            set { if ( this.SetField( ref this.batteryStateOfCharge, value ) ) { this.BatteryChargeStateLED( value ); } }
         }
 
         double batteryStateOfHealth;
         public double BatteryStateOfHealth
         {
             get { return this.batteryStateOfHealth; }
-            set { this.SetField( ref this.batteryStateOfHealth, value ); }
+            set 
+            {
+                if ( this.SetField( ref this.batteryStateOfHealth, value ) ) { }
+            }
         }
 
         double batteryCapacity;
@@ -804,7 +807,7 @@ namespace VehicleControlSystem.ControlLayer
 
             this.DriveControlEventPublish( msg );
         }
-        #endregion
+        #endregion 
 
         #region Thread
         void ThreadStart()
@@ -940,7 +943,7 @@ namespace VehicleControlSystem.ControlLayer
         {
             //Move 시작 시 충전 중이면 충전 중지 실행.
             int result = 0;
-            if ( this.IsCharging() || this.VehicleStateProperty == eVehicleState.Charge || this.BatteryChargeState)
+            if ( this.CheckBatteryCharge() || this.VehicleStateProperty == eVehicleState.Charge || this.BatteryChargeState)
             {
                 result = this.StopBatteryCharge();
                 if ( result != 0 )
@@ -1392,6 +1395,7 @@ namespace VehicleControlSystem.ControlLayer
 
             this.PIOSensorOff();
 
+            this.OnChargingFull?.Invoke();
             this.VehicleStateProperty = eVehicleState.Idle;
 
             return 0;
@@ -1406,7 +1410,7 @@ namespace VehicleControlSystem.ControlLayer
             if ( this.refObjects.IO.IsOff( "IN_OBSTRUCTION_DETECT_SAFETY" ) || this.refObjects.IO.IsOff( "IN_OBSTRUCTION_DETECT_ERROR" ) )
             {
                 this.ObstacleStateProperty = eObstacleState.Abnormal;
-                this.OccurVehicleAlarm( 9999 );
+                this.OccurVehicleAlarm( 42 );
             }
             else if ( this.refObjects.IO.IsOff( "IN_OBSTRUCTION_DETECT_STOP" ) )
             {
@@ -1421,7 +1425,7 @@ namespace VehicleControlSystem.ControlLayer
                 this.ObstacleStateProperty = eObstacleState.Normal;
             }
 
-            this.refObjects.Drive.SetObstacleState( this.ObstacleStateProperty );
+            //this.refObjects.Drive.SetObstacleState( this.ObstacleStateProperty );
 
             return false;
         }
@@ -1458,12 +1462,21 @@ namespace VehicleControlSystem.ControlLayer
         /// 이걸 보고 판단 하자. 충전 단자 전진 상태임.
         /// </summary>
         /// <returns></returns>
-        public bool IsCharging()
+        public bool CheckBatteryCharge()
         {
             this.PIOSensorOn();
             LockUtils.Wait( 500 );
 
-            var ret = this.refObjects.IO.IsOn( "OUT_PIO_RECEIVABLE", false ) && this.refObjects.IO.IsOn( "OUT_PIO_RECEIVE_RUN", false );
+            if ( this.BatteryChargeState || this.VehicleStateProperty == eVehicleState.Charge )
+            {
+
+            }
+
+            //var ret = this.refObjects.IO.IsOn( "OUT_PIO_RECEIVABLE", false ) 
+            //    && this.refObjects.IO.IsOn( "OUT_PIO_RECEIVE_RUN", false ) 
+            //    && this.refObjects.IO.IsOn( "IN_PIO_SEND_RUN" );
+
+            var ret = this.refObjects.IO.IsOn( "IN_PIO_SEND_RUN" );
             //this.PIOSensorOff();
 
             return ret;
@@ -1531,7 +1544,7 @@ namespace VehicleControlSystem.ControlLayer
                 return 0;
             }
 
-            if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 40 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
             {
                 loggerPIO.E( "[Port] - Lift Position Check Error" );
                 TimerUtils.Once( 1000, this.OnFailReport, eFailCode.LoadPIOInterlockTimeout );
@@ -1559,7 +1572,7 @@ namespace VehicleControlSystem.ControlLayer
             this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
             loggerPIO.I( "[Vehicle] - 4 Receivable" );
 
-            if ( !this.refObjects.IO.WaitChangeInputIO( true, 10 * ConstUtils.ONE_SECOND, "IN_PIO_SENDABLE" ) )
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_PIO_SENDABLE" ) )
             {
                 PIOClear();
                 loggerPIO.E( "[Port] - 4 Ready Time Out" );
@@ -1703,7 +1716,7 @@ namespace VehicleControlSystem.ControlLayer
                 return 0;
             }
 
-            if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 40 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
             {
                 loggerPIO.E( "[Port] - Lift Position Check Error" );
                 TimerUtils.Once( 1000, this.OnFailReport, eFailCode.UnlaodPIOInterlockTimeout );
@@ -1721,7 +1734,7 @@ namespace VehicleControlSystem.ControlLayer
             PIOClear();
             this.OnPIOStart?.Invoke( false );
 
-            if ( !this.refObjects.IO.WaitChangeInputIO( true, 5 * ConstUtils.ONE_SECOND, "IN_PIO_READY" ) )
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_PIO_READY" ) )
             {
                 loggerPIO.E( "[Port] - 1 Ready not On" );
                 TimerUtils.Once( 1000, this.OnFailReport, eFailCode.UnlaodPIOInterlockTimeout );
@@ -1770,7 +1783,19 @@ namespace VehicleControlSystem.ControlLayer
                     if ( this.refObjects.Conveyor.IsDetectedLoadStart() || this.refObjects.Conveyor.IsDetectedCenter() ) //중간에 걸려 있다고 생각해서 알람 처리.
                         return 12; //Conveyor Moving Timeout
                     else
-                        return 0;
+                    {
+                        if ( this.refObjects.Conveyor.IsDetectedCenter() ) //Time Out 후 아직 Tray 가 있으면 다시 Clamp Lock.
+                        {
+                            result = this.refObjects.Clamp.Unlock_Sync();
+                            if ( result != 0 )
+                            {
+                                this.OccurVehicleAlarm( result );
+                                return result;
+                            }
+                        }
+                        else 
+                            return 0;
+                    }
                 }
 
 
@@ -1812,6 +1837,37 @@ namespace VehicleControlSystem.ControlLayer
         #endregion
 
         #region Help Method
+        void BatteryChargeStateLED(double percent )
+        {
+            if ( percent > 65 )
+            {
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_00", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_01", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_02", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_03", true );
+            }
+            else if ( percent > 50 )
+            {
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_00", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_01", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_02", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_03", false );
+            }
+            else if ( percent > 40 )
+            {
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_00", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_01", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_02", false );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_03", false );
+            }
+            else
+            {
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_00", true );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_01", false );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_02", false );
+                this.refObjects.IO.WriteOutputIO( "OUT_BATTERY_LED_03", false );
+            }
+        }
 
         /// <summary>
         /// 현재 Point 가 변경될때 장애물 감지 센서의 패턴을 변경한다.
@@ -1949,6 +2005,7 @@ namespace VehicleControlSystem.ControlLayer
                 case eDataKind.Voltage:
                     this.BatteryVoltage = (double)obj.Value;
                     break;
+
                 case eDataKind.Current:
                     this.BatteryCurrent = (double)obj.Value;
                     if ( BatteryCurrent > 0 )
@@ -1958,58 +2015,50 @@ namespace VehicleControlSystem.ControlLayer
 
                     break;
                 case eDataKind.BatteryState:
-                    if ( obj.Value == null )
-                        return;
                     this.BatteryState = (double)obj.Value;
                     break;
-                case eDataKind.ChargeCompleteTime:
-                    if ( obj.Value == null /*|| obj.Value <= 0 */)
-                        return;
 
+                case eDataKind.ChargeCompleteTime:
                     this.BatteryChargeTime = (double)obj.Value;
-
-                    //if ( this.BatteryChargeTime > 0 )
-                    //{
-                    //    //this.OnCharging?.Invoke();
-                    //    this.VehicleStateProperty = eVehicleState.Charge;
-                    //}
-                    //else
-                    //    //this.OnChargingFull?.Invoke();
-
                     break;
+
                 case eDataKind.DisChargeCompleteTime:
-                    if ( obj.Value == null || obj.Value <= 0 )
-                        return;
                     this.BatteryDisChargeTime = (double)obj.Value;
                     break;
+
                 case eDataKind.SOC:
                     this.BatteryStateOfCharge = (double)obj.Value;
-                    if ( this.BatteryStateOfCharge >= 78 )
-                    {
-                        if ( this.autoManager.AutoModeStateProperty != eAutoModeState.Run )
-                            return;
+                    //if ( this.BatteryStateOfCharge >= 78 )
+                    //{
+                    //    if ( this.autoManager.AutoModeStateProperty != eAutoModeState.Run )
+                    //        return;
 
-                        if ( this.VehicleStateProperty == eVehicleState.Charge || this.IsCharging() || this.BatteryChargeState )
-                        {
-                            int result = ConstInt.EXECUTE_SUCCESS;
-                            result = this.StopBatteryCharge();
-                            if ( result != ConstInt.EXECUTE_SUCCESS )
-                                this.OccurVehicleAlarm( result );
-                        }
-                    }
+                    //    if ( this.VehicleStateProperty == eVehicleState.Charge || this.CheckBatteryCharge() || this.BatteryChargeState )
+                    //    {
+                    //        int result = ConstInt.EXECUTE_SUCCESS;
+                    //        result = this.StopBatteryCharge();
+                    //        if ( result != ConstInt.EXECUTE_SUCCESS )
+                    //            this.OccurVehicleAlarm( result );
+                    //    }
+                    //}
                     break;
+
                 case eDataKind.SOH:
                     this.BatteryStateOfHealth = (double)obj.Value;
                     break;
+
                 case eDataKind.ResidualCapacity:
                     this.BatteryCapacity = (double)obj.Value;
                     break;
+
                 case eDataKind.ResidualEnergy:
                     this.BatteryEnergy = (double)obj.Value;
                     break;
+
                 case eDataKind.Temperature:
                     this.BatteryTemperature = (double)obj.Value;
                     break;
+
                 default:
                     break;
             }

+ 37 - 5
Dev/OHV/VehicleControlSystem/Managers/HostManager.cs

@@ -77,7 +77,7 @@ namespace VehicleControlSystem.Managers
             msg.Tag = obj.ToString("0000");
             msg.IsSubCode1 = vehicle.IsContain;
             msg.IsSubCode2 = vehicle.IsMoving;
-            msg.IsSubCode3 = true;
+            msg.IsSubCode3 = false;
             this.manager.Send( msg );
         }
 
@@ -88,7 +88,7 @@ namespace VehicleControlSystem.Managers
             msg.Tag = obj.ToString("0000");
             msg.IsSubCode1 = vehicle.IsContain;
             msg.IsSubCode2 = vehicle.IsMoving;
-            msg.IsSubCode3 = false;
+            msg.IsSubCode3 = true;
             this.manager.Send( msg );
         }
 
@@ -383,12 +383,43 @@ namespace VehicleControlSystem.Managers
                     break;
                 case OHVConnector.eKind.Z:
                     break;
+                case eKind.G:
+                    ReceiveGCommand( msg );
+                    break;
                 default:
                     break;
             }
 
         }
 
+        private void ReceiveGCommand( OCSMessage msg )
+        {
+            this.Reply( msg );
+
+            var cmd = new Command();
+
+            var info = sql.VehicleInfoDAL.GetAll().FirstOrDefault();
+            if ( info.MachineMode == eMachineMode.LocalMode )
+            {
+                loggerHost.E( $"[OCS] Cmd - Current Mode Local Mode " );
+                return;
+            }
+
+            if ( this.sql.CommandDAL.Count > 0 )
+            {
+                logger.W( $"[{this.GetType().Name}] - Has Command / Target {cmd.TargetID} / Type {cmd.Type}" );
+                return;
+            }
+
+            cmd.TargetID = msg.Tag;
+            cmd.Type = eCommandType.Move;
+            cmd.ByWho = eCommandByWho.Host;
+            cmd.TargetList = new List<string>( msg.ViaRouteList );
+
+            this.sql.CommandDAL.Insert( cmd );
+            logger.I( $"[Command] - Add Host : Target {cmd.TargetID} / Type {cmd.Type}" );
+        }
+
         void Reply( OCSMessage recieve )
         {
             var reply = new OCSMessage();
@@ -560,9 +591,10 @@ namespace VehicleControlSystem.Managers
             msg.Kind = eKind.B;
             var bData = volt;
             msg.Tag = bData.ToString( "00.00" ).Replace( ".", "" );
-            msg.IsSubCode1 = this.vehicle.IsContain;
-            msg.IsSubCode2 = vehicle.IsMoving;
-            msg.IsSubCode3 = vehicle.IsError;
+            msg.SubCode = this.vehicle.BatteryStateOfCharge.ToString( "000" );
+            //msg.IsSubCode1 = this.vehicle.IsContain;
+            //msg.IsSubCode2 = vehicle.IsMoving;
+            //msg.IsSubCode3 = vehicle.IsError;
 
             this.manager.Send( msg );
         }