Bladeren bron

Prism Library 추가

SK.Kang 6 jaren geleden
bovenliggende
commit
e5166e5068
30 gewijzigde bestanden met toevoegingen van 912 en 51 verwijderingen
  1. 1 0
      .gitignore
  2. 21 0
      Dev/OHV/Assambly/GSG.NET.XML
  3. 0 13
      Dev/OHV/OHV.Common/Events/GUIMessageEventArgs.cs
  4. 23 0
      Dev/OHV/OHV.Common/Events/MessageEventArgs.cs
  5. 16 0
      Dev/OHV/OHV.Common/Events/PubSubEvent.cs
  6. 24 0
      Dev/OHV/OHV.Common/Model/Command.cs
  7. 21 0
      Dev/OHV/OHV.Common/Model/Config.cs
  8. 11 2
      Dev/OHV/OHV.Common/OHV.Common.csproj
  9. 50 0
      Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs
  10. 5 0
      Dev/OHV/OHV.Common/packages.config
  11. 37 0
      Dev/OHV/OHV.SqliteDAL/DAL/ConfigDAL.cs
  12. 1 0
      Dev/OHV/OHV.SqliteDAL/OHV.SqliteDAL.csproj
  13. 2 2
      Dev/OHV/OHV.UIControl/ControlBase/OHVControlBase.cs
  14. 5 5
      Dev/OHV/OHV.UIControl/LayoutParts/VehiclePart/Vehiclebase.cs
  15. 1 1
      Dev/OHV/OHV.Vehicle/App.config
  16. 5 4
      Dev/OHV/OHV.Vehicle/App.xaml
  17. 75 6
      Dev/OHV/OHV.Vehicle/App.xaml.cs
  18. 88 0
      Dev/OHV/OHV.Vehicle/Config/log4net.xml
  19. 7 2
      Dev/OHV/OHV.Vehicle/MainWindow.xaml
  20. 15 0
      Dev/OHV/OHV.Vehicle/MainWindow.xaml.cs
  21. 63 0
      Dev/OHV/OHV.Vehicle/MainWindowViewModel.cs
  22. 58 0
      Dev/OHV/OHV.Vehicle/OHV.Vehicle.csproj
  23. 9 0
      Dev/OHV/OHV.Vehicle/packages.config
  24. 99 0
      Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs
  25. 188 0
      Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs
  26. 0 15
      Dev/OHV/VehicleControlSystem/System.cs
  27. 48 0
      Dev/OHV/VehicleControlSystem/VCSystem.cs
  28. 32 1
      Dev/OHV/VehicleControlSystem/VehicleControlSystem.csproj
  29. 7 0
      Dev/OHV/VehicleControlSystem/packages.config
  30. BIN
      Documents/■ OHV Distribution Diagram.pptx

+ 1 - 0
.gitignore

@@ -109,3 +109,4 @@ Backup*/
 UpgradeLog*.XML
 
 Dev/OHV/.vs/
+Dev/OHV/.cr/

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

@@ -3851,6 +3851,27 @@
         <member name="M:GSG.NET.Utils.NumUtils.FloatV(System.String)">
             <summary/>
         </member>
+        <member name="T:GSG.NET.Utils.ObjectCopyUtils">
+            <summary>
+            Deep Copy 지원
+            </summary>
+        </member>
+        <member name="M:GSG.NET.Utils.ObjectCopyUtils.DeepClone``1(``0)">
+            <summary>
+             Deep Clone 구현
+            </summary>
+            <typeparam name="T"></typeparam>
+            <param name="obj"></param>
+            <returns></returns>
+        </member>
+        <member name="M:GSG.NET.Utils.ObjectCopyUtils.SerializableDeepClone``1(``0)">
+            <summary>
+            Serializable 객체에 대한  Deep Clone
+            </summary>
+            <typeparam name="T"></typeparam>
+            <param name="obj"></param>
+            <returns></returns>
+        </member>
         <member name="T:GSG.NET.Utils.ProcessUtils">
             <summary>
             AddStartUpProcess는 windows registry를 사용하며 실행 폴더는 system folder가 되므로

+ 0 - 13
Dev/OHV/OHV.Common/Events/GUIMessageEventArgs.cs

@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace OHV.Common.Events
-{
-    [Serializable]
-    public class GUIMessageEventArgs : EventArgs
-    {
-    }
-}

+ 23 - 0
Dev/OHV/OHV.Common/Events/MessageEventArgs.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Model;
+
+namespace OHV.Common.Events
+{
+    public class GUIMessageEventArgs : EventArgs
+    {
+        public int MessageKey { get; set; }
+        public string MessageText { get; set; }
+        public Command Command { get; set; }
+    }
+
+    public class VCSMessageEventArgs : EventArgs
+    {
+        public int MessageKey { get; set; }
+        public string MessageText { get; set; }
+        public Command Command { get; set; }
+    }
+}

