Bläddra i källkod

현장 Update, Conveyor Class

SK.Kang 6 år sedan
förälder
incheckning
fed8706e32

+ 1 - 1
Dev/OHV/OHV.Module.Interactivity/PopUp/ConveyorControlView.xaml

@@ -257,7 +257,7 @@
 
                     <Grid Grid.Column="1">
                         <StackPanel VerticalAlignment="Top" HorizontalAlignment="Center" Margin="20">
-                            <Button Content="Carrier Control" Foreground="Orange" Background="{x:Null}" FontSize="20"
+                            <Button Content="Clamp Control" Foreground="Orange" Background="{x:Null}" FontSize="20"
                             VerticalAlignment="Top" Width="Auto" Height="50"
                             HorizontalAlignment="Left"/>
                         </StackPanel>

+ 2 - 2
Dev/OHV/OHV.SqliteDAL/OHVDbInitializer.cs

@@ -143,13 +143,13 @@ namespace OHV.SqliteDAL
                 {
                     Name = ConstString.AXIS_CARRIER_LOCK_LEFT,
                     Scale = 0.001,
-                    Address = "100.100.100.20",
+                    Address = "192.168.0.40",
                 },
                 new AxisConfig
                 {
                     Name = ConstString.AXIS_CARRIER_LOCK_RIGHT,
                     Scale = 0.001,
-                    Address = "100.100.100.21",
+                    Address = "192.168.0.41",
                 }
             } );
 

+ 136 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Conveyor.cs

@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using GSG.NET.Logging;
+using GSG.NET.Utils;
+using VehicleControlSystem.ControlLayer.IO;
+
+namespace VehicleControlSystem.ControlLayer
+{
+    public class Conveyor
+    {
+        Logger logger = Logger.GetLogger();
+        EzIO ezIO = null;
+
+        public Conveyor(EzIO io)
+        {
+            this.ezIO = io;
+        }
+
+        int OnOffConveyor( bool isOn, bool isLoad = false )
+        {
+            if ( IsInverterError() )
+                return 16;
+
+            if ( isLoad )
+                this.ezIO.OutputOn( "OUT_CV_CWCCW" );
+            else
+                this.ezIO.OutputOff( "OUT_CV_CWCCW" );
+
+            if ( isOn )
+                this.ezIO.OutputOn( "OUT_CV_RUN" );
+            else
+                this.ezIO.OutputOff( "OUT_CV_RUN" );
+
+            return 0;
+        }
+
+        void SetConveyorSpeed( bool IsHight )
+        {
+            if ( IsHight )
+                this.ezIO.WriteOutputIO( "OUT_CV_DA", true );
+            else
+                this.ezIO.WriteOutputIO( "OUT_CV_DA", false );
+        }
+
+        bool IsCvRun() => this.ezIO.IsOn( "OUT_CV_RUN" );
+        bool IsCvCWCCW() => this.ezIO.IsOn( "OUT_CV_CWCCW" );
+
+        /// <summary>
+        /// 입구 감지 로딩시 감속 사용
+        /// </summary>
+        /// <returns></returns>
+        bool IsDetectedLoadStart() => this.ezIO.IsOn( "IN_CV_DETECT_00" );
+
+        /// <summary>
+        /// 실물 감지
+        /// </summary>
+        /// <returns></returns>
+        public bool IsDetectedCenter() => this.ezIO.IsOn( "IN_CV_DETECT_01" );
+
+        public bool IsDetectedLoadStop() => this.ezIO.IsOn( "IN_CV_DETECT_02" );
+        bool IsInverterError() => !this.ezIO.IsOn( "IN_CV_ERROR" ); //Normal Close 로 생각 됨.
+        public bool IsLifterPositinCheck() => this.ezIO.IsOn( "IN_LIFTER_POSITION_DETECT" );
+        public bool IsLifterDuplication() => this.ezIO.IsOn( "IN_LIFTER_DUPLICATION_DETECT" );
+        public bool IsPIOInterLockOn() => this.ezIO.IsOn( "OUT_PIO_INTERLOCK" );
+
+        public int ConveyorLoad()
+        {
+            if ( IsDetectedCenter() )
+                return 9;
+
+            logger.D( "[Manual Load] - Conveyor On" );
+            OnOffConveyor( true, true );
+
+            bool isStartDetected = false;
+            long sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) ) //Wait 20Sec
+                {
+                    OnOffConveyor( false, true );
+                    return 10;
+                }
+
+                if ( this.IsDetectedLoadStart() && !isStartDetected )
+                    isStartDetected = true;
+
+                if ( !this.IsDetectedLoadStart() && isStartDetected )
+                {
+                    this.SetConveyorSpeed( false );
+                    logger.D( "[Manual Load] - Conveyor Slow State" );
+                }
+
+                if ( IsDetectedLoadStop() )
+                    break;
+            }
+            OnOffConveyor( false );
+
+            logger.D( "[Manual Load] - Conveyor Off" );
+
+            return 0;
+        }
+
+        public int ConveyorUnload()
+        {
+            if ( !IsDetectedCenter() )
+                return 11;
+
+            logger.D( "[Manual Unload] - Conveyor On" );
+            OnOffConveyor( true, false );
+
+            long sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) ) //Wait 20Sec
+                {
+                    OnOffConveyor( false, false );
+                    return 12;
+                }
+
+                if ( !IsDetectedLoadStart() && !IsDetectedCenter() )
+                    break;
+            }
+            Thread.Sleep( 2000 );
+            OnOffConveyor( false );
+
+            logger.D( "[Manual Unload] - Conveyor Off" );
+
+            return 0;
+        }
+
+    }
+}

