Sfoglia il codice sorgente

Merge branch 'master' of http://unque781.synology.me:3000/GSI/OHV

ys-hwang 6 anni fa
parent
commit
286e676a66
32 ha cambiato i file con 1141 aggiunte e 547 eliminazioni
  1. 15 1
      Dev/Connection/OHVProtocolServer/OHVConnector/Manager.cs
  2. 43 24
      Dev/Connection/OHVProtocolServer/OHVConnector/OCSMessage.cs
  3. 16 3
      Dev/Connection/OHVProtocolServer/OHVProtocolClient/MainWindow.xaml
  4. 116 9
      Dev/Connection/OHVProtocolServer/OHVProtocolClient/MainWindow.xaml.cs
  5. 4 0
      Dev/Connection/OHVProtocolServer/OHVProtocolClient/OHVProtocolClient.csproj
  6. 1 1
      Dev/Connection/OHVProtocolServer/OHVProtocolClient/log4net.xml
  7. 162 0
      Dev/OHV/Assambly/GSG.NET.XML
  8. BIN
      Dev/OHV/Assambly/GSG.NET.dll
  9. BIN
      Dev/OHV/Assambly/GSG.NET.pdb
  10. BIN
      Dev/OHV/Assambly/OHVConnector.dll
  11. BIN
      Dev/OHV/Assambly/OHVConnector.pdb
  12. 2 1
      Dev/OHV/OHV.Common/Model/Command.cs
  13. 4 0
      Dev/OHV/OHV.Common/Model/Route.cs
  14. 4 0
      Dev/OHV/OHV.Common/Shareds/ConstString.cs
  15. 1 0
      Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs
  16. 4 0
      Dev/OHV/OHV.Module.ListViews/OHV.Module.ListViews.csproj
  17. 10 2
      Dev/OHV/OHV.Module.ListViews/Views/CommandListViewModel.cs
  18. 4 22
      Dev/OHV/OHV.SqliteDAL/DAL/ConfigDAL.cs
  19. 53 15
      Dev/OHV/OHV.SqliteDAL/OHVDbInitializer.cs
  20. 2 1
      Dev/OHV/OHV.Vehicle/App.xaml.cs
  21. 2 10
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml
  22. 29 14
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs
  23. 5 1
      Dev/OHV/OHV.Vehicle/OHV.Vehicle.csproj
  24. 9 1
      Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs
  25. 0 256
      Dev/OHV/VehicleControlSystem/ControlLayer/Conveyor.cs
  26. 2 0
      Dev/OHV/VehicleControlSystem/ControlLayer/Motion/GSIMotion.cs
  27. 501 122
      Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs
  28. 3 0
      Dev/OHV/VehicleControlSystem/Managers/AutoManager.cs
  29. 87 5
      Dev/OHV/VehicleControlSystem/Managers/HostManager.cs
  30. 55 55
      Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs
  31. 6 2
      Dev/OHV/VehicleControlSystem/VCSystem.cs
  32. 1 2
      Dev/OHV/VehicleControlSystem/VehicleControlSystem.csproj

+ 15 - 1
Dev/Connection/OHVProtocolServer/OHVConnector/Manager.cs

@@ -382,7 +382,7 @@ namespace OHVConnector
         void _OnRecd(OCSMessage recd)
         {
             //Alive Check Reply
-            if (recd.Kind == eKind.A && !ModeActive)
+            if (recd.Kind == eKind.A && !ModeActive) //자동으로 응답을 보낸다. OCS 가 Active 상태
             {
                 var reply = new OCSMessage()
                 {
@@ -397,6 +397,12 @@ namespace OHVConnector
                 return;
             }
 
+            if ( recd.Kind == eKind.C )
+            {
+                this.qQ.Enqueue( new QoRecd { Arg0 = recd } );
+                return;
+            }
+
             //Send 한 Message 의 Reply 로 판단.
             if (this.quzT3.HasId(recd.CheckSum))
             {
@@ -486,6 +492,12 @@ namespace OHVConnector
             msg.RevID = Config.HostID;
             msg.SendID = Config.ID;
 
+
+            if ( msg.Kind == eKind.C ) // Control Message 는 페어로 응답이 오지 않는다.
+            {
+                qqW.Enqueue( msg );
+            }
+
             if (this.quzT3.HasId(msg.GetCheckSum()))
             {
                 _OnLog("quzT3 Has ID" + msg.LogFormat());
@@ -523,6 +535,8 @@ namespace OHVConnector
                 _OnLog("Reply fail not connected" + msg.LogFormat());
                 return;
             }
+            msg.RevID = Config.HostID;
+            msg.SendID = Config.ID;
 
             qqW.Enqueue(msg);
         }

+ 43 - 24
Dev/Connection/OHVProtocolServer/OHVConnector/OCSMessage.cs

@@ -56,18 +56,37 @@ namespace OHVConnector
             return $"{this.Id} - {this.RevID} <- {this.SendID} : kind [{this.Kind.ToString()}] / Tag [{this.Tag}] / SubCode [{this.SubCode}]";
         }
 
+        public int SubCodeToInt()
+        {
+            int result = 0;
+
+            if ( string.IsNullOrEmpty( this.SubCode ) )
+            {
+                StringBuilder sb = new StringBuilder();
+                sb.Append( this.IsSubCode1 ? "1" : "0" );
+                sb.Append( this.IsSubCode2 ? "1" : "0" );
+                sb.Append( this.IsSubCode3 ? "1" : "0" );
+
+                int.TryParse( sb.ToString(), out result );
+            }
+            else
+                int.TryParse( this.SubCode, out result );
+
+            return result;
+        }
+
         string MakeSubcode()
         {
-            if ( this.Kind == eKind.A)
+            if ( !string.IsNullOrEmpty(this.SubCode) )
             {
                 return this.SubCode;
             }
             else
             {
                 StringBuilder sb = new StringBuilder();
-                sb.Append(this.IsSubCode1 ? "1" : "0");
-                sb.Append(this.IsSubCode2 ? "1" : "0");
-                sb.Append(this.IsSubCode3 ? "1" : "0");
+                sb.Append( this.IsSubCode1 ? "1" : "0" );
+                sb.Append( this.IsSubCode2 ? "1" : "0" );
+                sb.Append( this.IsSubCode3 ? "1" : "0" );
 
                 return this.SubCode = sb.ToString();
             }
@@ -76,39 +95,39 @@ namespace OHVConnector
         public MemoryBuffer ToMemoryBuffer()
         {
             var mb = new MemoryBuffer();
-            mb.Append(STX);
-            mb.AppendAscii(RevID);
-            mb.AppendAscii(SendID);
-            mb.AppendAscii(this.Kind.ToString());
-            mb.AppendAscii(this.Tag);
-            mb.AppendAscii(MakeSubcode());
-            mb.Append(GetCheckSum(mb.ToBytes));
-            mb.Append(ETX);
+            mb.Append( STX );
+            mb.AppendAscii( RevID );
+            mb.AppendAscii( SendID );
+            mb.AppendAscii( this.Kind.ToString() );
+            mb.AppendAscii( this.Tag );
+            mb.AppendAscii( MakeSubcode() );
+            mb.Append( GetCheckSum( mb.ToBytes ) );
+            mb.Append( ETX );
 
             return mb;
         }
 
         public byte GetCheckSum()
         {
-            var mb = new MemoryBuffer(18);
-            mb.Append(STX);
-            mb.AppendAscii(RevID);
-            mb.AppendAscii(SendID);
-            mb.AppendAscii(this.Kind.ToString());
-            mb.AppendAscii(this.Tag);
-            mb.AppendAscii(MakeSubcode());
-
-            return GetCheckSum(mb.ToBytes);
+            var mb = new MemoryBuffer( 18 );
+            mb.Append( STX );
+            mb.AppendAscii( RevID );
+            mb.AppendAscii( SendID );
+            mb.AppendAscii( this.Kind.ToString() );
+            mb.AppendAscii( this.Tag );
+            mb.AppendAscii( MakeSubcode() );
+
+            return GetCheckSum( mb.ToBytes );
         }
 
-        byte GetCheckSum(byte[] bs)
+        byte GetCheckSum( byte[] bs )
         {
             byte rb = 0;
-            foreach( var item in bs)
+            foreach ( var item in bs )
             {
                 rb += item;
             }
-            return (byte)(rb & 0xff);
+            return (byte)( rb & 0xff );
         }
     }
 }

+ 16 - 3
Dev/Connection/OHVProtocolServer/OHVProtocolClient/MainWindow.xaml

@@ -1,13 +1,26 @@
-<Window x:Class="OHVProtocolClient.MainWindow"
+<Window
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:OHVProtocolClient"
+        xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:OHVConnector="clr-namespace:OHVConnector;assembly=OHVConnector" x:Class="OHVProtocolClient.MainWindow"
         mc:Ignorable="d"
         Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">
+    <Window.Resources>
+        <ObjectDataProvider x:Key="MessageKind" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
+            <ObjectDataProvider.MethodParameters>
+                <x:Type TypeName="OHVConnector:eKind"/>
+            </ObjectDataProvider.MethodParameters>
+        </ObjectDataProvider>
+    </Window.Resources>
     <Grid>
-        <Label x:Name="lblState" Content="Connection State" Background="Gray" Height="25" Width="110" Margin="10,10,672,379"></Label>
-        <Button Content="Button" HorizontalAlignment="Left" Height="26" Margin="10,42,0,0" VerticalAlignment="Top" Width="110"/>
+        <Label x:Name="lblState" Content="Connection State" Background="Gray" Height="25" Width="110" Margin="10,10,672,379"/>
+        <Button x:Name="btnSend" Content="Alive" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="10,60,0,0" Click="btnSend_Click"/>
+        <TextBox x:Name="txtTag" HorizontalAlignment="Left" Height="22" Margin="139,88,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
+        <Button Content="Send" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="395,88,0,0" Click="Button_Click" Height="22"/>
+        <TextBox x:Name="txtSubCode" HorizontalAlignment="Left" Height="22" Margin="267,88,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
+        <ComboBox HorizontalAlignment="Left" Margin="10,88,0,0" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Source={StaticResource MessageKind}}" x:Name="comboMessageKind"/>
+
     </Grid>
 </Window>

+ 116 - 9
Dev/Connection/OHVProtocolServer/OHVProtocolClient/MainWindow.xaml.cs

@@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
 using GSG.NET.Logging;
+using GSG.NET.Quartz;
 using OHVConnector;
 
 namespace OHVProtocolClient