+ 16 - 0
Dev/OHV/OHV.Common/Events/PubSubEvent.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Prism.Events;
+
+namespace OHV.Common.Events
+{
+    public class ApplicationExitEvent : PubSubEvent<string> { }
+    public class VCSMessagePubSubEvent : PubSubEvent<VCSMessageEventArgs>
+    {
+    }
+
+    public class GUIMessagePubSubEvent : PubSubEvent<GUIMessageEventArgs> { }
+}

+ 24 - 0
Dev/OHV/OHV.Common/Model/Command.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Shareds;
+
+namespace OHV.Common.Model
+{
+    public class Command
+    {
+        public string CommandID { get; set; }
+        public DateTime CreateTime { get; set; }
+        public eCommandType Type { get; set; }
+        public eCommandState State { get; set; }
+        public eCommandResult Result { set; get; }
+        public Command()
+        {
+            CreateTime = DateTime.Now;
+            State = eCommandState.init;
+            Result = eCommandResult.Completed;
+        }
+    }
+}

+ 21 - 0
Dev/OHV/OHV.Common/Model/Config.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OHV.Common.Model
+{
+    public class Config
+    {
+        public Config()
+        {
+        }
+
+        public string ID { get; set; }
+        public string Name { get; set; }
+        public string Value { get; set; }
+        public string Desc { get; set; }
+        public DateTime EditTime { get; set; }
+    }
+}

+ 11 - 2
Dev/OHV/OHV.Common/OHV.Common.csproj

@@ -31,8 +31,14 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Prism, Version=7.2.0.1422, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
+      <HintPath>..\packages\Prism.Core.7.2.0.1422\lib\net45\Prism.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
+    </Reference>
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
@@ -41,14 +47,17 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Events\GUIMessageEventArgs.cs" />
+    <Compile Include="Events\MessageEventArgs.cs" />
+    <Compile Include="Events\PubSubEvent.cs" />
     <Compile Include="Interfaces\IModelBase.cs" />
     <Compile Include="Interfaces\IVehicle.cs" />
+    <Compile Include="Model\Command.cs" />
+    <Compile Include="Model\Config.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Shareds\SharedEnumType.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Folder Include="Model\" />
+    <None Include="packages.config" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

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

@@ -22,4 +22,54 @@
 		Both = 2,
 	}
 	#endregion
+
+	#region Machine State
+	public enum eMachineState
+	{
+		None = -1,
+		Manual,
+		Auto,
+		Abnormal
+	}
+    #endregion
+
+    #region Vehicle Status
+	public enum eVehicleStatus
+	{
+		Idle,
+		Active,
+		Abnormal,
+	}
+    #endregion
+
+    #region Command
+    public enum eCommandType
+	{
+		Move,
+		Transfer,
+		Charging,
+	}
+
+	public enum eCommandState
+	{
+		init,
+		MoveToSource,
+		Arrived,
+		AcquireStart,
+		AcquireComplete,
+		MoveToDest,
+		Departed,
+		DepositStart,
+		DepositComplete,
+		Finished,
+	}
+
+	public enum eCommandResult
+	{
+		Completed = 0,
+		CancleByHost,
+		AbortByHost,
+		AbortByAbnormal,
+	}
+	#endregion
 }

+ 5 - 0
Dev/OHV/OHV.Common/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Prism.Core" version="7.2.0.1422" targetFramework="net45" />
+  <package id="System.ValueTuple" version="4.5.0" targetFramework="net45" />
+</packages>

+ 37 - 0
Dev/OHV/OHV.SqliteDAL/DAL/ConfigDAL.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Model.DataModel;
+
+namespace OHV.SqliteDAL.DAL
+{
+    public class ConfigDAL
+    {
+        public ConfigDAL()
+        {
+        }
+
+        public void Add(Config config)
+        {
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                db.Set<Config>().Add(config);
+                db.SaveChanges();
+            }
+        }
+
+        public Config GetConfig(string ID)
+        {
+            Config config = null;
+
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                config = db.Set<Config>().Where(x => x.ID.Equals(ID)).SingleOrDefault();
+            }
+
+            return config;
+        }
+    }
+}

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

@@ -55,6 +55,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="CustomHistory.cs" />
+    <Compile Include="DAL\ConfigDAL.cs" />
     <Compile Include="ModelConfiguration.cs" />
     <Compile Include="OHVDbContext.cs" />
     <Compile Include="OHVDbInitializer.cs" />

+ 2 - 2
Dev/OHV/OHV.UIControl/ControlBase/OHVControlBase.cs