+ 13 - 3
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -312,6 +312,7 @@ namespace VehicleControlSystem.ControlLayer
         Steering steering = null;
         AutoManager autoManager = null;
         BMUManager bMUManager = null;
+        private Conveyor conveyor = null;
 
         ThreadCancel cancel = new ThreadCancel();
         TaskCancel taskCancel = new TaskCancel();
@@ -487,6 +488,7 @@ namespace VehicleControlSystem.ControlLayer
             this.CreateSteering();
             this.CreateDrive();
             this.CreateBMUManager();
+            this.CreateConveyor();
 
             ThreadStart();
 
@@ -1163,7 +1165,7 @@ namespace VehicleControlSystem.ControlLayer
         public bool IsDetectedCenter() => this.iO.IsOn( "IN_CV_DETECT_01" );
 
         bool IsDetectedLoadStop() => this.iO.IsOn( "IN_CV_DETECT_02" );
-        bool IsInverterError() => !this.iO.IsOn( "IN_CV_ERROR" ); //Normal Close로 생각 됨.
+        bool IsInverterError() => !this.iO.IsOn( "IN_CV_ERROR" ); //Normal Close 로 생각 됨.
         bool IsLifterPositinCheck() => this.iO.IsOn( "IN_LIFTER_POSITION_DETECT" );
         bool IsLifterDuplication() => this.iO.IsOn( "IN_LIFTER_DUPLICATION_DETECT" );
         bool IsPIOInterLockOn() => this.iO.IsOn( "OUT_PIO_INTERLOCK" );
@@ -1447,8 +1449,12 @@ namespace VehicleControlSystem.ControlLayer
                         return 0;
                 }
 
-                if ( this.iO.IsOn( "IN_PIO_RECEIVE_COMPLITE" ) )
-                    break;
+
+                if ( !IsDetectedLoadStart() && !IsDetectedCenter() )
+                {
+                    if ( this.iO.IsOn( "IN_PIO_RECEIVE_COMPLITE" ) )
+                        break;
+                }
             }
 
             if ( !IsDetectedCenter() )
@@ -1496,6 +1502,10 @@ namespace VehicleControlSystem.ControlLayer
             this.motion = new GSIMotion( this.sql );
             this.motion.PropertyChanged += Motion_PropertyChanged;
         }
+        void CreateConveyor()
+        {
+            this.conveyor = new Conveyor( this.iO );
+        }
         void CreateBMUManager()
         {
             this.bMUManager = new BMUManager();

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

@@ -118,6 +118,7 @@
     <Compile Include="ControlLayer\Axis\IAxis.cs" />
     <Compile Include="ControlLayer\Clamp.cs" />
     <Compile Include="ControlLayer\ControlObjectBase.cs" />
+    <Compile Include="ControlLayer\Conveyor.cs" />
     <Compile Include="ControlLayer\IO\BitBlock.cs" />
     <Compile Include="ControlLayer\IO\Delegates.cs" />
     <Compile Include="ControlLayer\IO\EzBoard.cs" />