@@ -24,6 +25,8 @@ namespace OHVProtocolClient
     {
         static Logger logger = Logger.GetLogger("Client");
 
+        Manager manager = null;
+
         public MainWindow()
         {
             InitializeComponent();
@@ -34,16 +37,19 @@ namespace OHVProtocolClient
             string basePath = AppDomain.CurrentDomain.BaseDirectory;
             LogUtils.Configure(basePath + "/log4net.xml");
 
-            var cn = new Manager();
-            cn.Config = new Config() { ID = "V0001" };
-            cn.Connect(true);
+            QuartzUtils.Init( 10 );
+
+            manager = new Manager();
+            manager.Config = new Config() { ID = "S0", HostID="V0001" };
+            manager.Connect(true);
+
+            manager.OnRecd += Cn_OnRecd;
+            manager.OnContd += Cn_OnContd;
+            manager.OnDiscontd += Cn_OnDiscontd;
+            manager.OnLog += Cn_OnLog;
+            manager.OnT3Timeout += Cn_OnT3Timeout;
+            manager.OnSent += Cn_OnSent;
 
-            cn.OnRecd += Cn_OnRecd;
-            cn.OnContd += Cn_OnContd;
-            cn.OnDiscontd += Cn_OnDiscontd;
-            cn.OnLog += Cn_OnLog;
-            cn.OnT3Timeout += Cn_OnT3Timeout;
-            cn.OnSent += Cn_OnSent;
         }
 
         private void Cn_OnSent(OCSMessage msg)
@@ -64,16 +70,117 @@ namespace OHVProtocolClient
         private void Cn_OnDiscontd(string id, Exception e)
         {
             this.lblState.Background = Brushes.Gray;
+
+            QuartzUtils.StopSchedule( "Scode" );
         }
 
         private void Cn_OnContd(string id)
         {
            this.lblState.Background = Brushes.Green;
+
+            QuartzUtils.Invoke( "Scode", QuartzUtils.GetExpnMinute( 3 ), RequestScode );
+
+            RequestBcode();
         }
 
         private void Cn_OnRecd(OCSMessage msg)
         {
             logger.I("[Received] : " + msg.LogFormat());
+
+            switch ( msg.Kind )
+            {
+                case eKind.Unknown:
+                    break;
+                case eKind.E:
+                    break;
+
+                case eKind.S:
+                case eKind.B:
+                case eKind.H:
+                case eKind.F:
+                    ReplyMessage( msg );
+                    break;
+
+                case eKind.T:
+                    break;
+                case eKind.C:
+                    break;
+                case eKind.P:
+                    break;
+                case eKind.I:
+                    break;
+                case eKind.O:
+                    break;
+                case eKind.A:
+                    break;
+                case eKind.L:
+                    break;
+                case eKind.U:
+                    break;
+                case eKind.M:
+                    break;
+                case eKind.R:
+                    break;
+                case eKind.Z:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void ReplyMessage(OCSMessage msg )
+        {
+            var reply = new OCSMessage();
+            reply.Kind = msg.Kind;
+            reply.Tag = msg.Tag;
+            reply.SubCode = msg.SubCode;
+            this.manager.Reply( reply );
         }
+
+        void RequestScode()
+        {
+            var msg = new OCSMessage();
+            msg.Kind = eKind.R;
+            msg.Tag = "0000";
+            msg.SubCode = "100";
+
+            this.manager.Send( msg );
+        }
+
+        void RequestBcode()
+        {
+            var msg = new OCSMessage();
+            msg.Kind = eKind.R;
+            msg.Tag = "0000";
+            msg.SubCode = "010";
+
+            this.manager.Send( msg );
+        }
+
+        private void btnSend_Click( object sender, RoutedEventArgs e )
+        {
+            var om = new OCSMessage();
+            om.Id = "S0";
+            om.Kind = eKind.A;
+            //om.RevID = "V0001";
+            //om.SendID = om.Id;
+            om.Tag = DateTime.Now.ToString( "mmss" );
+            om.SubCode = DateTime.Now.ToString( "fff" );
+
+            this.manager.Send( om );
+        }
+
+        private void Button_Click( object sender, RoutedEventArgs e )
+        {
+            OCSMessage meg = new OCSMessage();
+            meg.RevID = "V0001";
+            meg.SendID = "A0";
+            meg.Kind = (eKind)Enum.ToObject( typeof( eKind ), this.comboMessageKind.SelectedItem );
+            meg.Tag = this.txtTag.Text;
+            meg.SubCode = this.txtSubCode.Text;
+
+            this.manager.Send( meg );
+        }
+
     }
 }

+ 4 - 0
Dev/Connection/OHVProtocolServer/OHVProtocolClient/OHVProtocolClient.csproj

@@ -34,6 +34,10 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Quartz, Version=1.0.3.2, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\OHV\Assambly\Quartz.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />

+ 1 - 1
Dev/Connection/OHVProtocolServer/OHVProtocolClient/log4net.xml

@@ -54,7 +54,7 @@
 	</appender>-->
 
 	<appender name="ClientAppender" type="GSG.NET.Logging.FileAppender, GSG.NET">
-		<file value="D:\LOG\OHV\Vehicle\Client.log" />
+		<file value="D:\LOG\OHV\OCS_Simulation\Client.log" />
 		<appendToFile value="true" />
 		<rollingStyle value="Date" />
 		<backupDays value="180" />

+ 162 - 0
Dev/OHV/Assambly/GSG.NET.XML

@@ -1572,6 +1572,168 @@
             </summary>
             <returns></returns>
         </member>
+        <member name="T:GSG.NET.OSView.EventLogSpy">
+            <summary>
+            <para>Event 로그를 읽는것이 느려서</para>
+            <para>EntryWritten을 활용하는 방법으로 구현한다.</para>
+            </summary>
+        </member>
+        <member name="E:GSG.NET.OSView.EventLogSpy.OnEntryWritten">
+            <summary/>
+        </member>
+        <member name="T:GSG.NET.OSView.EventLogSpy.LogType">
+            <summary/>
+        </member>
+        <member name="F:GSG.NET.OSView.EventLogSpy.LogType.Application">
+            <summary/>
+        </member>
+        <member name="F:GSG.NET.OSView.EventLogSpy.LogType.System">
+            <summary/>
+        </member>
+        <member name="F:GSG.NET.OSView.EventLogSpy.LogType.Security">
+            <summary/>
+        </member>
+        <member name="F:GSG.NET.OSView.EventLogSpy.LogType.Setup">
+            <summary/>
+        </member>
+        <member name="M:GSG.NET.OSView.EventLogSpy.Watch(GSG.NET.OSView.EventLogSpy.LogType)">
+            <summary/>
+        </member>
+        <member name="M:GSG.NET.OSView.EventLogSpy.Close">
+            <summary/>
+        </member>
+        <member name="M:GSG.NET.OSView.EventLogSpy.WarnOrError(System.Diagnostics.EventLogEntry)">
+            <summary>
+            <para>Waring 또는 에러인지 검사.</para>
+            </summary>
+        </member>
+        <member name="T:GSG.NET.OSView.Mgnt">
+            <summary>
+            Management
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.PrinterNames">
+            <summary/>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.CpuUseRate">
+            <summary>
+            <para>CPU 사용률 % / 100%기준.</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.ProcCpu1UseRate(System.String)">
+            <summary>
+            <para>Process 의 CPU 사용률</para>
+            <para>1 cpu 기준이므로 multi cpu 일 경우 processor count 로 나눠야 한다.</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.ProcCpuUseRate(System.String)">
+            <summary>
+            <para>Logical CPU 기준으로 나눈값</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.ProcMemUseKB(System.String)">
+            <summary>
+            <para>메모리 사용량 KB</para>
+            <para>PrivateMemorySize</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.ProcMemPeakUseKB(System.String)">
+            <summary>
+            <para>Peak 메모리 사용량 KB</para>
+            <para>PrivateMemorySize</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemPhysicalKB">
+            <summary>
+            <para>Physical Memory Size KB 단위 추출</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemVirtualKB">
+            <summary>
+            <para>Virtual Memory Size KB 단위 추출</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemVirtualFreeKB">
+            <summary>
+            Virtual 기준 Free Kb size
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemVirtualUseKB">
+            <summary>
+            Virtual 기준 Use KB
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemPhysicalFreeKB">
+            <summary>
+            Physical 기준 Free size
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemPhysicalUseKB">
+            <summary>
+            Physical 기준 사용량 KB
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemPhysicalUseRate">
+            <summary>
+            Physical 기준 100분율
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.OsName">
+            <summary>
+            <para>OS Name 가져오기.</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.CpuCountLogical">
+            <summary>
+            <para>Retrieve Total Logical Cpu Count</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MemVirtualUseRate">
+            <summary>
+            <para>메모리 사용률 %</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.HddList">
+            <summary>
+            <para>Ready 상태이고, HDD 드라이브만 추출</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.LocalIpList">
+            <summary>
+            <para>Local IP Address 가져오기.</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.MacAddressList">
+            <summary>
+            <para>Local Mac Address 가져오기.</para>
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.Wql(System.String)">
+            <summary>
+            wql: SQL for WMI
+            </summary>
+        </member>
+        <member name="P:GSG.NET.OSView.Mgnt.Is64BitOperatingSystem">
+            <summary>
+            32, 64 bit check
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.GetDotnetVersion">
+            <summary>
+            CLR version retrieve
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.AddFirewall(System.String,System.Int32)">
+            <summary>
+            Tcp 방화벽 등록.
+            </summary>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.ServiceStart(System.String)">
+            <summary/>
+        </member>
+        <member name="M:GSG.NET.OSView.Mgnt.ServiceStop(System.String)">
+            <summary/>
+        </member>
         <member name="T:GSG.NET.Poco">
             <summary>
             POCO(Plain Old CLR Object)

BIN
Dev/OHV/Assambly/GSG.NET.dll


BIN
Dev/OHV/Assambly/GSG.NET.pdb


BIN
Dev/OHV/Assambly/OHVConnector.dll


BIN
Dev/OHV/Assambly/OHVConnector.pdb


+ 2 - 1
Dev/OHV/OHV.Common/Model/Command.cs

@@ -19,7 +19,8 @@ namespace OHV.Common.Model
         /// <summary>
         /// 두번째 명령을 주었음을 확인 위해.
         /// </summary>
-        public virtual bool IsSecondCommanded { get; set; }
+        public bool IsSecondCommanded { get; set; }
+
         public virtual bool IsSelected { get; set; }
 
         public Command()

+ 4 - 0
Dev/OHV/OHV.Common/Model/Route.cs

@@ -37,6 +37,10 @@ namespace OHV.Common.Model
         public double ScaleValue { get; set; }
         public double ScaleTolerance { get; set; }
         public bool UsePIO { get; set; }
+        /// <summary>
+        /// OCS 와 매칭 아이디.
+        /// </summary>
+        public string OCSMatchID { get; set; }
         public virtual bool IsSelected { get; set; }
 
     }

+ 4 - 0
Dev/OHV/OHV.Common/Shareds/ConstString.cs