@@ -15,7 +15,7 @@ using System.Windows.Media;
 namespace OHV.UIControl.ControlBase
 {
     public delegate void BeginTimeLoadedHandler( object sender );
-    public delegate void UICallbackCommunicationBackground( GUIMessageEventArgs e );
+    //public delegate void UICallbackCommunicationBackground(MessageEventArgs e);
 
     class OHVControlBase : Control, IModelBase
     {
@@ -161,7 +161,7 @@ namespace OHV.UIControl.ControlBase
 
         protected event BeginTimeLoadedHandler BeginTimeLoaded;
 
-        protected event UICallbackCommunicationBackground UICallbackCommunication_Background;
+        //protected event UICallbackCommunicationBackground UICallbackCommunication_Background;
 
         public OHVControlBase()
         {

+ 5 - 5
Dev/OHV/OHV.UIControl/LayoutParts/VehiclePart/Vehiclebase.cs

@@ -142,7 +142,7 @@ namespace OHV.UIControl.LayoutParts.VehicleParts
             {
                 this.BeginTimeLoaded += BeginTimeLoadedHandler;
                 this.DisplayElementVisibility = System.Windows.Visibility.Visible;
-                base.UICallbackCommunication_Background += this.UICallbackCommunication_BackgroundWork;
+                //base.UICallbackCommunication_Background += this.UICallbackCommunication_BackgroundWork;
 
                 this._DefaultCraneSpeed = 3;
             }
@@ -153,10 +153,10 @@ namespace OHV.UIControl.LayoutParts.VehicleParts
             //base.Stocker.CraneList.Add( this );
         }
 
-        void UICallbackCommunication_BackgroundWork( GUIMessageEventArgs e )
-        {
-            throw new NotImplementedException();
-        }
+        //void UICallbackCommunication_BackgroundWork( MessageEventArgs e )
+        //{
+        //    throw new NotImplementedException();
+        //}
 
     }
 }

+ 1 - 1
Dev/OHV/OHV.Vehicle/App.config

@@ -6,7 +6,7 @@
   </configSections>
 
   <connectionStrings>
-    <add name="OHVDb" connectionString="data source=.\db\OHVDb\OHVDb.sqlite;foreign keys=true" providerName="System.Data.SQLite"/>
+    <add name="OHVDb" connectionString="data source=.\DB\OHVDb.sqlite;foreign keys=true" providerName="System.Data.SQLite"/>
   </connectionStrings>
 
   <startup>

+ 5 - 4
Dev/OHV/OHV.Vehicle/App.xaml

@@ -1,9 +1,10 @@
-<Application x:Class="OHV.Vehicle.App"
+<prism:PrismApplication x:Class="OHV.Vehicle.App"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:OHV.Vehicle"
-             StartupUri="MainWindow.xaml">
+                          xmlns:prism="http://prismlibrary.com/"
+             Startup="Application_Startup" Exit="Application_Exit">
     <Application.Resources>
-         
+
     </Application.Resources>
-</Application>
+</prism:PrismApplication>

+ 75 - 6
Dev/OHV/OHV.Vehicle/App.xaml.cs

@@ -1,17 +1,86 @@
 using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Threading.Tasks;
 using System.Windows;
+using CommonServiceLocator;
+using GSG.NET.Logging;
+using GSG.NET.Utils;
+using OHV.Common.Events;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Modularity;
+using Prism.Unity;
+using VehicleControlSystem;
 
 namespace OHV.Vehicle
 {
     /// <summary>
     /// App.xaml에 대한 상호 작용 논리
     /// </summary>
-    public partial class App : Application
+    public partial class App : PrismApplication
     {
+        static Logger logger = Logger.GetLogger();
+
+        private void Application_Startup(object sender, StartupEventArgs e)
+        {
+            LogUtils.Configure("CONFIG/log4net.xml");
+            AppUtils.LogGlobalException();
+
+            if (!ProcessUtils.IsOnlyOneInstance)
+            {
+                MessageBox.Show("Program is already running.");
+                this.Shutdown();
+                return;
+            }
+
+            try
+            {
+                //QuartzUtils.Init(10);
+                logger.I(string.Format(string.Empty.PadRight(40, '+') + $" Ver. {AssemblyUtils.GetVersion()} " + string.Empty.PadRight(40, '+')));
+
+
+                //var mainView = new MainWindow();
+                //mainView.Show();
+
+                //this.MainWindow = mainView;
+                //this.ShutdownMode = ShutdownMode.OnMainWindowClose;
+            }
+            catch (Exception ex)
+            {
+                logger.E(ex);
+
+                this.Shutdown();
+            }
+
+        }
+
+        private void Application_Exit(object sender, ExitEventArgs e)
+        {
+            var ea = Container.Resolve<IEventAggregator>();
+            if (ea != null) ea.GetEvent<ApplicationExitEvent>().Publish("");
+
+            logger.I(string.Empty.PadRight(100, '-'));
+        }
+
+        protected override Window CreateShell()
+        {
+            return Container.Resolve<MainWindow>();
+            //return ServiceLocator.Current.GetInstance<MainWindow>();
+        }
+
+        protected override void RegisterTypes(IContainerRegistry containerRegistry)
+        {
+        }
+
+        protected override void ConfigureViewModelLocator()
+        {
+            base.ConfigureViewModelLocator();
+        }
+
+        protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
+        {
+            base.ConfigureModuleCatalog(moduleCatalog);
+
+            moduleCatalog.AddModule(typeof(VCSystem));
+        }
+
     }
 }

+ 88 - 0
Dev/OHV/OHV.Vehicle/Config/log4net.xml

@@ -0,0 +1,88 @@
+<log4net>
+
+	<root>
+		<level value="ALL" />
+		<appender-ref ref="FileAppender" />
+		<appender-ref ref="WarnFileAppender" />
+		<appender-ref ref="ConsoleAppender" />
+		<appender-ref ref="DebugFileAppender" />
+		<!--<appender-ref ref="MongoAppender" />-->
+	</root>
+
+	<logger name="Host" additivity="false">
+		<appender-ref ref="HostAppender" />
+	</logger>
+
+	<!--
+	ALL    DEBUG   INFO    WARN    ERROR   FATAL   OFF
+	•All
+	•DEBUG  •DEBUG
+	•INFO   •INFO   •INFO
+	•WARN   •WARN   •WARN   •WARN
+	•ERROR  •ERROR  •ERROR  •ERROR  •ERROR
+	•FATAL  •FATAL  •FATAL  •FATAL  •FATAL  •FATAL
+	•OFF    •OFF    •OFF    •OFF    •OFF    •OFF    •OFF
+	-->
+
+	<appender name="FileAppender" type="GSG.NET.Logging.FileAppender, GSG.NET">
+		<filter type="log4net.Filter.LevelRangeFilter">
+			<param name="LevelMin" value="INFO"></param>
+			<param name="LevelMax" value="OFF"></param>
+		</filter>
+		<file value="D:\LOG\OHV\Vehicle.log" />
+		<appendToFile value="true" />
+		<rollingStyle value="Date" />
+		<backupDays value="180" />
+		<datePattern value="-MMdd'.log'" />
+		<layout type="log4net.Layout.PatternLayout">
+			<conversionPattern value="%d{MM-dd HH:mm:ss.fff} %-2t %p %m%n" />
+		</layout>
+	</appender>
+
+	<appender name="HostAppender" type="GSG.NET.Logging.FileAppender, GSG.NET">
+		<file value="D:\LOG\OHV\Vehicle\Host.log" />
+		<appendToFile value="true" />
+		<rollingStyle value="Date" />
+		<backupDays value="180" />
+		<datePattern value="-MMdd'.log'" />
+		<layout type="log4net.Layout.PatternLayout">
+			<conversionPattern value="%d{MM-dd HH:mm:ss.fff} %-2t %p %m%n" />
+		</layout>
+	</appender>
+
+	<appender name="DebugFileAppender" type="GSG.NET.Logging.FileAppender, GSG.NET">
+		<filter type="log4net.Filter.LevelRangeFilter">
+			<param name="LevelMin" value="DEBUG"></param>
+			<param name="LevelMax" value="DEBUG"></param>
+		</filter>
+		<threshold value="DEBUG"/>
+		<file value="D:\LOG\OHV\DEBUG\Vehicle_DEBUG.log" />
+		<appendToFile value="true" />
+		<rollingStyle value="Date" />
+		<backupDays value="10" />
+		<datePattern value="-MMdd'.log'" />
+		<layout type="log4net.Layout.PatternLayout">
+			<conversionPattern value="%d{MM-dd HH:mm:ss.fff} %2t %p %m%n" />
+		</layout>
+	</appender>
+
+	<appender name="WarnFileAppender" type="GSG.NET.Logging.FileAppender, GSG.NET">
+		<threshold value="WARN"/>
+		<file value="D:\LOG\OHV\Vehicle_WARN.log" />
+		<appendToFile value="true" />
+		<rollingStyle value="Date" />
+		<backupDays value="180" />
+		<datePattern value="-MMdd'.log'" />
+		<layout type="log4net.Layout.PatternLayout">
+			<conversionPattern value="%d{MM-dd HH:mm:ss.fff} %2t %p %m%n" />
+		</layout>
+	</appender>
+
+	<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"   >
+		<layout type="log4net.Layout.PatternLayout">
+			<param name="ConversionPattern" value="%d %m%n" />
+		</layout>
+		<threshold value="ALL"/>
+	</appender>
+
+</log4net>