@@ -8,10 +8,14 @@ namespace OHV.Common.Shareds
 {
     public class ConstString
     {
+        //Config
         public const string Addr = "OCSADDRESS";
         public const string PortNo = "OCSPORTNO";
         public const string VehicleID = "VEHICLEID";
         public const string OCSID = "OCSID";
+        public const string BuzzerStartReadyTime = "BUZZEER_START_READY";
+        public const string PIOInterLockTimeout = "PIO_INTERLOCK_TIMEOUT";
+        public const string PIOTimeOut = "PIO_TIMEOUT";
 
         //Axis Name
         public const string AXIS_CARRIER_LOCK_LEFT = "Axis_CarrierLock_Left";

+ 1 - 0
Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs

@@ -108,6 +108,7 @@
 		Axis,
 		Cylinder,
 		Drive,
+		IO,
 	}
 
 	public enum eBuzzerKind

+ 4 - 0
Dev/OHV/OHV.Module.ListViews/OHV.Module.ListViews.csproj

@@ -126,6 +126,10 @@
       <Project>{0d1f7fbc-bfb0-4ee4-852d-e2a8d62c5708}</Project>
       <Name>OHV.Common</Name>
     </ProjectReference>
+    <ProjectReference Include="..\OHV.Module.Interactivity\OHV.Module.Interactivity.csproj">
+      <Project>{d6402d97-2206-4d55-8097-8da9a01568cb}</Project>
+      <Name>OHV.Module.Interactivity</Name>
+    </ProjectReference>
     <ProjectReference Include="..\OHV.SqliteDAL\OHV.SqliteDAL.csproj">
       <Project>{122d81c8-9ab9-4ced-80d2-9c4f2f9deb4c}</Project>
       <Name>OHV.SqliteDAL</Name>

+ 10 - 2
Dev/OHV/OHV.Module.ListViews/Views/CommandListViewModel.cs

@@ -9,6 +9,7 @@ using System.Windows.Input;
 using OHV.Common.Events;
 using OHV.Common.Model;
 using OHV.Common.Shareds;
+using OHV.Module.Interactivity;
 using OHV.SqliteDAL;
 using Prism.Commands;
 using Prism.Events;
@@ -55,10 +56,12 @@ namespace OHV.Module.ListViews.Views
 
         IEventAggregator eventAggregator;
         SqliteManager sql;
+        MessageController messageController;
 
-        public CommandListViewModel(IEventAggregator ea, SqliteManager sql)
+        public CommandListViewModel(IEventAggregator ea, SqliteManager sql, MessageController msgController )
         {
             this.eventAggregator = ea;
+            this.messageController = msgController;
             this.sql = sql;
             this.sql.CommandDAL.ChangedProperty += this.RefreshCommandLIst;
 
@@ -97,7 +100,12 @@ namespace OHV.Module.ListViews.Views
         private void ExecuteSaveCommand()
         {
             Command cmd = new Command() { TargetID = TargetID, Type = SelectedCommandType };
-            sql.CommandDAL.Add(cmd);
+
+            var route = sql.RouteDal.GetRoute( TargetID );
+            if (route ==null )
+                messageController.ShowNotificationView( "Not Found TargetID" );
+            else
+                sql.CommandDAL.Add(cmd);
 
             this.TargetID = "None";
             this.SelectedCommandType = eCommandType.Move;

+ 4 - 22
Dev/OHV/OHV.SqliteDAL/DAL/ConfigDAL.cs

@@ -7,21 +7,8 @@ using OHV.Common.Model;
 
 namespace OHV.SqliteDAL.DAL
 {
-    public class ConfigDAL
+    public class ConfigDAL : GenericDAL<Config>
     {
-        public ConfigDAL()
-        {
-        }
-
-        public void Add(Config config)
-        {
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                db.Set<Config>().Add(config);
-                db.SaveChanges();
-            }
-        }
-
         public Config GetK(string ID)
         {
             Config config = null;
@@ -34,15 +21,10 @@ namespace OHV.SqliteDAL.DAL
             return config;
         }
 
-        public int Count()
+        public int GetValueToInt(string id )
         {
-            int count = 0;
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                count = db.Set<Config>().Count();
-            }
-
-            return count;
+            var v = GetK( id );
+            return Convert.ToInt32( v.Value );
         }
     }
 }

+ 53 - 15
Dev/OHV/OHV.SqliteDAL/OHVDbInitializer.cs

@@ -9,15 +9,15 @@ namespace OHV.SqliteDAL
 {
     public class OHVDbInitializer : SqliteDropCreateDatabaseWhenModelChanges<OHVDbContext>
     {
-        public OHVDbInitializer(DbModelBuilder modelBuilder) : base(modelBuilder, typeof(CustomHistory))
+        public OHVDbInitializer( DbModelBuilder modelBuilder ) : base( modelBuilder, typeof( CustomHistory ) )
         {
         }
 
-        protected override void Seed(OHVDbContext context)
+        protected override void Seed( OHVDbContext context )
         {
             //base.Seed( context );
             // Here you can seed your core data if you have any.
-            context.Set<Config>().AddRange(new List<Config>()
+            context.Set<Config>().AddRange( new List<Config>()
             {
                 new Config
                 {
@@ -47,16 +47,40 @@ namespace OHV.SqliteDAL
                 {
                     ID = ConstString.OCSID,
                     Name = ConstString.OCSID,
-                    Value = "SO",
+                    Value = "S0",
                     Desc = "OCS ID",
                     EditTime = DateTime.Now
                 },
-            });
+                new Config
+                {
+                    ID = ConstString.BuzzerStartReadyTime,
+                    Name = ConstString.BuzzerStartReadyTime,
+                    Value = "3000",
+                    Desc = "BeforeMoveBuzzer",
+                    EditTime = DateTime.Now
+                },
+                new Config
+                {
+                    ID = ConstString.PIOInterLockTimeout,
+                    Name= ConstString.PIOInterLockTimeout,
+                    Value = "30000",
+                    Desc = "PIO InterLock Time Out",
+                    EditTime = DateTime.Now,
+                },
+                new Config
+                {
+                    ID = ConstString.PIOTimeOut,
+                    Name= ConstString.PIOTimeOut,
+                    Value = "1000",
+                    Desc = "PIO Time Out",
+                    EditTime = DateTime.Now,
+                },
+            } ) ;
 
-            context.Set<AxisPositionData>().AddRange(new List<AxisPositionData>()
-            { 
+            context.Set<AxisPositionData>().AddRange( new List<AxisPositionData>()
+            {
                 new AxisPositionData
-                { 
+                {
                     AxisName = ConstString.AXIS_CARRIER_LOCK_LEFT,
                     Name = ConstString.TEACH_POSITION_LOCK,
                 },
@@ -75,9 +99,9 @@ namespace OHV.SqliteDAL
                     AxisName = ConstString.AXIS_CARRIER_LOCK_RIGHT,
                     Name = ConstString.TEACH_POSITION_UNLOCK,
                 },
-            });
+            } );
 
-            context.Set<AxisVelocityData>().AddRange(new List<AxisVelocityData>()
+            context.Set<AxisVelocityData>().AddRange( new List<AxisVelocityData>()
             {
                 new AxisVelocityData
                 {
@@ -102,9 +126,9 @@ namespace OHV.SqliteDAL
                     JogSlow = 2,
                     Tolerance = 1,
                 },
-            });
+            } );
 
-            context.Set<AxisConfig>().AddRange(new List<AxisConfig>()
+            context.Set<AxisConfig>().AddRange( new List<AxisConfig>()
             {
                 new AxisConfig
                 {
@@ -118,12 +142,26 @@ namespace OHV.SqliteDAL
                     Scale = 0.001,
                     Address = "100.100.100.21",
                 }
-            });
+            } );
 
-            context.Set<Alarm>().Add(new Alarm { AlarmId = 1, Kind = eAlarmKind.Axis, Name = "adfsdfds", Level = eAlarmLevel.Falut, });
+            context.Set<Alarm>().AddRange( new List<Alarm>()
+            {
+                new Alarm { AlarmId = 1, Kind = eAlarmKind.Axis, Name = "LeftClampServoError", Text="Left Clamp Lock Motion Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
+                new Alarm { AlarmId = 2, Kind = eAlarmKind.Axis, Name = "LeftClampServoError", Text="Left Clamp Unlock Motion Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
+            } );
 
             //context.Set<HisAlarm>().Add(new HisAlarm { AlarmId = 1, OccurTime = DateTime.Now.AddDays(-10) });
-            context.Set<Route>().Add(new Route { Id = 1, Name = "P01", PrePoint = "P00", NextPoint = "P02", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, UsePIO = true });
+            context.Set<Route>().Add( new Route { Id = 1, Name = "P01", PrePoint = "P11", NextPoint = "P02", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1000", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 2, Name = "P02", PrePoint = "P01", NextPoint = "P03", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1001", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 3, Name = "P03", PrePoint = "P02", NextPoint = "P04", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1002", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 4, Name = "P04", PrePoint = "P03", NextPoint = "P05", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1003", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 5, Name = "P05", PrePoint = "P04", NextPoint = "P06", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1004", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 6, Name = "P06", PrePoint = "P05", NextPoint = "P07", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1005", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 7, Name = "P07", PrePoint = "P06", NextPoint = "P08", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1006", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 8, Name = "P08", PrePoint = "P07", NextPoint = "P09", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1007", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 9, Name = "P09", PrePoint = "P08", NextPoint = "P10", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1008", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 10, Name = "P10", PrePoint = "P09", NextPoint = "P11", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1009", UsePIO = true } );
+            context.Set<Route>().Add( new Route { Id = 11, Name = "P11", PrePoint = "P10", NextPoint = "P01", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1010", UsePIO = true } );
         }
     }
 }

+ 2 - 1
Dev/OHV/OHV.Vehicle/App.xaml.cs

@@ -3,6 +3,7 @@ using System.Threading;
 using System.Windows;
 using CommonServiceLocator;
 using GSG.NET.Logging;
+using GSG.NET.Quartz;
 using GSG.NET.Utils;
 using OHV.Common.Events;
 using OHV.Common.Interfaces;
@@ -42,7 +43,7 @@ namespace OHV.Vehicle
 
             try
             {
-                //QuartzUtils.Init(10);
+                QuartzUtils.Init(10);
                 logger.I(string.Format(string.Empty.PadRight(40, '+') + $" Ver. {AssemblyUtils.GetVersion()} " + string.Empty.PadRight(40, '+')));
 
 

+ 2 - 10
Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml

@@ -29,14 +29,6 @@
                 </LinearGradientBrush>
             </Grid.Background>
 
-            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center">
-                <Button Margin="10,0,10,0" Command="{Binding ChangeLanguage}"
-                   Style="{DynamicResource MaterialDesignFloatingActionMiniButton}"     
-                   materialDesign:ShadowAssist.ShadowDepth="Depth5" Background="{Binding OcsBrush, FallbackValue={x:Null}}">
-                    OCS
-                </Button>
-            </StackPanel>
-
             <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                 <TextBlock Style="{StaticResource MaterialDesignHeadline3TextBlock}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="60" FontWeight="Bold">
                 Over Head Vehicle
@@ -195,12 +187,12 @@
 
                         <StackPanel>
                             <Button Margin="0,4,0,0" Height="30" Width="auto" Background="{x:Null}">
-                                <TextBlock HorizontalAlignment="Center"><Run Text="{Binding CPU, StringFormat={}{0:0.0}%}"/></TextBlock>
+                                <TextBlock HorizontalAlignment="Center"><Run Text="{Binding CPU, StringFormat={}{0:0.0} %}"/></TextBlock>
                             </Button>
 
                             <Button Margin="0,8,0,0" Background="{x:Null}">
                                 <StackPanel>
-                                    <TextBlock Text="{Binding RAM, StringFormat={}{0:0.0} GB}" HorizontalAlignment="Center"/>
+                                    <TextBlock Text="{Binding RAM, StringFormat={}{0:0.0} %}" HorizontalAlignment="Center"/>
                                 </StackPanel>
                             </Button>
 

+ 29 - 14
Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs

@@ -1,4 +1,5 @@
 using CommonServiceLocator;
+using GSG.NET.Utils;
 using OHV.Common.Events;
 using OHV.Common.Model;
 using OHV.Common.Shareds;
@@ -39,6 +40,7 @@ namespace OHV.Vehicle.Concept
             get { return this._cpu; }
             set { this.SetProperty(ref this._cpu, value); }
         }
+
         private double _totalCPU;
         public double TotalCPU
         {
@@ -49,8 +51,8 @@ namespace OHV.Vehicle.Concept
                 this.SetProperty(ref this._totalCPU, value);
             }
         }
-        public int UsageCPU { get; set; }
 
+        public int UsageCPU { get; set; }
         private double _ram;
         public double RAM
         {
@@ -199,26 +201,36 @@ namespace OHV.Vehicle.Concept
             dateTimer.Tick += (object sender, EventArgs e) =>
             {
                 this.DateTime = DateTime.Now;
-
             };
             dateTimer.Interval = TimeSpan.FromMilliseconds(500);
             dateTimer.Start();
 
-            DispatcherTimer deskTopTimer = new DispatcherTimer();
-            deskTopTimer.Tick += (object sender, EventArgs e) =>
-            {
-                this.CPU = dti.GetCpuUsage();
-                this.UsageCPU = (int)dti.GetCpuUsage();
-                this.RAM = dti.GetRamUsage();
-            };
-            deskTopTimer.Interval = TimeSpan.FromMilliseconds(1000);
-            deskTopTimer.Start();
+            //DispatcherTimer deskTopTimer = new DispatcherTimer();
+            //deskTopTimer.Tick += (object sender, EventArgs e) =>
+            //{
+            //    this.CPU = dti.GetCpuUsage();
+            //    this.UsageCPU = (int)dti.GetCpuUsage();
+            //    this.RAM = dti.GetRamUsage();
+            //};
+            //deskTopTimer.Interval = TimeSpan.FromMilliseconds(1000);
+            //deskTopTimer.Start();
 
-            this._totalCPU = dti.cpuResult;
-            this._cDrive = dti.GetCDrive();
+            //this._totalCPU = dti.cpuResult;
+            //this._cDrive = dti.GetCDrive();
 
-            this.SwVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
+            this.SwVersion = AssemblyUtils.GetVersion();
             this.LastBuildedTime = new Helpler.AssemblyInfo().Get_BuildDateTime();
+
+            GSG.NET.Quartz.QuartzUtils.Invoke("RESOURCE_CHECK", GSG.NET.Quartz.QuartzUtils.GetExpnSecond(1), QuzOnResourceUsage);
+        }
+
+        void QuzOnResourceUsage()
+        {
+            this.CPU = GSG.NET.OSView.Mgnt.CpuUseRate();
+            this.RAM = GSG.NET.OSView.Mgnt.MemPhysicalUseRate();
+
+            var ll = GSG.NET.OSView.Mgnt.HddList();
+            this.CDrive = ll.FirstOrDefault().AvailableFreeSpace / ConstUtils.ONE_GIGA_BYTES;
         }
 
         private void ExecuteAlarmResetCommand( )
@@ -314,6 +326,9 @@ namespace OHV.Vehicle.Concept
             {
                 var hisAlarm = args.Args as HisAlarm;
                 this.messageController.ShowNotificationView(args.MessageText);
+
+
+
             }
         }
 

+ 5 - 1
Dev/OHV/OHV.Vehicle/OHV.Vehicle.csproj

@@ -38,7 +38,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>..\OutRelese\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;SIMULATION</DefineConstants>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <Prefer32Bit>true</Prefer32Bit>
@@ -87,6 +87,10 @@
     <Reference Include="Prism.Wpf, Version=7.2.0.1422, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
       <HintPath>..\packages\Prism.Wpf.7.2.0.1422\lib\net45\Prism.Wpf.dll</HintPath>
     </Reference>
+    <Reference Include="Quartz, Version=1.0.3.2, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\Assambly\Quartz.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Configuration" />

+ 9 - 1
Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Threading;
 using System.Threading.Tasks;
 using FluentResults;
 using GSG.NET.Concurrent;
@@ -328,6 +329,9 @@ namespace VehicleControlSystem.ControlLayer
         /// <returns></returns>
         public int Lock_Sync()
         {
+#if SIMULATION
+            Thread.Sleep(2000);
+#else
             int result = 0;
 
             result = this.IsAllAxisOriginReturn();
@@ -357,6 +361,7 @@ namespace VehicleControlSystem.ControlLayer
             result = right.Wait4Done();
             if (result != EziMOTIONPlusELib.FMM_OK)
                 return 1;
+#endif
 
             return EziMOTIONPlusELib.FMM_OK;
         }
@@ -367,6 +372,9 @@ namespace VehicleControlSystem.ControlLayer
         /// <returns></returns>
         public int Unlock_Sync()
         {
+#if SIMULATION
+            Thread.Sleep(2000);
+#else
             int result = 0;
 
             result = this.IsAllAxisOriginReturn();
@@ -396,7 +404,7 @@ namespace VehicleControlSystem.ControlLayer
             result = right.Wait4Done();
             if (result != EziMOTIONPlusELib.FMM_OK)
                 return 4;
-
+#endif
 
             return EziMOTIONPlusELib.FMM_OK;
         }

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

@@ -1,256 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using GSG.NET.Logging;
-using GSG.NET.Utils;
-using GSG.NET.LINQ;
-using VehicleControlSystem.ControlLayer.IO;
-
-namespace VehicleControlSystem.ControlLayer
-{
-    public class Conveyor :ControlObjectBase
-    {
-        static Logger loggerPIO = Logger.GetLogger("PIO");
-        IIO iO = null;
-
-        public Conveyor(IIO io)
-        {
-            this.iO = io;
-        }
-
-        int OnOffConveyor(bool isOn, bool isCW = false)
-        {
-            if (IsInverterError())
-                return 16;
-
-            if (isCW)
-                this.iO.OutputOn("OUT_CV_CWCCW");
-            else
-                this.iO.OutputOff("OUT_CV_CWCCW");
-
-            if (isOn)
-                this.iO.OutputOn("OUT_CV_RUN");
-            else
-                this.iO.OutputOff("OUT_CV_RUN");
-
-            return 0;
-        }
-
-        void SetConveyorSpeed(bool IsHight)
-        {
-            if (IsHight)
-                this.iO.WriteOutputIO("OUT_CV_DA", true);
-            else
-                this.iO.WriteOutputIO("OUT_CV_DA", false);
-        }
-
-        /// <summary>
-        /// 입구 감지 로딩시 감속 사용
-        /// </summary>
-        /// <returns></returns>
-        bool IsDetectedLoadStart() => this.iO.IsOn("IN_CV_DETECT_00");
-
-        /// <summary>
-        /// 실물 감지
-        /// </summary>
-        /// <returns></returns>
-        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");
-        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");
-
-        int Load_Carrier()
-        {
-            if (IsDetectedCenter())
-                return 9;
-
-            OnOffConveyor(true, true);
-
-            long sTime = SwUtils.CurrentTimeMillis;
-            while (true)
-            {
-                if (SwUtils.Gt(sTime, 20 * ConstUtils.ONE_SECOND)) //Wait 20Sec
-                {
-                    OnOffConveyor(false, true);
-                    return 10;
-                }
-
-                if (IsDetectedLoadStart())
-                    break;
-            }
-
-            return 0;
-        }
-
-        int UnloadCarrier()
-        {
-            if (!IsDetectedLoadStart())
-                return 11;
-
-            OnOffConveyor(true, true);
-
-            long sTime = SwUtils.CurrentTimeMillis;
-            while (true)
-            {
-                if (SwUtils.Gt(sTime, 20 * ConstUtils.ONE_SECOND)) //Wait 20Sec
-                {
-                    OnOffConveyor(false, true);
-                    return 12;
-                }
-
-                if (!IsDetectedLoadStart())
-                    break;
-            }
-
-            return 0;
-        }
-
-        public int PIOAndLoad(string targetName)
-        {
-            if (this.IsInverterError())
-                return 16;
-
-            if (this.IsLifterPositinCheck())
-                return 14;
-
-            if (this.IsLifterDuplication())
-                return 11;
-
-            PIOClear();
-            loggerPIO.I($"Start Load PIO - [{targetName}]");
-
-            this.iO.WriteOutputIO("OUT_PIO_RECEIVE_RUN", true);
-            loggerPIO.I("[Vehicle] - 4 Receive Run On");
-
-            if ( !this.iO.WaitChangeInputIO(true, 1000, "IN_PIO_SENDABLE"))
-            {
-                PIOClear();
-                loggerPIO.E("[Port] - 4 Ready Time Out");
-                return 10;
-            }
-            loggerPIO.E("[Port] - 4 Ready On");
-
-            this.SetConveyorSpeed(true);
-            this.OnOffConveyor(true, true);
-            this.iO.WriteOutputIO("OUT_PIO_RECEIVE_RUN", true);
-            loggerPIO.I("[Vehicle] - Conveyor Run");
-
-            if ( !this.iO.WaitChangeInputIO(true, 1000, "IN_PIO_SEND_RUN"))
-            {
-                this.OnOffConveyor(false, true);
-                PIOClear();
-                loggerPIO.E("[Port] - 5 Sending Run Time Out");
-                return 10;
-            }
-
-            bool isStartDetected = false;
-            var sTime = SwUtils.CurrentTimeMillis;
-            while (true)
-            {
-                if ( SwUtils.Gt(sTime, 20 * ConstUtils.ONE_SECOND))
-                {
-                    PIOClear();
-                    this.OnOffConveyor(false, true);
-                    loggerPIO.E("[Vehicle] Conveyor Wait Time Out");
-                    return 10; //Conveyor Moving Timeout
-                }
-
-                if (this.IsDetectedLoadStart() && !isStartDetected)
-                    isStartDetected = true;
-
-                if (!this.IsDetectedLoadStart() && isStartDetected)
-                    this.SetConveyorSpeed(false);
-
-                if (this.IsDetectedLoadStop()) break;
-
-                if (this.IsPIOInterLockOn())
-                {
-                    PIOClear();
-                    this.OnOffConveyor(false); //Stop
-                    loggerPIO.E("[Port] PIO InterLock On ");
-                    return 19; //Conveyor Moving Timeout
-                }
-            }
-
-            this.OnOffConveyor(false); //Stop
-            PIOClear();
-
-            this.iO.WriteOutputIO("OUT_PIO_RECIVE_COMPLITE", true);
-            this.iO.WriteOutputIO("OUT_PIO_RECIVE_COMPLITE", false, 1000);
-
-            return 0;
-        }
-
-        public int PIOAndUnload(string targetName)
-        {
-            if (this.IsInverterError())
-                return 16;
-
-            if (this.IsLifterDuplication())
-                return 15;
-
-            if (this.IsLifterPositinCheck())
-                return 13;
-
-            PIOClear();
-            loggerPIO.I($"Start Unload PIO - [{targetName}]");
-
-            if (!this.iO.IsOn("IN_PIO_READY"))
-            {
-                loggerPIO.E("[Port] - 1 Ready not On");
-                return 12;
-            }
-
-            this.iO.WriteOutputIO("OUT_PIO_READY", true);
-            loggerPIO.I("[Vehicle] - 1 Ready On");
-
-            if ( !this.iO.WaitChangeInputIO(true, 1000, "IN_PIO_RECEIVE_RUN"))
-            {
-                PIOClear();
-                loggerPIO.E("[Port] - 2 Receive CV Run Timeout");
-                return 12;
-            }
-
-            this.iO.WriteOutputIO("", true);
-            loggerPIO.I("[Vehicle] - 2 Send Run On");
-
-            this.SetConveyorSpeed(true);
-            this.OnOffConveyor(true);
-
-            var sTime = SwUtils.CurrentTimeMillis;
-            while (true)
-            {
-                if (SwUtils.Gt(sTime, 20 * ConstUtils.ONE_SECOND))
-                {
-                    PIOClear();
-                    this.OnOffConveyor(false, true);
-                    loggerPIO.E("[Port] Conveyor Wait Time Out");
-                    return 12; //Conveyor Moving Timeout
-                }
-
-                if (this.iO.IsOn("IN_PIO_RECEIVE_COMPLITE"))
-                    break;
-            }
-
-            this.OnOffConveyor(false); //Stop
-            PIOClear();
-
-            this.iO.WriteOutputIO("OUT_PIO_SEND_COMPLITE", true);
-            this.iO.WriteOutputIO("OUT_PIO_SEND_COMPLITE", false, 1000);
-
-            return 0;
-        }
-
-        void PIOClear()
-        {
-            string[] pio = { "OUT_PIO_READY", "OUT_PIO_SENDING_RUN", "OUT_PIO_SEND_COMPLITE", "OUT_PIO_RECEIVABLE", "OUT_PIO_RECEIVE_RUN", "OUT_PIO_RECIVE_COMPLITE", "OUT_PIO_INTERLOCK" };
-            pio.FwEach(x => { this.iO.OutputOff(x); });
-        }
-
-    }
-}

+ 2 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Motion/GSIMotion.cs

@@ -14,6 +14,8 @@ namespace VehicleControlSystem.ControlLayer.Motion
         public bool IsStop { get; set; }
         public double CurrentPos { get; set; }
 
+        public bool IsErrorOn { get; set; }
+
         public GSIMotion()
         {
 

+ 501 - 122
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading;
 using GSG.NET.Concurrent;
+using GSG.NET.LINQ;
 using GSG.NET.Logging;
 using GSG.NET.Quartz;
 using GSG.NET.Utils;
@@ -24,15 +25,39 @@ namespace VehicleControlSystem.ControlLayer
     /// </summary>
     public class Vehicle : ControlObjectBase, IDisposable
     {
+        /// <summary>
+        /// OCS Report Code
+        /// 목적지에 도착해서 Load, Unload 시 발생하는 Alarm
+        /// </summary>
+        public enum eFailCode
+        {
+            Load_PortHasNotCarrier = 1,
+            Load_VehicleHasCarrier,
+            Unload_PortHasCarrier,
+            Unload_VehicleHasNotCarrier,
+            LoadPIOInterlockTimeout,
+            UnlaodPIOInterlockTimeout,
+        }
+
         static Logger logger = Logger.GetLogger();
+        static Logger loggerPIO = Logger.GetLogger( "PIO" );
 
         #region Properties
         private double currentPosition;
 
+        /// <summary>
+        /// Tag 위치
+        /// </summary>
         public double CurrentPosition
         {
             get { return currentPosition; }
-            set { currentPosition = value; }
+            set
+            {
+                if ( this.currentPosition == value ) return;
+
+                this.currentPosition = value;
+                this.OnCurrentPotisionChanged?.Invoke( (int)value );
+            }
         }
 
         //이동
@@ -48,7 +73,7 @@ namespace VehicleControlSystem.ControlLayer
         public bool IsMoving { get; set; }
         public double BatteryVolt { get; set; }
         public bool IsError { get; set; }
-        public bool IsContain { get { return this.conveyor.IsDetectedCenter(); } }
+        public bool IsContain { get { return this.IsDetectedCenter(); } }
 
         public SubCmd CurrentSubCommand { get; private set; }
         #endregion
@@ -76,13 +101,14 @@ namespace VehicleControlSystem.ControlLayer
         public event Action OnManualLoad;
         public event Action OnManualUnload;
         public event Action OnManualCharging;
+
+        public event Action<eFailCode> OnFailReport;
         #endregion
 
         IIO iO = null;
         GSIMotion motion = null;
         SqliteManager sql = null;
         Clamp clamp = null;
-        Conveyor conveyor = null;
         Steering steering = null;
         AutoManager autoManager = null;
 
@@ -98,7 +124,7 @@ namespace VehicleControlSystem.ControlLayer
         public eObstacleState ObstacleStateProperty
         {
             get { return obstacleState; }
-            set { SetField(ref this.obstacleState, value); }
+            set { SetField( ref this.obstacleState, value ); }
         }
 
         private eVehicleState vehicleState;
@@ -106,50 +132,50 @@ namespace VehicleControlSystem.ControlLayer
         public eVehicleState VehicleStateProperty
         {
             get { return vehicleState; }
-            set { SetField(ref this.vehicleState, value); }
+            set { SetField( ref this.vehicleState, value ); }
         }
 
         IEventAggregator eventAggregator;
 
-        public Vehicle(IIO io, SqliteManager sqliteManager, IEventAggregator ea, AutoManager auto)
+        public Vehicle( IIO io, SqliteManager sqliteManager, IEventAggregator ea, AutoManager auto )
         {
             this.iO = io;
             this.motion = new GSIMotion();
             this.sql = sqliteManager;
             this.autoManager = auto;
 
-            this.obstacleBitList.AddRange(new string[]
+            this.obstacleBitList.AddRange( new string[]
             {
                 "OUT_OBSTRUCTION_PATTERN_00",
                 "OUT_OBSTRUCTION_PATTERN_01",
                 "OUT_OBSTRUCTION_PATTERN_02",
                 "OUT_OBSTRUCTION_PATTERN_03",
                 "OUT_OBSTRUCTION_PATTERN_04",
-            });
+            } );
 
             this.eventAggregator = ea;
 
-            this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Unsubscribe(ReceiveDriveControlEvent);
-            this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Subscribe(ReceiveDriveControlEvent);
+            this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Unsubscribe( ReceiveDriveControlEvent );
+            this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Subscribe( ReceiveDriveControlEvent );
         }
 
-        private void ReceiveDriveControlEvent(DriveControlEventArgs obj)
+        private void ReceiveDriveControlEvent( DriveControlEventArgs obj )
         {
-            if (this.autoManager.OperationModeProperty != eOperatationMode.ManualMode)
+            if ( this.autoManager.OperationModeProperty != eOperatationMode.ManualMode )
                 return;
 
             var msg = obj;
-            if (msg.EventDir == DriveControlEventArgs.eEventDir.ToBack)
+            if ( msg.EventDir == DriveControlEventArgs.eEventDir.ToBack )
             {
-                switch (msg.ControlKind)
+                switch ( msg.ControlKind )
                 {
                     case DriveControlEventArgs.eControlKind.MOVE:
                         break;
                     case DriveControlEventArgs.eControlKind.STOP:
                         break;
                     case DriveControlEventArgs.eControlKind.Steering:
-                        if (msg.MoveDir == DriveControlEventArgs.eMoveDir.LEFT)
-                            this.steering.ControlSteering(true);
+                        if ( msg.MoveDir == DriveControlEventArgs.eMoveDir.LEFT )
+                            this.steering.ControlSteering( true );
                         else
                             this.steering.ControlSteering();
                         break;
@@ -157,11 +183,11 @@ namespace VehicleControlSystem.ControlLayer
                         {
                             DriveControlEventArgs reply = new DriveControlEventArgs();
                             reply.ControlKind = DriveControlEventArgs.eControlKind.SteeringState;
-                            if (this.steering.IsLeft())
-                                reply.Result = FluentResults.Results.Ok<DriveControlEventArgs.eMoveDir>(DriveControlEventArgs.eMoveDir.LEFT);
+                            if ( this.steering.IsLeft() )
+                                reply.Result = FluentResults.Results.Ok<DriveControlEventArgs.eMoveDir>( DriveControlEventArgs.eMoveDir.LEFT );
                             else
-                                reply.Result = FluentResults.Results.Ok<DriveControlEventArgs.eMoveDir>(DriveControlEventArgs.eMoveDir.RIGHT);
-                            this.DriveControlEventPublish(reply);
+                                reply.Result = FluentResults.Results.Ok<DriveControlEventArgs.eMoveDir>( DriveControlEventArgs.eMoveDir.RIGHT );
+                            this.DriveControlEventPublish( reply );
                         }
                         break;
                     default:
@@ -170,21 +196,34 @@ namespace VehicleControlSystem.ControlLayer
             }
         }
 
-        private void DriveControlEventPublish(DriveControlEventArgs args)
+        private void DriveControlEventPublish( DriveControlEventArgs args )
         {
             args.EventDir = DriveControlEventArgs.eEventDir.ToFront;
-            this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Publish(args);
+            this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Publish( args );
         }
 
         public void Init()
         {
             this.CreateClamp();
-            this.CreateConveyor();
             this.CreateSteering();
 
             ThreadStart();
         }
 
+        public int InitializationVehicle()
+        {
+            int result = 0;
+            if ( this.IsDetectedCenter() ) //자제가 있으면 Lock
+                result = this.clamp.Lock_Sync();
+            else
+                result = this.clamp.Unlock_Sync();
+
+            if ( this.motion.IsErrorOn )
+                return 22;
+
+            return result;
+        }
+
         public void Dispose()
         {
             this.cancel.Cancel();
@@ -194,34 +233,34 @@ namespace VehicleControlSystem.ControlLayer
         #region Thread
         void ThreadStart()
         {
-            this.cancel.AddGo(new Action(this._ThSubCmdWorker));
-            this.cancel.AddGo(new Action(this._ThObstacleChecker));
+            this.cancel.AddGo( new Action( this._ThSubCmdWorker ) );
+            this.cancel.AddGo( new Action( this._ThObstacleChecker ) );
         }
 
         //장애물 감지 Thread
         //장애물 감지 패턴 변경도 여기 하자.
         private void _ThObstacleChecker()
         {
-            while (!this.cancel.Canceled)
+            while ( !this.cancel.Canceled )
             {
                 try
                 {
-                    if (this.autoManager.OperationModeProperty == eOperatationMode.AutoMode)
+                    if ( this.autoManager.OperationModeProperty == eOperatationMode.AutoMode )
                         this.CheckObstacle();
                 }
-                catch (ThreadInterruptedException threadInterruptedException)
+                catch ( ThreadInterruptedException threadInterruptedException )
                 {
                 }
-                catch (Exception exception)
+                catch ( Exception exception )
                 {
-                    logger.E(exception);
+                    logger.E( exception );
                 }
                 finally
                 {
-                    LockUtils.Wait(5);
+                    LockUtils.Wait( 5 );
                 }
             }
-            logger.D("Vehicle - _ThObstacleChecker Dispose");
+            logger.D( "Vehicle - _ThObstacleChecker Dispose" );
         }
 
         /// <summary>
@@ -229,103 +268,109 @@ namespace VehicleControlSystem.ControlLayer
         /// </summary>
         public void _ThSubCmdWorker()
         {
-            while (!this.cancel.Canceled)
+            while ( !this.cancel.Canceled )
             {
                 try
                 {
-                    if (this.ObstacleStateProperty != eObstacleState.Normal) //장애물 감지 상태 시 조그 동작만 가능하게.
+                    if ( this.ObstacleStateProperty != eObstacleState.Normal ) //장애물 감지 상태 시 조그 동작만 가능하게.
                         continue;
 
-                    if (this.autoManager.AutoModeStateProperty != eAutoModeState.Run) // 
+                    if ( this.autoManager.AutoModeStateProperty != eAutoModeState.Run ) // 
                         continue;
 
                     var subCmd = sql.SubCmdDAL.GetSubCmd();
-                    if (subCmd == null) continue;
+                    if ( subCmd == null ) continue;
 
-                    if (!sql.CommandDAL.All.Any(x => x.CommandID.Equals(subCmd.CmdID)))
+                    if ( !sql.CommandDAL.All.Any( x => x.CommandID.Equals( subCmd.CmdID ) ) )
                     {
-                        if (subCmd.CmdType == SubCmd.eCmdType.Auto) //자동 명령중 Main Command 가 없으면 삭제.
+                        if ( subCmd.CmdType == SubCmd.eCmdType.Auto ) //자동 명령중 Main Command 가 없으면 삭제.
                         {
-                            sql.SubCmdDAL.Delete(subCmd);
-                            logger.I($"SubCmd Deleted - ID={subCmd.ID}, CommandID={subCmd.CmdID}");
+                            sql.SubCmdDAL.Delete( subCmd );
+                            logger.I( $"SubCmd Deleted - ID={subCmd.ID}, CommandID={subCmd.CmdID}" );
                         }
                     }
 
-                    switch (subCmd.Type)
+                    switch ( subCmd.Type )
                     {
                         case SubCmd.eType.Move:
                             this.CurrentSubCommand = subCmd;
-                            this.Move(subCmd);
+                            this.Move( subCmd );
                             break;
 
                         case SubCmd.eType.Load:
                             this.CurrentSubCommand = subCmd;
-                            this.LoadCarrier(subCmd);
+                            this.LoadCarrier( subCmd );
                             break;
 
                         case SubCmd.eType.Unload:
                             this.CurrentSubCommand = subCmd;
-                            this.UnloadCarrier(subCmd);
+                            this.UnloadCarrier( subCmd );
                             break;
 
                         case SubCmd.eType.Charge:
                             this.CurrentSubCommand = subCmd;
-                            this.BatteryCharge(subCmd);
+                            this.BatteryCharge( subCmd );
                             break;
                         default:
                             break;
                     }
                 }
-                catch (ThreadInterruptedException threadInterruptedException)
+                catch ( ThreadInterruptedException threadInterruptedException )
                 {
                 }
-                catch (Exception exception)
+                catch ( Exception exception )
                 {
-                    logger.E(exception);
+                    logger.E( exception );
                 }
                 finally
                 {
-                    LockUtils.Wait(500);
+                    LockUtils.Wait( 500 );
                 }
             }
-            logger.D("Vehicle - _ThSubCmdWorker Dispose");
+            logger.D( "Vehicle - _ThSubCmdWorker Dispose" );
         }
         #endregion
 
         #region Control Action Method
 
-        void Move(SubCmd sub)
+        void Move( SubCmd sub )
         {
-            if (this.MoveTo(sub.TargetID))
+            if ( this.MoveTo( sub.TargetID ) )
             {
-                sql.SubCmdDAL.Delete(sub);
+                sql.SubCmdDAL.Delete( sub );
             }
             else
             {
+                if ( this.ObstacleStateProperty == eObstacleState.Blocked )
+                {
+                }
             }
         }
 
-        bool MoveTo(string pointID)
+        bool MoveTo( string pointID )
         {
-            ////ToDo: 부저를 울리는 시간을 설정에 넣자.
             //this.BuzzerOnOff(true, eBuzzerKind.StartWarn);
             ////TimerUtils.Once(3000, BuzzerOnOff, false, eBuzzerKind.StartWarn );
             //Thread.Sleep(3000);
             //this.BuzzerOnOff(false);
+
             this.OnMoveReady?.Invoke();
-            Thread.Sleep(3000);
+
+            var moveReadyBuzzerTime = sql.ConfigDal.GetValueToInt( ConstString.BuzzerStartReadyTime );
+            Thread.Sleep( moveReadyBuzzerTime );
+
             this.OnMoving?.Invoke();
             this.IsMoving = true;
 
             //this.BuzzerOnOff(true, eBuzzerKind.Moving);
-            this.motion.MoveToPoint(pointID, 100);
+            this.motion.MoveToPoint( pointID, 100 );
 
-            Wait4MoveDone();
+            bool result = Wait4MoveDone();
             this.IsMoving = false;
             //this.BuzzerOnOff(false);
             this.OnMoveFinish?.Invoke();
 
-            return true;
+            return result;
         }
 
         bool Wait4MoveDone()
@@ -334,84 +379,90 @@ namespace VehicleControlSystem.ControlLayer
             long st = SwUtils.CurrentTimeMillis;
 
             //Todo: 이동시 확인 사항들.
-            while (true)
+            while ( true )
             {
-                Thread.Sleep(5);
+                Thread.Sleep( 5 );
 
-                if (SwUtils.Gt(st, waitTime))
+                if ( SwUtils.Gt( st, waitTime ) )
                 {
                     //Todo: 이동시간 초과 시 동작들.
                     break;
                 }
 
-                if (this.ObstacleStateProperty == eObstacleState.Blocked)
+                if ( this.ObstacleStateProperty == eObstacleState.Blocked )
                     return false;
             }
             return true;
         }
 
-        public bool LoadCarrier(SubCmd sub)
+        public bool LoadCarrier( SubCmd sub )
         {
-            var route = sql.RouteDal.GetRoute(sub.TargetID);
+            var route = sql.RouteDal.GetRoute( sub.TargetID );
 
-            if (!CorrectPosition(route, this.CurrentPosition))
+            if ( !CorrectPosition( route, this.CurrentPosition ) )
             {
-                this.autoManager.ProcessAlarm(20);
+                this.autoManager.ProcessAlarm( 20 );
                 return false; //Alarm
             }
 
             int result = this.clamp.Unlock_Sync();
-            if (result != 0)
+            if ( result != 0 )
             {
-                this.autoManager.ProcessAlarm(result);
+                this.autoManager.ProcessAlarm( result );
                 return false;
             }
 
-            result = this.conveyor.PIOAndLoad(sub.TargetID);
-            if (result != 0)
+            result = this.PIOAndLoad( sub.TargetID );
+            if ( result != 0 )
             {
-                this.autoManager.ProcessAlarm(result);
+                this.autoManager.ProcessAlarm( result );
                 return false;
             }
 
             result = this.clamp.Lock_Sync();
-            if (result != 0)
+            if ( result != 0 )
             {
-                this.autoManager.ProcessAlarm(result);
+                this.autoManager.ProcessAlarm( result );
                 return false;
             }
 
+            sql.CommandDAL.UpdateState( sub.CmdID, eCommandState.Complete );
+            sql.SubCmdDAL.Delete( sub );
+
             return true;
         }
 
-        public bool UnloadCarrier(SubCmd sub)
+        public bool UnloadCarrier( SubCmd sub )
         {
-            var route = sql.RouteDal.GetRoute(sub.TargetID);
+            var route = sql.RouteDal.GetRoute( sub.TargetID );
 
-            if (!CorrectPosition(route, this.CurrentPosition))
+            if ( !CorrectPosition( route, this.CurrentPosition ) )
             {
-                this.autoManager.ProcessAlarm(21);
+                this.autoManager.ProcessAlarm( 21 );
                 return false; //Alarm
             }
 
             int result = this.clamp.Unlock_Sync();
-            if (result != 0)
+            if ( result != 0 )
             {
-                this.autoManager.ProcessAlarm(result);
+                this.autoManager.ProcessAlarm( result );
                 return false;
             }
 
-            result = this.conveyor.PIOAndUnload(sub.TargetID);
-            if (result != 0)
+            result = this.PIOAndUnload( sub.TargetID );
+            if ( result != 0 )
             {
-                this.autoManager.ProcessAlarm(result);
+                this.autoManager.ProcessAlarm( result );
                 return false;
             }
 
+            sql.CommandDAL.UpdateState( sub.CmdID, eCommandState.Complete );
+            sql.SubCmdDAL.Delete( sub );
+
             return true;
         }
 
-        public bool BatteryCharge(SubCmd sub)
+        public bool BatteryCharge( SubCmd sub )
         {
 
             return true;
@@ -422,21 +473,21 @@ namespace VehicleControlSystem.ControlLayer
         #region Check Method
         bool CheckObstacle()
         {
-            if (this.iO.IsOn("IN_OBSTRUCTION_DETECT_SAFETY") || this.iO.IsOn("IN_OBSTRUCTION_DETECT_ERROR"))
+            if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_SAFETY" ) || this.iO.IsOn( "IN_OBSTRUCTION_DETECT_ERROR" ) )
             {
                 this.motion.Stop();
                 this.ObstacleStateProperty = eObstacleState.Abnormal;
                 return true;
             }
 
-            if (this.iO.IsOn("IN_OBSTRUCTION_DETECT_STOP"))
+            if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_STOP" ) )
             {
                 this.motion.Stop();
                 this.ObstacleStateProperty = eObstacleState.Blocked;
                 return true;
             }
 
-            if (this.iO.IsOn("IN_OBSTRUCTION_DETECT_SLOW"))
+            if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_SLOW" ) )
             {
                 this.motion.SlowStop();
                 this.ObstacleStateProperty = eObstacleState.Decelerate;
@@ -451,25 +502,353 @@ namespace VehicleControlSystem.ControlLayer
         #endregion
 
         #region Machanical Method
+
+        #region Conveyor
+        int OnOffConveyor( bool isOn, bool isCW = false )
+        {
+            if ( IsInverterError() )
+                return 16;
+
+            if ( isCW )
+                this.iO.OutputOn( "OUT_CV_CWCCW" );
+            else
+                this.iO.OutputOff( "OUT_CV_CWCCW" );
+
+            if ( isOn )
+                this.iO.OutputOn( "OUT_CV_RUN" );
+            else
+                this.iO.OutputOff( "OUT_CV_RUN" );
+
+            return 0;
+        }
+
+        void SetConveyorSpeed( bool IsHight )
+        {
+            if ( IsHight )
+                this.iO.WriteOutputIO( "OUT_CV_DA", true );
+            else
+                this.iO.WriteOutputIO( "OUT_CV_DA", false );
+        }
+
+        /// <summary>
+        /// 입구 감지 로딩시 감속 사용
+        /// </summary>
+        /// <returns></returns>
+        bool IsDetectedLoadStart() => this.iO.IsOn( "IN_CV_DETECT_00" );
+
+        /// <summary>
+        /// 실물 감지
+        /// </summary>
+        /// <returns></returns>
+        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" );
+        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" );
+
+        int Load_Carrier()
+        {
+            if ( IsDetectedCenter() )
+                return 9;
+
+            OnOffConveyor( true, true );
+
+            long sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) ) //Wait 20Sec
+                {
+                    OnOffConveyor( false, true );
+                    return 10;
+                }
+
+                if ( IsDetectedLoadStart() )
+                    break;
+            }
+
+            return 0;
+        }
+
+        int UnloadCarrier()
+        {
+            if ( !IsDetectedLoadStart() )
+                return 11;
+
+            OnOffConveyor( true, true );
+
+            long sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) ) //Wait 20Sec
+                {
+                    OnOffConveyor( false, true );
+                    return 12;
+                }
+
+                if ( !IsDetectedLoadStart() )
+                    break;
+            }
+
+            return 0;
+        }
+
+        public int PIOAndLoad( string targetName )
+        {
+#if SIMULATION
+            PIOClear();
+            loggerPIO.I($"Start Load PIO - [{targetName}]");
+            this.OnPIOStart?.Invoke(true);
+            
+            this.iO.WriteOutputIO("OUT_PIO_RECEIVE_RUN", true);
+            loggerPIO.I("[Vehicle] - 4 Receive Run On");
+
+            Thread.Sleep(1000);//상대 IO 기다린다 생각.
+            loggerPIO.E("[Port] - 4 Ready On");
+
+            //Conveyor Start
+            loggerPIO.I("[Vehicle] - Conveyor Run");
+            this.OnConveyorStart?.Invoke(true);
+
+            Thread.Sleep(10000);//Conveyor 구동
+            this.OnCarrierDetected?.Invoke(true);
+
+            PIOClear();
+            Thread.Sleep(1000);
+            this.OnConveyorStop?.Invoke(true);
+#else
+            var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
+
+            if ( this.IsInverterError() )
+                return 16;
+
+            if ( this.IsLifterPositinCheck() )
+                return 14;
+
+            if ( !this.IsLifterDuplication() )
+            {
+                this.OnFailReport?.Invoke( eFailCode.Load_PortHasNotCarrier );
+                return 0;
+            }
+
+            if ( this.IsDetectedCenter() )
+            {
+                this.OnFailReport?.Invoke( eFailCode.Load_VehicleHasCarrier );
+                return 0;
+            }
+
+            PIOClear();
+            loggerPIO.I( $"Start Load PIO - [{targetName}]" );
+            this.OnPIOStart?.Invoke( true );
+
+            this.iO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true );
+            loggerPIO.I( "[Vehicle] - 4 Receive Run On" );
+
+            if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SENDABLE" ) )
+            {
+                PIOClear();
+                loggerPIO.E( "[Port] - 4 Ready Time Out" );
+                this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
+                return 0;
+            }
+            loggerPIO.E( "[Port] - 4 Ready On" );
+
+            this.SetConveyorSpeed( true );
+            this.OnOffConveyor( true, true );
+            this.iO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true );
+            loggerPIO.I( "[Vehicle] - Conveyor Run" );
+            this.OnConveyorStart?.Invoke( true );
+
+            if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SEND_RUN" ) )
+            {
+                this.OnOffConveyor( false, true );
+                PIOClear();
+                loggerPIO.E( "[Port] - 5 Sending Run Time Out" );
+                this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
+                return 0;
+            }
+
+            bool isStartDetected = false;
+            var sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) )
+                {
+                    PIOClear();
+                    this.OnOffConveyor( false, true );
+                    loggerPIO.E( "[Vehicle] Conveyor Wait Time Out" );
+                    this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
+
+                    if ( this.IsDetectedLoadStart() ) // 감지가 시작 되었으면 이동중 Error 로 판단 설비를 정지 상태로
+                        return 10; //Conveyor Moving Timeout
+                    else
+                        return 0;
+                }
+
+                if ( this.IsDetectedLoadStart() && !isStartDetected )
+                    isStartDetected = true;
+
+                if ( !this.IsDetectedLoadStart() && isStartDetected )
+                    this.SetConveyorSpeed( false );
+
+                if ( this.IsDetectedLoadStop() ) break;
+
+                if ( this.IsPIOInterLockOn() )
+                {
+                    PIOClear();
+                    this.OnOffConveyor( false ); //Stop
+                    loggerPIO.E( "[Port] PIO InterLock On " );
+                    return 19; //
+                }
+            }
+
+            if ( this.IsDetectedCenter() )
+                this.OnCarrierDetected?.Invoke( true );
+
+            this.OnOffConveyor( false ); //Stop
+            PIOClear();
+            this.OnConveyorStop?.Invoke( true );
+
+            this.iO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", true );
+            this.iO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false, 1000 );
+
+            this.OnLoadComplete?.Invoke();
+#endif
+
+            return 0;
+        }
+
+        public int PIOAndUnload( string targetName )
+        {
+#if SIMULATION
+            PIOClear();
+            loggerPIO.I($"Start Unload PIO - [{targetName}]");
+            this.OnPIOStart?.Invoke(false);
+
+            Thread.Sleep(1000);
+
+            this.iO.WriteOutputIO("OUT_PIO_READY", true);
+            loggerPIO.I("[Vehicle] - 1 Ready On");
+
+            Thread.Sleep(1000);
+            this.OnConveyorStart?.Invoke(false);
+
+            Thread.Sleep(10000);
+            this.OnOffConveyor(false); //Stop
+            this.OnConveyorStop?.Invoke(false);
+            PIOClear();
+
+            this.OnUnloadComplete?.Invoke();
+#else
+            var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
+
+            if ( this.IsInverterError() )
+                return 16;
+
+            if ( this.IsLifterDuplication() )
+            {
+                this.OnFailReport?.Invoke( eFailCode.Unload_PortHasCarrier );
+                return 0;
+            }
+
+            if ( !this.IsDetectedCenter() )
+            {
+                this.OnFailReport?.Invoke( eFailCode.Unload_VehicleHasNotCarrier );
+                return 0;
+            }
+
+            if ( this.IsLifterPositinCheck() )
+                return 13;
+
+            PIOClear();
+            loggerPIO.I( $"Start Unload PIO - [{targetName}]" );
+            this.OnPIOStart?.Invoke( false );
+
+            if ( !this.iO.IsOn( "IN_PIO_READY" ) )
+            {
+                loggerPIO.E( "[Port] - 1 Ready not On" );
+                this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
+                return 0;
+            }
+
+            this.iO.WriteOutputIO( "OUT_PIO_READY", true );
+            loggerPIO.I( "[Vehicle] - 1 Ready On" );
+
+            if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_RECEIVE_RUN" ) )
+            {
+                PIOClear();
+                loggerPIO.E( "[Port] - 2 Receive CV Run Timeout" );
+                this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
+                return 0;
+            }
+
+            this.iO.WriteOutputIO( "OUT_PIO_SENDING_RUN", true );
+            loggerPIO.I( "[Vehicle] - 2 Send Run On" );
+
+            this.SetConveyorSpeed( true );
+            this.OnOffConveyor( true );
+            this.OnConveyorStart?.Invoke( false );
+
+            var sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) )
+                {
+                    PIOClear();
+                    this.OnOffConveyor( false, true );
+                    loggerPIO.E( "[Port] Conveyor Wait Time Out" );
+                    this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
+
+                    if ( IsDetectedLoadStart() || IsDetectedCenter() ) //중간에 걸려 있다고 생각해서 알람 처리.
+                        return 12; //Conveyor Moving Timeout
+                    else
+                        return 0;
+                }
+
+                if ( this.iO.IsOn( "IN_PIO_RECEIVE_COMPLITE" ) )
+                    break;
+            }
+
+            if ( !IsDetectedCenter() )
+                this.OnCarrierDetected?.Invoke( false );
+
+            this.OnOffConveyor( false ); //Stop
+            this.OnConveyorStop?.Invoke( false );
+            PIOClear();
+
+            this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", true );
+            this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", false, 1000 );
+
+            this.OnUnloadComplete?.Invoke();
+#endif
+
+            return 0;
+        }
+
+        void PIOClear()
+        {
+            string[] pio = { "OUT_PIO_READY", "OUT_PIO_SENDING_RUN", "OUT_PIO_SEND_COMPLITE", "OUT_PIO_RECEIVABLE", "OUT_PIO_RECEIVE_RUN", "OUT_PIO_RECIVE_COMPLITE", "OUT_PIO_INTERLOCK" };
+            pio.FwEach( x => { this.iO.OutputOff( x ); } );
+        }
+
+        #endregion
+
         #endregion
 
         #region Hardware Create Method
         void CreateSteering()
         {
-            this.steering = new Steering(this.iO, this.sql, this.eventAggregator);
+            this.steering = new Steering( this.iO, this.sql, this.eventAggregator );
             this.steering.OnSteeringError += Steering_OnSteeringError;
         }
 
         void CreateClamp()
         {
-            this.clamp = new Clamp(this.sql, this.eventAggregator);
+            this.clamp = new Clamp( this.sql, this.eventAggregator );
             this.clamp.Init();
         }
 