+ 7 - 2
Dev/OHV/OHV.Vehicle/MainWindow.xaml

@@ -4,9 +4,14 @@
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:OHV.Vehicle"
+        xmlns:prism="http://prismlibrary.com/"
+        prism:ViewModelLocator.AutoWireViewModel="True"
         mc:Ignorable="d"
-        Title="MainWindow" Height="450" Width="800">
+        Title="{Binding Title}" Height="450" Width="800">
     <Grid>
-        
+        <!--<ContentControl prism:RegionManager.RegionName="ContentRegion" />-->
+        <TextBlock ><InlineUIContainer>
+            </InlineUIContainer></TextBlock>
+        <Button Content="Button" Height="30" Width="65" Command="{Binding TestCommand}"/>
     </Grid>
 </Window>

+ 15 - 0
Dev/OHV/OHV.Vehicle/MainWindow.xaml.cs

@@ -20,9 +20,24 @@ namespace OHV.Vehicle
     /// </summary>
     public partial class MainWindow : Window
     {
+        public MainWindowViewModel ViewModel { get => this.DataContext as MainWindowViewModel; }
+
         public MainWindow()
         {
             InitializeComponent();
+            this.Loaded += MainWindow_Loaded;
+            this.Closing += MainWindow_Closing;
+        }
+
+        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+        {
+            this.ViewModel.Dispose();
         }
+
+        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
+        {
+            this.ViewModel.InitViewModel();
+        }
+
     }
 }

+ 63 - 0
Dev/OHV/OHV.Vehicle/MainWindowViewModel.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using CommonServiceLocator;
+using OHV.Common.Events;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using VehicleControlSystem;
+
+namespace OHV.Vehicle
+{
+    public class MainWindowViewModel :BindableBase
+    {
+        private string _title = "Prism Unity Application";
+        public string Title
+        {
+            get { return _title; }
+            set { SetProperty(ref _title, value); }
+        }
+
+        IEventAggregator eventAggregator = null;
+
+        public ICommand TestCommand { get; set; }
+
+        public MainWindowViewModel(IEventAggregator ea)
+        {
+            this.eventAggregator = ea;
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe(UICallbackCommunication, ThreadOption.UIThread);
+
+            this.TestCommand = new DelegateCommand(ExecuteTextCommand);
+        }
+
+        private void UICallbackCommunication(GUIMessageEventArgs obj)
+        {
+        }
+
+        private void ExecuteTextCommand()
+        {
+            var m = new VCSMessageEventArgs();
+            m.MessageKey = 1234;
+            m.MessageText = "Test Message";
+            m.Command = new Common.Model.Command() { CommandID = "TestCommand123", Type = Common.Shareds.eCommandType.Move };
+
+            this.eventAggregator.GetEvent<VCSMessagePubSubEvent>().Publish(m);
+        }
+
+        public void InitViewModel()
+        {
+            //VCSystem.Instance.Init();
+        }
+
+        public void Dispose()
+        {
+            //VCSystem.Instance.Dispose();
+            
+        }
+
+    }
+}

+ 58 - 0
Dev/OHV/OHV.Vehicle/OHV.Vehicle.csproj

@@ -37,14 +37,33 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
+      <HintPath>..\packages\CommonServiceLocator.2.0.4\lib\net45\CommonServiceLocator.dll</HintPath>
+    </Reference>
     <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.dll</HintPath>
     </Reference>
     <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
     </Reference>
+    <Reference Include="GSG.NET">
+      <HintPath>..\Assambly\GSG.NET.dll</HintPath>
+    </Reference>
+    <Reference Include="log4net">
+      <HintPath>..\Assambly\log4net.dll</HintPath>
+    </Reference>
+    <Reference Include="Prism, Version=7.2.0.1422, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
+      <HintPath>..\packages\Prism.Core.7.2.0.1422\lib\net45\Prism.dll</HintPath>
+    </Reference>
+    <Reference Include="Prism.Unity.Wpf, Version=7.2.0.1422, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
+      <HintPath>..\packages\Prism.Unity.7.2.0.1422\lib\net45\Prism.Unity.Wpf.dll</HintPath>
+    </Reference>
+    <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="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Data" />
     <Reference Include="System.Data.SQLite, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
       <HintPath>..\packages\System.Data.SQLite.Core.1.0.112.0\lib\net45\System.Data.SQLite.dll</HintPath>
@@ -55,6 +74,18 @@
     <Reference Include="System.Data.SQLite.Linq, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
       <HintPath>..\packages\System.Data.SQLite.Linq.1.0.112.0\lib\net45\System.Data.SQLite.Linq.dll</HintPath>
     </Reference>
+    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Prism.Wpf.7.2.0.1422\lib\net45\System.Windows.Interactivity.dll</HintPath>
+    </Reference>
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
@@ -64,6 +95,12 @@
     <Reference Include="System.Xaml">
       <RequiredTargetFramework>4.0</RequiredTargetFramework>
     </Reference>
+    <Reference Include="Unity.Abstractions, Version=5.11.1.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
+      <HintPath>..\packages\Unity.Abstractions.5.11.1\lib\net45\Unity.Abstractions.dll</HintPath>
+    </Reference>
+    <Reference Include="Unity.Container, Version=5.11.1.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
+      <HintPath>..\packages\Unity.Container.5.11.1\lib\net45\Unity.Container.dll</HintPath>
+    </Reference>
     <Reference Include="WindowsBase" />
     <Reference Include="PresentationCore" />
     <Reference Include="PresentationFramework" />
@@ -87,6 +124,9 @@
     </Compile>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="MainWindowViewModel.cs">
+      <DependentUpon>MainWindow.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Properties\AssemblyInfo.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -113,6 +153,24 @@
   <ItemGroup>
     <None Include="App.config" />
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="DB\" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Config\log4net.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\OHV.Common\OHV.Common.csproj">
+      <Project>{0d1f7fbc-bfb0-4ee4-852d-e2a8d62c5708}</Project>
+      <Name>OHV.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\VehicleControlSystem\VehicleControlSystem.csproj">
+      <Project>{73BAB40E-FC7D-4AB5-85CA-B4CF221DFBD1}</Project>
+      <Name>VehicleControlSystem</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>

+ 9 - 0
Dev/OHV/OHV.Vehicle/packages.config

@@ -1,8 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="CommonServiceLocator" version="2.0.4" targetFramework="net45" />
   <package id="EntityFramework" version="6.3.0" targetFramework="net45" />
+  <package id="Prism.Core" version="7.2.0.1422" targetFramework="net45" />
+  <package id="Prism.Unity" version="7.2.0.1422" targetFramework="net45" />
+  <package id="Prism.Wpf" version="7.2.0.1422" targetFramework="net45" />
   <package id="System.Data.SQLite" version="1.0.112.0" targetFramework="net45" />
   <package id="System.Data.SQLite.Core" version="1.0.112.0" targetFramework="net45" />
   <package id="System.Data.SQLite.EF6" version="1.0.112.0" targetFramework="net45" />
   <package id="System.Data.SQLite.Linq" version="1.0.112.0" targetFramework="net45" />
+  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net45" />
+  <package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net45" />
+  <package id="System.ValueTuple" version="4.5.0" targetFramework="net45" />
+  <package id="Unity.Abstractions" version="5.11.1" targetFramework="net45" />
+  <package id="Unity.Container" version="5.11.1" targetFramework="net45" />
 </packages>

+ 99 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using GSG.NET.Utils;
+
+namespace VehicleControlSystem.ControlLayer
+{
+    /// <summary>
+    /// Control Layer 의 자원을 여기서 사용하자.
+    /// </summary>
+    public class Vehicle
+    {
+        private double currentPosition;
+
+        public double CurrentPosition
+        {
+            get { return currentPosition; }
+            set { currentPosition = value; }
+        }
+
+        public Vehicle()
+        {
+        }
+
+        #region Control Action Method
+        public bool MoveTo(string pointID)
+        {
+            return Wait4MoveDone();
+        }
+
+        bool Wait4MoveDone()
+        {
+            int waitTime = 60000;
+            long st = SwUtils.CurrentTimeMillis;
+
+            //Todo: 이동시 확인 사항들.
+            while (true)
+            {
+                if (SwUtils.Gt(st, waitTime))
+                {
+                    //Todo: 이동시간 초과 시 동작들.
+                    break;
+                }
+            }
+            return true;
+        }
+
+        public bool LoadCarrier()
+        {
+            return Wait4LoadCarreir();
+        }
+
+        bool Wait4LoadCarreir()
+        {
+            int waitTime = 60000;
+            long st = SwUtils.CurrentTimeMillis;
+
+            //Todo: 이동시 확인 사항들.
+            while (true)
+            {
+                if (SwUtils.Gt(st, waitTime))
+                {
+                    //Todo: 이동시간 초과 시 동작들.
+                    break;
+                }
+            }
+            return true;
+        }
+
+        public bool UnloadCarrier()
+        {
+            return Wait4UnloadCarreir();
+        }
+
+        bool Wait4UnloadCarreir()
+        {
+            int waitTime = 60000;
+            long st = SwUtils.CurrentTimeMillis;
+
+            //Todo: 이동시 확인 사항들.
+            while (true)
+            {
+                if (SwUtils.Gt(st, waitTime))
+                {
+                    //Todo: 이동시간 초과 시 동작들.
+                    break;
+                }
+            }
+            return true;
+        }
+        #endregion
+
+        #region Machanical Method
+
+        #endregion
+    }
+}