-        void CreateConveyor()
-        {
-            this.conveyor = new Conveyor(this.iO);
-        }
         #endregion
 
         #region Help Method
@@ -480,12 +859,12 @@ namespace VehicleControlSystem.ControlLayer
         /// <param name="route"></param>
         /// <param name="currentPosition"></param>
         /// <returns></returns>
-        bool CorrectPosition(Route route, double currentPosition)
+        bool CorrectPosition( Route route, double currentPosition )
         {
             var rScale = route.ScaleValue;
             var rTolerance = route.ScaleTolerance;
             var result = currentPosition - rScale;
-            if (rTolerance < Math.Abs(result))
+            if ( rTolerance < Math.Abs( result ) )
                 return false;
 
             return true;
@@ -497,19 +876,19 @@ namespace VehicleControlSystem.ControlLayer
         /// </summary>
         /// <param name="no"> 0 == Off Laser</param>
         /// <returns></returns>
-        bool ChgObstacleDetectPattern(int no)
+        bool ChgObstacleDetectPattern( int no )
         {
-            var bitArray = BitUtils.ChgBitArray(no);
+            var bitArray = BitUtils.ChgBitArray( no );
 
             int bitIndex = 0;
-            this.obstacleBitList.ForEach(b =>
-            {
-                if (bitArray[bitIndex])
-                    this.iO.OutputOff(b);
-                else
-                    this.iO.OutputOn(b);
-                bitIndex++;
-            });
+            this.obstacleBitList.ForEach( b =>
+             {
+                 if ( bitArray[bitIndex] )
+                     this.iO.OutputOff( b );
+                 else
+                     this.iO.OutputOn( b );
+                 bitIndex++;
+             } );
 
             return true;
         }
@@ -518,29 +897,29 @@ namespace VehicleControlSystem.ControlLayer
         {
             int bitIndex = 0;
 
-            BitArray bitArray = new BitArray(this.obstacleBitList.Count);
+            BitArray bitArray = new BitArray( this.obstacleBitList.Count );
 
-            this.obstacleBitList.ForEach(b =>
-            {
-                if (this.iO.IsOn(b))
-                    bitArray.Set(bitIndex, false);
-                else
-                    bitArray.Set(bitIndex, true);
-                bitIndex++;
-            });
+            this.obstacleBitList.ForEach( b =>
+             {
+                 if ( this.iO.IsOn( b ) )
+                     bitArray.Set( bitIndex, false );
+                 else
+                     bitArray.Set( bitIndex, true );
+                 bitIndex++;
+             } );
 
-            return BitUtils.ChgInt32(bitArray);
+            return BitUtils.ChgInt32( bitArray );
         }
 
         #endregion
 
-        #region Event
-        private void Steering_OnSteeringError(object sender, int e)
+        #region Event Subscribe 
+        private void Steering_OnSteeringError( object sender, int e )
         {
-            if (e != 0)
+            if ( e != 0 )
             {
-                logger.E($"[Steering] - Control Error {e}");
-                this.autoManager.ProcessAlarm(e);
+                logger.E( $"[Steering] - Control Error {e}" );
+                this.autoManager.ProcessAlarm( e );
             }
             else
             {
@@ -548,10 +927,10 @@ namespace VehicleControlSystem.ControlLayer
                 {
                     EventDir = DriveControlEventArgs.eEventDir.ToFront,
                     ControlKind = DriveControlEventArgs.eControlKind.Steering,
-                    Result = FluentResults.Results.Ok<DriveControlEventArgs.eMoveDir>(DriveControlEventArgs.eMoveDir.LEFT),
+                    Result = FluentResults.Results.Ok<DriveControlEventArgs.eMoveDir>( DriveControlEventArgs.eMoveDir.LEFT ),
                 };
 
-                this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Publish(msg);
+                this.eventAggregator.GetEvent<DirveControlPubSubEvent>().Publish( msg );
             }
 
         }

+ 3 - 0
Dev/OHV/VehicleControlSystem/Managers/AutoManager.cs

@@ -234,6 +234,9 @@ namespace VehicleControlSystem.Managers
             this.AutoModeStateProperty = eAutoModeState.ErrorStop;
             this.LampStateProperty = eLampState.Alarm;
 
+            this.sql.CommandDAL.Clean();
+            this.sql.SubCmdDAL.Clean();
+
             HisAlarm hisAlarm = new HisAlarm();
             var alarm = sql.AlarmDAL.GetK(alarmID);
             if (alarm == null)

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

@@ -10,6 +10,9 @@ using OHV.SqliteDAL;
 using OHVConnector;
 using Prism.Events;
 using VehicleControlSystem.ControlLayer;
+using GSG.NET.Extensions;
+using OHV.Common.Model;
+using GSG.NET.Quartz;
 
 namespace VehicleControlSystem.Managers
 {
@@ -34,7 +37,7 @@ namespace VehicleControlSystem.Managers
 
         public void Init()
         {
-            this.manager.Config = new Config
+            this.manager.Config = new OHVConnector.Config
             {
                 ID = sql.ConfigDal.GetK(ConstString.VehicleID).Value,
                 IpAddress = sql.ConfigDal.GetK(ConstString.Addr).Value,
@@ -71,6 +74,18 @@ namespace VehicleControlSystem.Managers
             vehicle.OnLoadComplete += Vehicle_OnLoadComplete;
             vehicle.OnUnloadComplete += Vehicle_OnUnloadComplete;
             vehicle.OnCarrierDetected += Vehicle_OnCarrierDetected;
+
+            vehicle.OnFailReport += Vehicle_OnFailReport;
+        }
+
+        private void Vehicle_OnFailReport( Vehicle.eFailCode obj )
+        {
+            var msg = new OCSMessage();
+            msg.Kind = eKind.F;
+            msg.Tag = this.vehicle.CurrentPosition.ToString();
+            msg.SubCode = CastTo<int>.From( obj ).ToString( "000" );
+
+            this.manager.Send( msg );
         }
 
         private void Vehicle_OnChargingFull()
@@ -270,8 +285,10 @@ namespace VehicleControlSystem.Managers
                 case OHVConnector.eKind.F:
                     break;
                 case OHVConnector.eKind.M:
+                    ReceiveMCommand( msg );
                     break;
                 case OHVConnector.eKind.R:
+                    ReceiveRCommand( msg );
                     break;
                 case OHVConnector.eKind.H:
                     break;
@@ -283,6 +300,59 @@ namespace VehicleControlSystem.Managers
 
         }
 
+        void Reply(OCSMessage recieve)
+        {
+            var reply = new OCSMessage();
+            reply.Kind = recieve.Kind;
+            reply.Tag = recieve.Tag;
+            reply.SubCode = recieve.SubCode;
+            this.manager.Reply( reply );
+        }
+
+        private void ReceiveRCommand( OCSMessage msg )
+        {
+            this.Reply(msg);
+
+            if ( msg.SubCode.Equals("100") )
+            {
+                Send_Scmd( (int)this.vehicle.CurrentPosition );
+            }
+            if ( msg.SubCode.Equals( "010" ) )
+            {
+                Send_Bcmd(this.vehicle.BatteryVolt);
+            }
+        }
+
+        private void ReceiveMCommand( OCSMessage msg )
+        {
+            this.Reply( msg );
+
+            var cmd = new Command();
+            cmd.TargetID = msg.Tag;
+
+            switch ( msg.SubCode )
+            {
+                case "000": //Move
+                    cmd.Type = eCommandType.Move;
+                    break;
+                case "001": //Move and Load
+                    cmd.Type = eCommandType.MoveNLoad;
+                    break;
+                case "002": //Move and Unload
+                    cmd.Type = eCommandType.MoveNUnload;
+                    break;
+                case "003": //Move and Charge
+                    cmd.Type = eCommandType.Charging;
+                    break;
+                default:
+                    return;
+            }
+            //Todo: 등록 되어 있는 경로 가 있는 지 확인 필요.
+
+            this.sql.CommandDAL.Add( cmd );
+
+        }
+
         private void Manager_OnT3Timeout(OHVConnector.OCSMessage msg)
         {
             logger.E("[TimeOut] : " + msg.LogFormat());
@@ -297,16 +367,27 @@ namespace VehicleControlSystem.Managers
         {
             var msg = new HostConnectedEventArgs(HostConnectedEventArgs.eConnectedState.Disconnected);
             this.eventAggregator.GetEvent<HostConnectedPubSubEvent>().Publish(msg);
+
+            QuartzUtils.StopSchedule( "BatteryReport" );
         }
 
         private void Manager_OnContd(string id)
         {
             var msg = new HostConnectedEventArgs(HostConnectedEventArgs.eConnectedState.Connected);
             this.eventAggregator.GetEvent<HostConnectedPubSubEvent>().Publish(msg);
+
+            QuartzUtils.Invoke( "BatteryReport", QuartzUtils.GetExpnMinute( 1 ), BatteryState_Report );
         }
 
         #endregion
 
+        #region Pooling Report
+        void BatteryState_Report()
+        {
+            Send_Bcmd( this.vehicle.BatteryVolt );
+        }
+        #endregion
+
         #region Send
         /// <summary>
         /// 현재 위치 보고 
@@ -339,7 +420,7 @@ namespace VehicleControlSystem.Managers
         public void Send_Ecmd()
         {
             var msg = new OCSMessage();
-            msg.Tag = vehicle.CurrentPosition.ToString();
+            msg.Tag = vehicle.CurrentPosition.ToString("0000");
             msg.IsSubCode1 = this.vehicle.IsContain;
             msg.IsSubCode2 = vehicle.IsMoving;
             msg.IsSubCode3 = vehicle.IsError;
@@ -351,7 +432,7 @@ namespace VehicleControlSystem.Managers
         {
             var msg = new OCSMessage();
             msg.Kind = eKind.T;
-            msg.Tag = point.ToString();
+            msg.Tag = point.ToString("0000");
             msg.IsSubCode1 = this.vehicle.IsContain;
             msg.IsSubCode2 = vehicle.IsMoving;
             msg.IsSubCode3 = vehicle.IsError;
@@ -360,11 +441,11 @@ namespace VehicleControlSystem.Managers
         }
 
 
-        public void Send_Ccmd()
+        public void Send_Ccmd(string crossPointID)
         {
             var msg = new OCSMessage();
             msg.Kind = eKind.C;
-            msg.Tag = vehicle.CurrentPosition.ToString();
+            msg.Tag = crossPointID;
             msg.IsSubCode1 = this.vehicle.IsContain;
             msg.IsSubCode2 = vehicle.IsMoving;
             msg.IsSubCode3 = vehicle.IsError;
@@ -384,6 +465,7 @@ namespace VehicleControlSystem.Managers
             };
             this.manager.Send(msg);
         }
+
         public void Send_ManualLoad()
         {
             var msg = new OCSMessage()

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

@@ -34,79 +34,79 @@ namespace VehicleControlSystem.Managers
         AutoManager autoManager;
         SqliteManager sql = null;
 
-        public Scheduler(IEventAggregator ea, AutoManager autoManager, SqliteManager sqlite)
+        public Scheduler( IEventAggregator ea, AutoManager autoManager, SqliteManager sqlite )
         {
             this.CommandsList = new List<Command>();
             eventAggregator = ea;// CommonServiceLocator.ServiceLocator.Current.GetInstance<IEventAggregator>();
-            eventAggregator.GetEvent<VCSMessagePubSubEvent>().Subscribe(OnReceivedMessageEvent);
+            eventAggregator.GetEvent<VCSMessagePubSubEvent>().Subscribe( OnReceivedMessageEvent );
 
             this.autoManager = autoManager;
             this.sql = sqlite;
         }
 
-        private void OnReceivedMessageEvent(VCSMessageEventArgs obj)
+        private void OnReceivedMessageEvent( VCSMessageEventArgs obj )
         {
-            this.AddCommand(obj.Command);
+            this.AddCommand( obj.Command );
 
             //var m = new GUIMessageEventArgs() { MessageText = obj.MessageText, MessageKey = obj.MessageKey };
             //m.Command = ObjectCopyUtils.DeepClone(obj.Command);
             //GUIMessagePublish(m);
         }
 
-        void GUIMessagePublish(GUIMessageEventArgs args)
+        void GUIMessagePublish( GUIMessageEventArgs args )
         {
-            eventAggregator.GetEvent<GUIMessagePubSubEvent>().Publish(args);
+            eventAggregator.GetEvent<GUIMessagePubSubEvent>().Publish( args );
         }
 
         public void Init()
         {
             this.isThreadAlive = true;
-            this.thread = ThreadUtils.Invoke(this.ExcuteCommand);
+            this.thread = ThreadUtils.Invoke( this.ExcuteCommand );
         }
 
-        public bool AddCommand(Command cmd)
+        public bool AddCommand( Command cmd )
         {
-            if (this.CommandsList == null) return false;
+            if ( this.CommandsList == null ) return false;
             try
             {
-	            this.CommandsList.Add(cmd);
+                this.CommandsList.Add( cmd );
             }
-            catch (Exception ex)
+            catch ( Exception ex )
             {
-                logger.E(ex);
+                logger.E( ex );
                 return false;
             }
 
             return true;
         }
 
-        bool RemoveCommand(Command cmd)
+        bool RemoveCommand( Command cmd )
         {
-            if (!this.CommandsList.Remove(cmd))
+            if ( !this.CommandsList.Remove( cmd ) )
             {
-                logger.D($"Scheduler - [Command] : RemoveCommand fail ID-{cmd.CommandID} / Result-{cmd.Result} ");
+                logger.D( $"Scheduler - [Command] : RemoveCommand fail ID-{cmd.CommandID} / Result-{cmd.Result} " );
                 return false;
             }
 
-            logger.D($"Scheduler - [Command] : RemoveCommand OK ID-{cmd.CommandID} / Result-{cmd.Result} ");
+            logger.D( $"Scheduler - [Command] : RemoveCommand OK ID-{cmd.CommandID} / Result-{cmd.Result} " );
             return true;
         }
 
         void ExcuteCommand()
         {
-            while (isThreadAlive)
+            while ( isThreadAlive )
             {
-                Thread.Sleep(500);
+                Thread.Sleep( 500 );
                 try
                 {
                     var state = this.autoManager.OperationModeProperty;
-                    switch (state)
+                    switch ( state )
                     {
                         case OHV.Common.Shareds.eOperatationMode.ManualMode:
                             break;
                         case OHV.Common.Shareds.eOperatationMode.AutoMode:
                             {
-                                switch (this.autoManager.AutoModeStateProperty)
+                                switch ( this.autoManager.AutoModeStateProperty )
                                 {
                                     case OHV.Common.Shareds.eAutoModeState.ErrorStop:
                                         break;
@@ -114,8 +114,8 @@ namespace VehicleControlSystem.Managers
                                         break;
                                     case OHV.Common.Shareds.eAutoModeState.Run:
                                         Command cmd = sql.CommandDAL.GetCmd();
-                                        if (cmd == null) continue;
-                                        DoWork(cmd);
+                                        if ( cmd == null ) continue;
+                                        DoWork( cmd );
                                         break;
                                     case OHV.Common.Shareds.eAutoModeState.Stop:
                                         break;
@@ -130,91 +130,91 @@ namespace VehicleControlSystem.Managers
                             break;
                     }
                 }
-                catch (Exception ex)
+                catch ( Exception ex )
                 {
-                    logger.E(ex);
+                    logger.E( ex );
                 }
             }
         }
 
-        private void DoWork(Command cmd)
+        private void DoWork( Command cmd )
         {
-            switch (cmd.State)
+            switch ( cmd.State )
             {
                 case OHV.Common.Shareds.eCommandState.Queued:
-                    if (sql.SubCmdDAL.Count <= 0) //
+                    if ( sql.SubCmdDAL.Count <= 0 ) //
                     {
-                        switch (cmd.Type)
+                        switch ( cmd.Type )
                         {
                             case OHV.Common.Shareds.eCommandType.Move:
                             case OHV.Common.Shareds.eCommandType.MoveNLoad:
                             case OHV.Common.Shareds.eCommandType.MoveNUnload:
-                                CreateSubCommand(cmd, SubCmd.eType.Move);
+                                CreateSubCommand( cmd, SubCmd.eType.Move );
                                 break;
                             case OHV.Common.Shareds.eCommandType.Charging:
                                 break;
                             default:
                                 break;
                         }
-                        this.sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Processing);
+                        this.sql.CommandDAL.UpdateState( cmd.CommandID, OHV.Common.Shareds.eCommandState.Processing );
                     }
                     break;
 
                 case OHV.Common.Shareds.eCommandState.Processing:
                     {
                         var subCmd = sql.SubCmdDAL.GetSubCmd();
-                        if (subCmd == null) // Move 명령을 수행 완료 했다고 판단.
+                        if ( subCmd == null ) // Move 명령을 수행 완료 했다고 판단.
                         {
-                            if ( cmd.IsSecondCommanded)
+                            if ( cmd.IsSecondCommanded )
                             {
-                                sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
+                                sql.CommandDAL.UpdateState( cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete );
                                 break;
                             }
 
-                            if (cmd.Type == OHV.Common.Shareds.eCommandType.MoveNLoad )
+                            if ( cmd.Type == OHV.Common.Shareds.eCommandType.MoveNLoad )
                             {
-                                if (this.CreateSubCommand(cmd, SubCmd.eType.Load))
+                                if ( this.CreateSubCommand( cmd, SubCmd.eType.Load ) )
                                     cmd.IsSecondCommanded = true;
                                 break;
                             }
-                            else if(cmd.Type == OHV.Common.Shareds.eCommandType.MoveNUnload)
+                            else if ( cmd.Type == OHV.Common.Shareds.eCommandType.MoveNUnload )
                             {
-                                if (this.CreateSubCommand(cmd, SubCmd.eType.Unload))
+                                if ( this.CreateSubCommand( cmd, SubCmd.eType.Unload ) )
                                     cmd.IsSecondCommanded = true;
                                 break;
                             }
-                            else if ( cmd.Type == OHV.Common.Shareds.eCommandType.Charging)
+                            else if ( cmd.Type == OHV.Common.Shareds.eCommandType.Charging )
                             {
-                                if ( this.CreateSubCommand(cmd, SubCmd.eType.Charge))
+                                if ( this.CreateSubCommand( cmd, SubCmd.eType.Charge ) )
                                     cmd.IsSecondCommanded = true;
                                 break;
                             }
                             else //Move Command complete
                             {
-                                sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
+                                sql.CommandDAL.UpdateState( cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete );
+                                break;
                             }
                         }
                         else
                         {
-                            if (subCmd.CmdID.Equals(cmd.CommandID)) //진행중 판단
+                            if ( subCmd.CmdID.Equals( cmd.CommandID ) ) //진행중 판단
                                 break;
                         }
                     }
-                    sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
                     break;
 
                 case OHV.Common.Shareds.eCommandState.Complete:
-                    sql.CommandDAL.Delete(cmd);
+                    sql.CommandDAL.Delete( cmd );
                     break;
                 default:
                     break;
             }
         }
 
-        private bool CreateSubCommand(Command cmd, SubCmd.eType type)
+        private bool CreateSubCommand( Command cmd, SubCmd.eType type )
         {
             //명령을 만들기 전에 Vehicle 의 상태를 확인하여 만들자.
-            switch (type)
+            switch ( type )
             {
                 case SubCmd.eType.Move:
                     break;
@@ -235,8 +235,8 @@ namespace VehicleControlSystem.Managers
                 TargetID = cmd.TargetID,
                 CmdID = cmd.CommandID,
             };
-            sql.SubCmdDAL.Add(sub);
-            logger.I($"{sub.ID} Sub Command Create - Type={sub.Type}, TargetID={sub.TargetID}, CommandID={sub.CmdID}");
+            sql.SubCmdDAL.Add( sub );
+            logger.I( $"{sub.ID} Sub Command Create - Type={sub.Type}, TargetID={sub.TargetID}, CommandID={sub.CmdID}" );
 
             return true;
         }
@@ -247,24 +247,24 @@ namespace VehicleControlSystem.Managers
             {
             };
 
-            sql.CommandDAL.Add(cmd);
-            logger.I($"{cmd.CommandID} Command Create - Type={cmd.Type}, TargetID={cmd.TargetID}");
+            sql.CommandDAL.Add( cmd );
+            logger.I( $"{cmd.CommandID} Command Create - Type={cmd.Type}, TargetID={cmd.TargetID}" );
             return true;
         }
 
         #region IDisposable Support
         private bool disposedValue = false; // 중복 호출을 검색하려면
 
-        protected virtual void Dispose(bool disposing)
+        protected virtual void Dispose( bool disposing )
         {
-            if (!disposedValue)
+            if ( !disposedValue )
             {
-                if (disposing)
+                if ( disposing )
                 {
                     // TODO: 관리되는 상태(관리되는 개체)를 삭제합니다.
                     this.isThreadAlive = false;
-                    if ( !this.thread.Join(3000) )
-                        ThreadUtils.Kill(this.thread);
+                    if ( !this.thread.Join( 3000 ) )
+                        ThreadUtils.Kill( this.thread );
                 }
 
                 // TODO: 관리되지 않는 리소스(관리되지 않는 개체)를 해제하고 아래의 종료자를 재정의합니다.
@@ -285,7 +285,7 @@ namespace VehicleControlSystem.Managers
         public void Dispose()
         {
             // 이 코드를 변경하지 마세요. 위의 Dispose(bool disposing)에 정리 코드를 입력하세요.
-            Dispose(true);
+            Dispose( true );
             // TODO: 위의 종료자가 재정의된 경우 다음 코드 줄의 주석 처리를 제거합니다.
             // GC.SuppressFinalize(this);
         }

+ 6 - 2
Dev/OHV/VehicleControlSystem/VCSystem.cs

@@ -44,7 +44,6 @@ namespace VehicleControlSystem
 
         public void Init()
         {
-            QuartzUtils.Init(5);
             QuartzUtils.Invoke("HIS_ALARM", QuartzUtils.GetExpnMinute(1), this.CleanHisAlarm);
 
             //Create IO
@@ -123,7 +122,12 @@ namespace VehicleControlSystem
             GUIMessageEventArgs msg;
             if (isAutoMode)
             {
-                //ToDo: 자동 모드로 들어가기전 확인 할 점들.
+                int result = vehicle.InitializationVehicle();
+                if (result != 0 )
+                {
+                    this.autoManager.ProcessAlarm( result ); //Alarm 내용을 UI로 전달 해주니까 Reply 가 필요 없다.
+                    return;
+                }
 
                 this.autoManager.OperationModeProperty = OHV.Common.Shareds.eOperatationMode.AutoMode;
                 this.autoManager.AutoModeStateProperty = OHV.Common.Shareds.eAutoModeState.StartRun;

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

@@ -18,7 +18,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
@@ -94,7 +94,6 @@
     <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" />