+ 188 - 0
Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs

@@ -0,0 +1,188 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using GSG.NET.Concurrent;
+using GSG.NET.Logging;
+using GSG.NET.Utils;
+using OHV.Common.Events;
+using OHV.Common.Model;
+using Prism.Events;
+
+namespace VehicleControlSystem.Managers
+{
+    public class Scheduler : IDisposable
+    {
+        static Logger logger = Logger.GetLogger();
+
+        private List<Command> commands;
+
+        public List<Command> CommandsList
+        {
+            get { return commands; }
+            set { commands = value; }
+        }
+
+        Thread thread = null;
+        bool isThreadAlive = false;
+
+        IEventAggregator eventAggregator;
+
+        public Scheduler(IEventAggregator ea)
+        {
+            this.CommandsList = new List<Command>();
+            eventAggregator = ea;// CommonServiceLocator.ServiceLocator.Current.GetInstance<IEventAggregator>();
+            eventAggregator.GetEvent<VCSMessagePubSubEvent>().Subscribe(OnReceivedMessageEvent);
+        }
+
+        private void OnReceivedMessageEvent(VCSMessageEventArgs obj)
+        {
+            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)
+        {
+            eventAggregator.GetEvent<GUIMessagePubSubEvent>().Publish(args);
+        }
+
+        public void Init()
+        {
+            this.isThreadAlive = true;
+            this.thread = ThreadUtils.Invoke(this.ExcuteCommand);
+        }
+
+        public bool AddCommand(Command cmd)
+        {
+            if (this.CommandsList == null) return false;
+            try
+            {
+	            this.CommandsList.Add(cmd);
+            }
+            catch (Exception ex)
+            {
+                logger.E(ex);
+                return false;
+            }
+
+            return true;
+        }
+
+        bool RemoveCommand(Command cmd)
+        {
+            if (!this.CommandsList.Remove(cmd))
+            {
+                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} ");
+            return true;
+        }
+
+        void ExcuteCommand()
+        {
+            while (isThreadAlive)
+            {
+                Thread.Sleep(100);
+                try
+                {
+                    Command cmd = null;
+                    cmd = CommandsList.FirstOrDefault();
+                    if ( cmd == null )
+                        continue;
+
+                    DoWork(cmd);
+
+                }
+                catch (Exception ex)
+                {
+                    logger.E(ex);
+                }
+            }
+        }
+
+        private void DoWork(Command cmd)
+        {
+            switch (cmd.State)
+            {
+                case OHV.Common.Shareds.eCommandState.init:
+                    break;
+                case OHV.Common.Shareds.eCommandState.MoveToSource:
+                    break;
+                case OHV.Common.Shareds.eCommandState.Arrived:
+                    cmd.State = OHV.Common.Shareds.eCommandState.AcquireStart;
+                    break;
+                case OHV.Common.Shareds.eCommandState.AcquireStart:
+                    cmd.State = OHV.Common.Shareds.eCommandState.AcquireComplete;
+                    break;
+                case OHV.Common.Shareds.eCommandState.AcquireComplete:
+                    cmd.State = OHV.Common.Shareds.eCommandState.MoveToDest;
+                    break;
+                case OHV.Common.Shareds.eCommandState.MoveToDest:
+                    cmd.State = OHV.Common.Shareds.eCommandState.Departed;
+                    break;
+                case OHV.Common.Shareds.eCommandState.Departed:
+                    cmd.State = OHV.Common.Shareds.eCommandState.DepositStart;
+                    break;
+                case OHV.Common.Shareds.eCommandState.DepositStart:
+                    cmd.State = OHV.Common.Shareds.eCommandState.DepositComplete;
+                    break;
+                case OHV.Common.Shareds.eCommandState.DepositComplete:
+                    cmd.State = OHV.Common.Shareds.eCommandState.Finished;
+                    break;
+                case OHV.Common.Shareds.eCommandState.Finished: //command Delete
+                    cmd.Result = OHV.Common.Shareds.eCommandResult.Completed;
+                    RemoveCommand(cmd);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        #region IDisposable Support
+        private bool disposedValue = false; // 중복 호출을 검색하려면
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                if (disposing)
+                {
+                    // TODO: 관리되는 상태(관리되는 개체)를 삭제합니다.
+                    this.isThreadAlive = false;
+                    if ( !this.thread.Join(3000) )
+                        ThreadUtils.Kill(this.thread);
+                }
+
+                // TODO: 관리되지 않는 리소스(관리되지 않는 개체)를 해제하고 아래의 종료자를 재정의합니다.
+                // TODO: 큰 필드를 null로 설정합니다.
+
+                disposedValue = true;
+            }
+        }
+
+        // TODO: 위의 Dispose(bool disposing)에 관리되지 않는 리소스를 해제하는 코드가 포함되어 있는 경우에만 종료자를 재정의합니다.
+        // ~Scheduler()
+        // {
+        //   // 이 코드를 변경하지 마세요. 위의 Dispose(bool disposing)에 정리 코드를 입력하세요.
+        //   Dispose(false);
+        // }
+
+        // 삭제 가능한 패턴을 올바르게 구현하기 위해 추가된 코드입니다.
+        public void Dispose()
+        {
+            // 이 코드를 변경하지 마세요. 위의 Dispose(bool disposing)에 정리 코드를 입력하세요.
+            Dispose(true);
+            // TODO: 위의 종료자가 재정의된 경우 다음 코드 줄의 주석 처리를 제거합니다.
+            // GC.SuppressFinalize(this);
+        }
+        #endregion
+    }
+}

+ 0 - 15
Dev/OHV/VehicleControlSystem/System.cs

@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using GSG.NET;
-using GSG.NET.ObjectBase;
-
-namespace VehicleControlSystem
-{
-    public class System : SingletonBase<System>
-    {
-        private System() { }
-    }
-}

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

@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using GSG.NET;
+using GSG.NET.ObjectBase;
+using OHV.Common.Events;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Modularity;
+using VehicleControlSystem.Managers;
+
+namespace VehicleControlSystem
+{
+    [Module(ModuleName ="VCSystem")]
+    public class VCSystem : IModule, IDisposable
+    {
+        Scheduler scheduler = null;
+        IEventAggregator eventAggregator = null;
+        public VCSystem(IEventAggregator ea) 
+        {
+            this.eventAggregator = ea;
+
+            this.eventAggregator.GetEvent<ApplicationExitEvent>().Subscribe((o) => Dispose(), true);
+        }
+
+        public void Init()
+        {
+            this.scheduler = new Scheduler(eventAggregator);
+            this.scheduler.Init();
+        }
+
+        public void Dispose()
+        {
+            this.scheduler.Dispose();
+        }
+
+        public void RegisterTypes(IContainerRegistry containerRegistry)
+        {
+        }
+
+        public void OnInitialized(IContainerProvider containerProvider)
+        {
+            this.Init();
+        }
+    }
+}

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

@@ -34,11 +34,27 @@
     <StartupObject />
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
+      <HintPath>..\packages\CommonServiceLocator.2.0.4\lib\net45\CommonServiceLocator.dll</HintPath>
+    </Reference>
     <Reference Include="GSG.NET">
       <HintPath>..\Assambly\GSG.NET.dll</HintPath>
     </Reference>
+    <Reference Include="Prism, Version=7.2.0.1422, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
+      <HintPath>..\packages\Prism.Core.7.2.0.1422\lib\net45\Prism.dll</HintPath>
+    </Reference>
+    <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="System" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
+    <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Prism.Wpf.7.2.0.1422\lib\net45\System.Windows.Interactivity.dll</HintPath>
+    </Reference>
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
@@ -47,14 +63,29 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="System.cs" />
+    <Compile Include="ControlLayer\Vehicle.cs" />
+    <Compile Include="Managers\Scheduler.cs" />
+    <Compile Include="VCSystem.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\OHV.Common\OHV.Common.csproj">
+      <Project>{0d1f7fbc-bfb0-4ee4-852d-e2a8d62c5708}</Project>
+      <Name>OHV.Common</Name>
+    </ProjectReference>
     <ProjectReference Include="..\OHV.SqliteDAL\OHV.SqliteDAL.csproj">
       <Project>{122d81c8-9ab9-4ced-80d2-9c4f2f9deb4c}</Project>
       <Name>OHV.SqliteDAL</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="ControlLayer\Actuator\" />
+    <Folder Include="ControlLayer\IO\" />
+    <Folder Include="ControlLayer\Motion\" />
+    <Folder Include="ControlLayer\Serial\" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 7 - 0
Dev/OHV/VehicleControlSystem/packages.config

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="CommonServiceLocator" version="2.0.4" targetFramework="net45" />
+  <package id="Prism.Core" version="7.2.0.1422" targetFramework="net45" />
+  <package id="Prism.Wpf" version="7.2.0.1422" targetFramework="net45" />
+  <package id="System.ValueTuple" version="4.5.0" targetFramework="net45" />
+</packages>

BIN
Documents/■ OHV Distribution Diagram.pptx