SK.Kang 6 лет назад
Родитель
Сommit
ca25f5445a
35 измененных файлов с 574 добавлено и 119 удалено
  1. 25 0
      Dev/OHV/OHV.Common/Model/Alarm.cs
  2. 19 0
      Dev/OHV/OHV.Common/Model/AxisConfig.cs
  3. 8 9
      Dev/OHV/OHV.Common/Model/AxisVelocityData.cs
  4. 2 0
      Dev/OHV/OHV.Common/OHV.Common.csproj
  5. 13 0
      Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs
  6. 132 0
      Dev/OHV/OHV.SqliteDAL/DAL/AbstractDAL.cs
  7. 13 0
      Dev/OHV/OHV.SqliteDAL/DAL/AlarmDAL.cs
  8. 13 0
      Dev/OHV/OHV.SqliteDAL/DAL/AxisConfigDAL.cs
  9. 59 0
      Dev/OHV/OHV.SqliteDAL/DAL/AxisPositionDataDAL.cs
  10. 39 0
      Dev/OHV/OHV.SqliteDAL/DAL/AxisVelocityDataDAL.cs
  11. 2 2
      Dev/OHV/OHV.SqliteDAL/DAL/ConfigDAL.cs
  12. 2 0
      Dev/OHV/OHV.SqliteDAL/ModelConfiguration.cs
  13. 8 0
      Dev/OHV/OHV.SqliteDAL/OHV.SqliteDAL.csproj
  14. 43 0
      Dev/OHV/OHV.SqliteDAL/OHVDbInitializer.cs
  15. 12 4
      Dev/OHV/OHV.SqliteDAL/SqliteManager.cs
  16. 3 3
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml
  17. 6 1
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml.cs
  18. 10 10
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs
  19. 19 0
      Dev/OHV/OHV.Vehicle/Config/AlarmDefind..csv
  20. 0 0
      Dev/OHV/OHV.Vehicle/Config/Axis.xlsx
  21. BIN
      Dev/OHV/OHV.Vehicle/Config/IO.xlsx
  22. BIN
      Dev/OHV/OHV.Vehicle/DB/OHVDb.sqlite
  23. 1 1
      Dev/OHV/OHV.Vehicle/MainWindow.xaml
  24. 1 1
      Dev/OHV/VehicleControlSystem/ControlLayer/Axis/AbstractAxis.cs
  25. 1 0
      Dev/OHV/VehicleControlSystem/ControlLayer/Axis/AxisConfig.cs
  26. 4 4
      Dev/OHV/VehicleControlSystem/ControlLayer/Axis/AxisData.cs
  27. 3 20
      Dev/OHV/VehicleControlSystem/ControlLayer/Axis/EzAxis.cs
  28. 1 1
      Dev/OHV/VehicleControlSystem/ControlLayer/Axis/IAxis.cs
  29. 84 0
      Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs
  30. 18 14
      Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs
  31. 8 5
      Dev/OHV/VehicleControlSystem/Managers/HostManager.cs
  32. 16 13
      Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs
  33. 0 26
      Dev/OHV/VehicleControlSystem/Managers/SqlManager.cs
  34. 8 4
      Dev/OHV/VehicleControlSystem/VCSystem.cs
  35. 1 1
      Dev/OHV/VehicleControlSystem/VehicleControlSystem.csproj

+ 25 - 0
Dev/OHV/OHV.Common/Model/Alarm.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Shareds;
+using SQLite.CodeFirst;
+
+namespace OHV.Common.Model
+{
+    public class Alarm
+    {
+        [Index("AlarmID")]
+        [Autoincrement]
+        public int Id { get; set; }
+
+        public string Name { get; set; }
+        public string Text { get; set; }
+        public string Decription { get; set; }
+        public string Solution { get; set; }
+        public eAlarmLevel Level { get; set; }
+        public eAlarmKind Kind { get; set; }
+    }
+}

+ 19 - 0
Dev/OHV/OHV.Common/Model/AxisConfig.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SQLite.CodeFirst;
+
+namespace OHV.Common.Model
+{
+    public class AxisConfig
+    {
+        [Autoincrement]
+        public int Id { get; set; }
+
+        public string Name { get; set; }
+        public string Address { get; set; }
+        public double Scale { get; set; }
+    }
+}

+ 8 - 9
Dev/OHV/OHV.Common/Model/AxisVelocityData.cs

@@ -14,17 +14,16 @@ namespace OHV.Common.Model
         [Autoincrement]
         public int id { get; set; }
 
-        [Index("AxisNo")]
+        [Index("AxisName")]
         [Required]
-        public int AxisNo { get; set; }
-
         public string AxisName { get; set; }
-        public double AutoRunVelocity { get; set; }
-        public double AutoRunAccelerate { get; set; }
-        public double AutoRunDecelerate { get; set; }
-        public double ManualRunVelocity { get; set; }
-        public double JogSlow { get; set; }
-        public double JogFast { get; set; }
+
+        public int AutoRunVelocity { get; set; }
+        public int AutoRunAccelerate { get; set; }
+        public int AutoRunDecelerate { get; set; }
+        public int ManualRunVelocity { get; set; }
+        public int JogSlow { get; set; }
+        public int JogFast { get; set; }
         public double Tolerance { get; set; }
         public DateTime CreateTime { get; set; }
         public DateTime EditTime { get; set; }

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

@@ -65,6 +65,8 @@
     <Compile Include="Interfaces\IModelBase.cs" />
     <Compile Include="Interfaces\ISqlManager.cs" />
     <Compile Include="Interfaces\IVehicle.cs" />
+    <Compile Include="Model\Alarm.cs" />
+    <Compile Include="Model\AxisConfig.cs" />
     <Compile Include="Model\AxisPositionData.cs" />
     <Compile Include="Model\AxisVelocityData.cs" />
     <Compile Include="Model\Command.cs" />

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

@@ -87,4 +87,17 @@
 		AbortByAbnormal,
 	}
 	#endregion
+
+	public enum eAlarmLevel
+	{
+		Warn,
+		Falut,
+	}
+
+	public enum eAlarmKind
+	{
+		Axis,
+		Cylinder,
+		Drive,
+	}
 }

+ 132 - 0
Dev/OHV/OHV.SqliteDAL/DAL/AbstractDAL.cs

@@ -0,0 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+using GSG.NET.Logging;
+
+namespace OHV.SqliteDAL.DAL
+{
+    public interface IRepository<TEntity> where TEntity : class
+    {
+        void Create(TEntity entity);
+        void Delete(TEntity entity);
+        void Delete(Guid id);
+        void Edit(TEntity entity);
+    }
+
+    public  class GenericDAL<T> where T : class
+    {
+        public List<T> All
+        {
+            get
+            {
+                List<T> ll = new List<T>();
+                using (var db = new OHVDbContext("OHVDb"))
+                {
+                    ll = db.Set<T>().ToList();
+                }
+                return ll;
+            }
+        }
+
+        public int Count
+        {
+            get
+            {
+                using (var db = new OHVDbContext("OHVDb"))
+                {
+                    return db.Set<T>().Count();
+                }
+            }
+
+        }
+
+        public T GetK(object key)
+        {
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                return db.Set<T>().Find(key);
+            }
+        }
+
+        public void Add(T entity)
+        {
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                db.Set<T>().Add(entity);
+                db.SaveChanges();
+            }
+        }
+
+        public void Delete(T entity)
+        {
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                db.Set<T>().Remove(entity);
+                db.SaveChanges();
+            }
+        }
+
+        //protected int DeleteN(Expression<Func<T, bool>> where)
+        //{
+
+        //}
+
+        public void Clean()
+        {
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                db.Set<T>().RemoveRange(db.Set<T>());
+                db.SaveChanges();
+            }
+        }
+    }
+
+    class GenericRepository<T> : IGenericRepository<T> where T : class
+    {
+        protected Logger logger = Logger.GetLogger();
+
+        private OHVDbContext _context = null;
+        private DbSet<T> table = null;
+
+        public IEnumerable<T> GetAll()
+        {
+            return table.ToList();
+        }
+        public T GetById(object id)
+        {
+            return table.Find(id);
+        }
+        public void Insert(T obj)
+        {
+            table.Add(obj);
+        }
+        public void Update(T obj)
+        {
+            table.Attach(obj);
+            _context.Entry(obj).State = EntityState.Modified;
+        }
+        public void Delete(object id)
+        {
+            T existing = table.Find(id);
+            table.Remove(existing);
+        }
+        public void Save()
+        {
+            _context.SaveChanges();
+        }
+    }
+
+    public interface IGenericRepository<T> where T : class
+    {
+        IEnumerable<T> GetAll();
+        T GetById(object id);
+        void Insert(T obj);
+        void Update(T obj);
+        void Delete(object id);
+        void Save();
+    }
+}

+ 13 - 0
Dev/OHV/OHV.SqliteDAL/DAL/AlarmDAL.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Model;
+
+namespace OHV.SqliteDAL.DAL
+{
+    public class AlarmDAL : GenericDAL<Alarm>
+    {
+    }
+}

+ 13 - 0
Dev/OHV/OHV.SqliteDAL/DAL/AxisConfigDAL.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Model;
+
+namespace OHV.SqliteDAL.DAL
+{
+    public class AxisConfigDAL : GenericDAL<AxisConfig>
+    {
+    }
+}

+ 59 - 0
Dev/OHV/OHV.SqliteDAL/DAL/AxisPositionDataDAL.cs

@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Model;
+
+namespace OHV.SqliteDAL.DAL
+{
+    public class AxisPositionDataDAL
+    {
+        public List<AxisPositionData> All
+        {
+            get
+            {
+                List<AxisPositionData> ll = new List<AxisPositionData>();
+                using (var db = new OHVDbContext("OHVDb"))
+                {
+                    ll = db.Set<AxisPositionData>().ToList();
+                }
+                return ll;
+            }
+        }
+
+        public List<AxisPositionData> GetKFromName(string axisName)
+        {
+            List<AxisPositionData> dataList = new List<AxisPositionData>();
+
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                dataList = db.Set<AxisPositionData>().Where(x => x.AxisName.Equals(axisName)).ToList();
+            }
+
+            return dataList;
+        }
+
+        public List<AxisPositionData> GetKFromPostion(string position)
+        {
+            List<AxisPositionData> dataList = new List<AxisPositionData>();
+
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                dataList = db.Set<AxisPositionData>().Where(x => x.Name.Equals(position)).ToList();
+            }
+
+            return dataList;
+        }
+
+        public AxisPositionData GetK(string axisName, string position)
+        {
+            AxisPositionData data = null;
+
+            var list = this.GetKFromName(axisName);
+
+            return list.Where(x => x.Name.Equals(position)).SingleOrDefault();
+
+        }
+    }
+}

+ 39 - 0
Dev/OHV/OHV.SqliteDAL/DAL/AxisVelocityDataDAL.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Model;
+
+namespace OHV.SqliteDAL.DAL
+{
+    public class AxisVelocityDataDAL
+    {
+        public List<AxisVelocityData> All
+        {
+            get
+            {
+                List<AxisVelocityData> ll = new List<AxisVelocityData>();
+                using (var db = new OHVDbContext("OHVDb"))
+                {
+                    ll = db.Set<AxisVelocityData>().ToList();
+                }
+                return ll;
+            }
+        }
+
+        public AxisVelocityData GetK(string axisName)
+        {
+            AxisVelocityData data = null;
+
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                data = db.Set<AxisVelocityData>().Where(x => x.AxisName.Equals(axisName)).SingleOrDefault();
+            }
+
+            return data;
+        }
+
+
+    }
+}

+ 2 - 2
Dev/OHV/OHV.SqliteDAL/DAL/ConfigDAL.cs

@@ -22,7 +22,7 @@ namespace OHV.SqliteDAL.DAL
             }
         }
 
-        public Config GetConfig(string ID)
+        public Config GetK(string ID)
         {
             Config config = null;
 
@@ -34,7 +34,7 @@ namespace OHV.SqliteDAL.DAL
             return config;
         }
 
-        public int GetCount()
+        public int Count()
         {
             int count = 0;
             using (var db = new OHVDbContext("OHVDb"))

+ 2 - 0
Dev/OHV/OHV.SqliteDAL/ModelConfiguration.cs

@@ -18,6 +18,8 @@ namespace OHV.SqliteDAL
             modelBuilder.Entity<SubCmd>();
             modelBuilder.Entity<AxisPositionData>();
             modelBuilder.Entity<AxisVelocityData>();
+            modelBuilder.Entity<AxisConfig>();
+            modelBuilder.Entity<Alarm>();
         }
     }
 }

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

@@ -43,6 +43,9 @@
     <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="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>
@@ -71,6 +74,11 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="CustomHistory.cs" />
+    <Compile Include="DAL\AbstractDAL.cs" />
+    <Compile Include="DAL\AlarmDAL.cs" />
+    <Compile Include="DAL\AxisConfigDAL.cs" />
+    <Compile Include="DAL\AxisPositionDataDAL.cs" />
+    <Compile Include="DAL\AxisVelocityDataDAL.cs" />
     <Compile Include="DAL\CommandDAL.cs" />
     <Compile Include="DAL\ConfigDAL.cs" />
     <Compile Include="DAL\RouteDAL.cs" />

+ 43 - 0
Dev/OHV/OHV.SqliteDAL/OHVDbInitializer.cs

@@ -76,6 +76,49 @@ namespace OHV.SqliteDAL
                     Name = ConstString.TEACH_POSITION_UNLOCK,
                 },
             });
+
+            context.Set<AxisVelocityData>().AddRange(new List<AxisVelocityData>()
+            {
+                new AxisVelocityData
+                {
+                    AxisName = ConstString.AXIS_CARRIER_LOCK_LEFT,
+                    AutoRunVelocity = 200,
+                    AutoRunAccelerate = 100,
+                    AutoRunDecelerate = 100,
+                    ManualRunVelocity = 100,
+                    JogFast = 10,
+                    JogSlow = 2,
+                    Tolerance = 1,
+
+                },
+                new AxisVelocityData
+                {
+                    AxisName = ConstString.AXIS_CARRIER_LOCK_RIGHT,
+                    AutoRunVelocity = 200,
+                    AutoRunAccelerate = 100,
+                    AutoRunDecelerate = 100,
+                    ManualRunVelocity = 100,
+                    JogFast = 10,
+                    JogSlow = 2,
+                    Tolerance = 1,
+                },
+            });
+
+            context.Set<AxisConfig>().AddRange(new List<AxisConfig>()
+            {
+                new AxisConfig
+                {
+                    Name = ConstString.AXIS_CARRIER_LOCK_LEFT,
+                    Scale = 0.001,
+                    Address = "100.100.100.20",
+                },
+                new AxisConfig
+                {
+                    Name = ConstString.AXIS_CARRIER_LOCK_RIGHT,
+                    Scale = 0.001,
+                    Address = "100.100.100.21",
+                }
+            });
         }
     }
 }

+ 12 - 4
Dev/OHV/OHV.SqliteDAL/SqliteManager.cs

@@ -17,9 +17,21 @@ namespace OHV.SqliteDAL
         public RouteDAL RouteDal { get; set; }
         public CommandDAL CommandDAL { get; set; }
         public SubCmdDAL SubCmdDAL { get; set; }
+        public AxisConfigDAL AxisConfigDAL { get; set; }
+        public AxisPositionDataDAL AxisPositionDataDAL { get; set; }
+        public AxisVelocityDataDAL AxisVelocityDataDAL { get; set; }
+        public AlarmDAL AlarmDAL { get; set; }
 
         public SqliteManager()
         {
+            this.ConfigDal = new ConfigDAL();
+            this.RouteDal = new RouteDAL();
+            this.SubCmdDAL = new SubCmdDAL();
+            this.CommandDAL = new CommandDAL();
+            this.AxisConfigDAL = new AxisConfigDAL();
+            this.AxisPositionDataDAL = new AxisPositionDataDAL();
+            this.AxisVelocityDataDAL = new AxisVelocityDataDAL();
+            this.AlarmDAL = new AlarmDAL();
         }
 
         public void RegisterTypes(IContainerRegistry containerRegistry)
@@ -30,10 +42,6 @@ namespace OHV.SqliteDAL
 
         public void OnInitialized(IContainerProvider containerProvider)
         {
-            this.ConfigDal = new ConfigDAL();
-            this.RouteDal = new RouteDAL();
-            this.SubCmdDAL = new SubCmdDAL();
-            this.CommandDAL = new CommandDAL();
         }
     }
 }

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

@@ -11,7 +11,7 @@
         WindowStyle="None"
         Title="D_MainWindow" Height="1080" Width="1920"
         xmlns:OHVCommonShareds="clr-namespace:OHV.Common.Shareds;assembly=OHV.Common"
-        Background="{x:Null}">
+        Background="{x:Null}" WindowStartupLocation="CenterScreen">
 
     <Grid x:Name="GridMain" Background="{x:Null}">
         <Grid.RowDefinitions>
@@ -54,8 +54,8 @@
                 </Button>
             </StackPanel>
 
-            <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right" >
-                <TextBlock Text="{Binding VehicleID, FallbackValue=VehicleControlSystem 1.0.0.1}" VerticalAlignment="Center" Foreground="LightGray" FontSize="20"/>
+            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0">
+                <TextBlock Text="{Binding VehicleID, FallbackValue=VehicleControlSystem 1.0.0.1}" VerticalAlignment="Center" Foreground="LightGray" FontSize="20" Margin="0,0,0,10"/>
                 <TextBlock Text="{Binding DateTime, FallbackValue=2020-02-24 13:09:33, StringFormat=' \{0:yyyy-MM-dd HH:mm:ss\}'}" VerticalAlignment="Center" FontSize="20" Foreground="LightGray"/>
             </StackPanel>
         </Grid>

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

@@ -12,6 +12,7 @@ using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Shapes;
+using GSG.NET.WPF.Extensions;
 
 namespace OHV.Vehicle.Concept
 {
@@ -37,7 +38,10 @@ namespace OHV.Vehicle.Concept
             e.Handled = true;
             if ( e.ClickCount > 1 )
             {
-
+                if (this.WindowState == WindowState.Maximized)
+                    this.WindowState = WindowState.Normal;
+                else
+                    WindowExternal.MaximizeToFirstMonitor(this);
             }
             else
                 this.DragMove();
@@ -51,6 +55,7 @@ namespace OHV.Vehicle.Concept
         private void MainWindow_Loaded( object sender , RoutedEventArgs e )
         {
             //throw new NotImplementedException();
+            WindowExternal.MaximizeToFirstMonitor(this);
         }
     }
 }

+ 10 - 10
Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs

@@ -133,18 +133,18 @@ namespace OHV.Vehicle.Concept
                 this.DateTime = DateTime.Now;
                 
             };
-            dateTimer.Interval = TimeSpan.FromMilliseconds( 100 );
+            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( 500 );
-            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;
         }

+ 19 - 0
Dev/OHV/OHV.Vehicle/Config/AlarmDefind..csv

@@ -0,0 +1,19 @@
+1,LeftClampServoError,Left Clamp Lock Motion Error,,,1,0
+2,LeftClampServoError,Left Clamp Unlock Motion Error,,,1,0
+3,RightClamServoError,Right Clamp Lock Motion Error,,,1,0
+4,RightClamServoError,Right Clamp Unlock Motion Error,,,1,0
+5,RightClamServoError,Is Not Origin Return,,,1,0
+6,LeftClampServoError,Is Not Origin Return,,,1,0
+7,,,,,,
+8,,,,,,
+9,,,,,,
+10,,,,,,
+11,,,,,,
+12,,,,,,
+13,,,,,,
+14,,,,,,
+15,,,,,,
+16,,,,,,
+17,,,,,,
+18,,,,,,
+19,,,,,,

Dev/OHV/OHV.Vehicle/Config/AxisData.xlsx → Dev/OHV/OHV.Vehicle/Config/Axis.xlsx


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


BIN
Dev/OHV/OHV.Vehicle/DB/OHVDb.sqlite


+ 1 - 1
Dev/OHV/OHV.Vehicle/MainWindow.xaml

@@ -12,7 +12,7 @@
         Title="{Binding Title}" Height="800" Width="1280"
         WindowStyle="None"
         xmlns:OHVCommonShareds="clr-namespace:OHV.Common.Shareds;assembly=OHV.Common"
-        xmlns:Behavior="clr-namespace:GSG.NET.WPF.Behavior;assembly=GSG.NET.WPF">
+        xmlns:Behavior="clr-namespace:GSG.NET.WPF.Behavior;assembly=GSG.NET.WPF" WindowStartupLocation="CenterScreen">
 
     <!--<WindowChrome.WindowChrome>
         <WindowChrome CaptionHeight="0"/>

+ 1 - 1
Dev/OHV/VehicleControlSystem/ControlLayer/Axis/AbstractAxis.cs

@@ -36,7 +36,7 @@ namespace VehicleControlSystem.ControlLayer.Axis
 
         #region Public Method
         public abstract int Initialize();
-        public abstract int Initialize(string filePath);
+        public abstract int Initialize(AxisData data);
         public abstract int Move( double dPosition, double dVelocity = 0, int iAccelerate = 0, int iDecelerate = 0, int iMoveType = 0 );
         public abstract int RMove( double dDistance, double dVelocity = 0, int iAccelerate = 0, int iDecelerate = 0, int iMoveType = 0, bool bClearOpt = true );
         public abstract int StartRMove( double dDistance, double dVelocity = 0, int iAccelerate = 0, int iDecelerate = 0, int iMoveType = 0, bool bClearOpt = true );

+ 1 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Axis/AxisConfig.cs

@@ -10,6 +10,7 @@ namespace VehicleControlSystem.ControlLayer.Axis
     {
         public string AxisName { get; set; }
         public int AxisNo { get; set; }
+        public string Address { get; set; }
         public double Scale { get; set; }
     }
 }

+ 4 - 4
Dev/OHV/VehicleControlSystem/ControlLayer/Axis/AxisData.cs

@@ -10,12 +10,12 @@ namespace VehicleControlSystem.ControlLayer.Axis
     {
         public int AxisNo { get; set; }
         public string AxisName { get; set; }
-        public double AutoRunVelocity { get; set; }
+        public int AutoRunVelocity { get; set; }
         public int AutoRunAccelerate { get; set; }
         public int AutoRunDecelerate { get; set; }
-        public double ManualRunVelocity { get; set; }
-        public double JogSlow { get; set; }
-        public double JogFast { get; set; }
+        public int ManualRunVelocity { get; set; }
+        public int JogSlow { get; set; }
+        public int JogFast { get; set; }
         public double Tolerance { get; set; }
     }
 }

+ 3 - 20
Dev/OHV/VehicleControlSystem/ControlLayer/Axis/EzAxis.cs

@@ -14,8 +14,6 @@ namespace VehicleControlSystem.ControlLayer.Axis
         public AxisConfig Config { get; set; }
         public override AxisData ValocityData { get; set; }
 
-        string _filePath;
-
         public override double CurrentPosition
         {
             get
@@ -81,31 +79,16 @@ namespace VehicleControlSystem.ControlLayer.Axis
             throw new NotImplementedException();
         }
 
-        public override int Initialize( string filePath )
+        public override int Initialize( AxisData data )
         {
-            //IO 에서 연결 해서 여기는 주석처리.
-            //return EziMOTIONPlusELib.FAS_Connect( (byte)192, (byte)168, (byte)0, (byte)Config.AxisNo, Config.AxisNo );
+            EziMOTIONPlusELib.FAS_Connect( (byte)192, (byte)168, (byte)0, (byte)Config.AxisNo, Config.AxisNo );
 
-            this._filePath = filePath;
-            //Data Load
-            this.ValocityData = new ExcelMapper( this._filePath ).Fetch<AxisData>( "Velocity" ).ToList().Where( x => this.AxisID.Equals( x.AxisNo ) ).FirstOrDefault();
+            this.ValocityData = data;
 
             //초기에 설정한다.
             this.SetAccelTime( this.ValocityData.AutoRunAccelerate );
             this.SetDecelTime( this.ValocityData.AutoRunDecelerate );
 
-            //Test
-            //var excel = new ExcelMapper( this._filePath );
-            //List<AxisData> ll = excel.Fetch<AxisData>( "Velocity" ).ToList();
-
-            //var a = ll.Where( x => x.AxisNo == 1 ).FirstOrDefault();
-            //a.AutoRunVelocity = 1000;
-
-
-            ////var S = new FileStream( this._filePath, FileMode.Open, FileAccess.ReadWrite );
-            ////excel.Save( S, ll, "Velocity" );
-            //excel.Save( this._filePath, ll, "Velocity" );
-
             return 0;
         }
 

+ 1 - 1
Dev/OHV/VehicleControlSystem/ControlLayer/Axis/IAxis.cs

@@ -29,7 +29,7 @@ namespace VehicleControlSystem.ControlLayer.Axis
         double CurrentPosition { get; }
 
         int Initialize();
-        int Initialize( string filePath );
+        int Initialize( AxisData data );
 
         int Move( double dPosition, double dVelocity = 0.0, int iAccelerate = 0, int iDecelerate = 0, int iMoveType = 0 );
         int StartMove( double dPosition, double dVelocity, int iAccelerate = 0, int iDecelerate = 0, int iMoveType = 0 );

+ 84 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs

@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Shareds;
+using OHV.SqliteDAL;
+using VehicleControlSystem.ControlLayer.Axis;
+
+namespace VehicleControlSystem.ControlLayer
+{
+    public class Clamp
+    {
+        SqliteManager sql = null;
+        List<EzAxis> axes = new List<EzAxis>();
+
+        public Clamp(SqliteManager sqliteManager)
+        {
+            this.sql = sqliteManager;
+        }
+
+        void CreateAxis()
+        {
+            sql.AxisConfigDAL.All.ForEach(config =>
+            {
+                Axis.AxisConfig c = new Axis.AxisConfig
+                {
+                    AxisName = config.Name,
+                    AxisNo = config.Id,
+                    Scale = config.Scale,
+                    Address = config.Address,
+                };
+                axes.Add(new EzAxis(c));
+            });
+
+            this.axes.ForEach(axis =>
+            {
+                var data = sql.AxisVelocityDataDAL.GetK(axis.Config.AxisName);
+                Axis.AxisData axisData = new AxisData
+                {
+                    AxisNo = data.id,
+                    AxisName = data.AxisName,
+                    AutoRunVelocity = data.AutoRunVelocity,
+                    AutoRunAccelerate = data.AutoRunAccelerate,
+                    AutoRunDecelerate = data.AutoRunDecelerate,
+                    ManualRunVelocity = data.ManualRunVelocity,
+                    JogFast = data.JogFast,
+                    JogSlow = data.JogSlow,
+                    Tolerance = data.Tolerance,
+                };
+
+                axis.Initialize(axisData);
+            });
+        }
+
+        bool CLAMP_OriginReturn()
+        {
+            this.axes.ForEach(a =>
+            {
+                a.OriginReturn(true);
+            });
+
+            return true;
+        }
+
+        bool CLAMP_Lock()
+        {
+            this.axes.ForEach(a =>
+            {
+                var pData = sql.AxisPositionDataDAL.GetK(a.Config.AxisName, ConstString.TEACH_POSITION_LOCK);
+                a.StartMove(pData.Value, 0);
+            });
+
+            this.axes.ForEach(a =>
+            {
+                a.Wait4Done();
+            });
+
+            return true;
+        }
+
+
+    }
+}

+ 18 - 14
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -9,6 +9,7 @@ using GSG.NET.Logging;
 using GSG.NET.Utils;
 using OHV.Common.Model;
 using OHV.Common.Shareds;
+using OHV.SqliteDAL;
 using VehicleControlSystem.ControlLayer.Actuator.Cylinder;
 using VehicleControlSystem.ControlLayer.Axis;
 using VehicleControlSystem.ControlLayer.IO;
@@ -53,10 +54,11 @@ namespace VehicleControlSystem.ControlLayer
 
         IIO iO = null;
         GSIMotion motion = null;
+        SqliteManager sql = null;
 
         #region List.
         List<ICylinder> cylinders = new List<ICylinder>();
-        List<IAxis> axes = new List<IAxis>();
+
         List<string> obstacleBitList = new List<string>();
         #endregion
 
@@ -71,12 +73,13 @@ namespace VehicleControlSystem.ControlLayer
         }
 
 
-        public Vehicle(IIO io)
+        public Vehicle(IIO io, SqliteManager sqliteManager)
         {
             this.iO = io;
             this.motion = new GSIMotion();
+            this.sql = sqliteManager;
 
-            this.obstacleBitList.AddRange(new string[] 
+            this.obstacleBitList.AddRange(new string[]
             {
                 "OUT_Obstruction_Bit_00",
                 "OUT_Obstruction_Bit_01",
@@ -88,9 +91,11 @@ namespace VehicleControlSystem.ControlLayer
 
         public void Init()
         {
+            var a = sql.AlarmDAL.GetK(1);
             ThreadStart();
         }
 
+
         public void Dispose()
         {
             this.cancel.Cancel();
@@ -140,14 +145,14 @@ namespace VehicleControlSystem.ControlLayer
                     if (this.VehicleStateProperty != eVehicleState.Idle) //상태가 Idle 가 아니면 subcmd 를 가져 오지 않는다.
                         continue;
 
-                    var subCmd = SqlManager.Instance.SubCmdDAL.GetSubCmd();
+                    var subCmd = sql.SubCmdDAL.GetSubCmd();
                     if (subCmd == null) continue;
 
-                    if (!SqlManager.Instance.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 가 없으면 삭제.
                         {
-                            SqlManager.Instance.SubCmdDAL.Delete(subCmd);
+                            sql.SubCmdDAL.Delete(subCmd);
                             logger.I($"SubCmd Deleted - ID={subCmd.ID}, CommandID={subCmd.CmdID}");
                         }
                     }
@@ -192,10 +197,10 @@ namespace VehicleControlSystem.ControlLayer
         {
             if (this.MoveTo(sub.TargetID))
             {
-                SqlManager.Instance.SubCmdDAL.Delete(sub);
+                sql.SubCmdDAL.Delete(sub);
             }
-            else 
-            { 
+            else
+            {
             }
         }
 
@@ -229,12 +234,12 @@ namespace VehicleControlSystem.ControlLayer
         //Load
         void Load(SubCmd sub)
         {
-            if ( this.LoadCarrier(sub))
-                SqlManager.Instance.SubCmdDAL.Delete(sub);
+            if (this.LoadCarrier(sub))
+                sql.SubCmdDAL.Delete(sub);
         }
         public bool LoadCarrier(SubCmd sub)
         {
-            var route = SqlManager.Instance.RouteDal.GetRoute(sub.TargetID);
+            var route = sql.RouteDal.GetRoute(sub.TargetID);
 
             if (!CorrectPosition(route, this.CurrentPosition))
                 return false; //Alarm
@@ -323,7 +328,6 @@ namespace VehicleControlSystem.ControlLayer
         #endregion
 
         #region Machanical Method
-
         #endregion
 
         #region Hardware Method
@@ -389,7 +393,7 @@ namespace VehicleControlSystem.ControlLayer
                     this.iO.OutputOff(b);
                 else
                     this.iO.OutputOn(b);
-           });
+            });
 
 
             return true;

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

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
 using GSG.NET.Logging;
 using OHV.Common.Events;
 using OHV.Common.Shareds;
+using OHV.SqliteDAL;
 using OHVConnector;
 using Prism.Events;
 using VehicleControlSystem.ControlLayer;
@@ -22,21 +23,23 @@ namespace VehicleControlSystem.Managers
         OHVConnector.Manager manager = new OHVConnector.Manager();
         IEventAggregator eventAggregator = null;
         Vehicle vehicle;
+        SqliteManager sql = null;
 
-        public HostManager(IEventAggregator ea, Vehicle vehicle)
+        public HostManager(IEventAggregator ea, Vehicle vehicle, SqliteManager sqlite)
         {
             this.eventAggregator = ea;
             this.vehicle = vehicle;
+            this.sql = sqlite;
         }
 
         public void Init()
         {
             this.manager.Config = new Config
             {
-                ID = SqlManager.Instance.ConfigDal.GetConfig(ConstString.VehicleID).Value,
-                IpAddress = SqlManager.Instance.ConfigDal.GetConfig(ConstString.Addr).Value,
-                Port = Convert.ToInt16(SqlManager.Instance.ConfigDal.GetConfig(ConstString.PortNo).Value),
-                HostID = SqlManager.Instance.ConfigDal.GetConfig(ConstString.OCSID).Value,
+                ID = sql.ConfigDal.GetK(ConstString.VehicleID).Value,
+                IpAddress = sql.ConfigDal.GetK(ConstString.Addr).Value,
+                Port = Convert.ToInt16(sql.ConfigDal.GetK(ConstString.PortNo).Value),
+                HostID = sql.ConfigDal.GetK(ConstString.OCSID).Value,
             };
 
             this.manager.OnContd += Manager_OnContd;

+ 16 - 13
Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs

@@ -10,6 +10,7 @@ using GSG.NET.Logging;
 using GSG.NET.Utils;
 using OHV.Common.Events;
 using OHV.Common.Model;
+using OHV.SqliteDAL;
 using Prism.Events;
 
 namespace VehicleControlSystem.Managers
@@ -31,14 +32,16 @@ namespace VehicleControlSystem.Managers
 
         IEventAggregator eventAggregator;
         AutoManager autoManager;
+        SqliteManager sql = null;
 
-        public Scheduler(IEventAggregator ea, AutoManager autoManager)
+        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);
 
             this.autoManager = autoManager;
+            this.sql = sqlite;
         }
 
         private void OnReceivedMessageEvent(VCSMessageEventArgs obj)
@@ -105,7 +108,7 @@ namespace VehicleControlSystem.Managers
                             break;
                         case OHV.Common.Shareds.eAutoModeState.Run:
                             {
-                                Command cmd = SqlManager.Instance.CommandDAL.GetCmd();
+                                Command cmd = sql.CommandDAL.GetCmd();
                                 if (cmd == null) continue;
 
                                 DoWork(cmd);
@@ -129,7 +132,7 @@ namespace VehicleControlSystem.Managers
             switch (cmd.State)
             {
                 case OHV.Common.Shareds.eCommandState.Queued:
-                    if ( SqlManager.Instance.SubCmdDAL.GetCount() <= 0)
+                    if (sql.SubCmdDAL.GetCount() <= 0)
                     {
                         switch (cmd.Type)
                         {
@@ -144,29 +147,29 @@ namespace VehicleControlSystem.Managers
                                 break;
                         }
                     }
-                    SqlManager.Instance.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Assign);
+                    sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Assign);
                     break;
 
                 case OHV.Common.Shareds.eCommandState.Assign: //Assign 되면 Vehicle 의 상태가 Busy 면 Processing 으로 전환.
                     { 
-                        var subCmd = SqlManager.Instance.SubCmdDAL.GetSubCmd();
+                        var subCmd = sql.SubCmdDAL.GetSubCmd();
                         if (subCmd == null) break;
 
                         if (!subCmd.CmdID.Equals(cmd.CommandID))
                             break;
                     }
 
-                    SqlManager.Instance.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Processing);
+                    sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Processing);
                     break;
 
                 case OHV.Common.Shareds.eCommandState.Processing:
                     {
-                        var subCmd = SqlManager.Instance.SubCmdDAL.GetSubCmd();
+                        var subCmd = sql.SubCmdDAL.GetSubCmd();
                         if (subCmd == null) // Move 명령을 수행 완료 했다고 판단.
                         {
                             if ( cmd.IsSecondCommanded)
                             {
-                                SqlManager.Instance.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
+                                sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
                                 break;
                             }
 
@@ -190,7 +193,7 @@ namespace VehicleControlSystem.Managers
                             }
                             else //Move Command
                             {
-                                SqlManager.Instance.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
+                                sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
                                 break;
                             }
                         }
@@ -200,11 +203,11 @@ namespace VehicleControlSystem.Managers
                         else //다른 아이디의 일을 하고 있을 경우 가 생길까??
                         { }
                     }
-                    SqlManager.Instance.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
+                    sql.CommandDAL.UpdateState(cmd.CommandID, OHV.Common.Shareds.eCommandState.Complete);
                     break;
 
                 case OHV.Common.Shareds.eCommandState.Complete:
-                    SqlManager.Instance.CommandDAL.Delete(cmd);
+                    sql.CommandDAL.Delete(cmd);
                     break;
                 default:
                     break;
@@ -235,7 +238,7 @@ namespace VehicleControlSystem.Managers
                 TargetID = cmd.TargetID,
                 CmdID = cmd.CommandID,
             };
-            SqlManager.Instance.SubCmdDAL.Add(sub);
+            sql.SubCmdDAL.Add(sub);
             logger.I($"{sub.ID} Sub Command Create - Type={sub.Type}, TargetID={sub.TargetID}, CommandID={sub.CmdID}");
 
             return true;
@@ -247,7 +250,7 @@ namespace VehicleControlSystem.Managers
             {
             };
 
-            SqlManager.Instance.CommandDAL.Add(cmd);
+            sql.CommandDAL.Add(cmd);
             logger.I($"{cmd.CommandID} Command Create - Type={cmd.Type}, TargetID={cmd.TargetID}");
             return true;
         }

+ 0 - 26
Dev/OHV/VehicleControlSystem/Managers/SqlManager.cs

@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using GSG.NET.ObjectBase;
-using OHV.SqliteDAL.DAL;
-
-namespace VehicleControlSystem.Managers
-{
-    public class SqlManager : SingletonBase<SqlManager>
-    {
-        public ConfigDAL ConfigDal { get; set; }
-        public RouteDAL RouteDal { get; set; }
-        public CommandDAL CommandDAL { get; set; }
-        public SubCmdDAL SubCmdDAL { get; set; }
-
-        private SqlManager()
-        {
-            this.ConfigDal = new ConfigDAL();
-            this.RouteDal = new RouteDAL();
-            this.SubCmdDAL = new SubCmdDAL();
-            this.CommandDAL = new CommandDAL();
-        }
-    }
-}

+ 8 - 4
Dev/OHV/VehicleControlSystem/VCSystem.cs

@@ -8,6 +8,7 @@ using GSG.NET;
 using GSG.NET.ObjectBase;
 using OHV.Common.Events;
 using OHV.Common.Model;
+using OHV.SqliteDAL;
 using Prism.Events;
 using Prism.Ioc;
 using Prism.Modularity;
@@ -26,9 +27,12 @@ namespace VehicleControlSystem
         public AutoManager autoManager = null;
         HostManager hostManager = null;
         Vehicle vehicle = null;
+        SqliteManager sql = null;
 
-        public VCSystem(IEventAggregator ea) 
+        public VCSystem(IEventAggregator ea, SqliteManager sql) 
         {
+            this.sql = sql;
+
             this.eventAggregator = ea;
 
             this.eventAggregator.GetEvent<ApplicationExitEvent>().Subscribe((o) => Dispose(), true);
@@ -53,13 +57,13 @@ namespace VehicleControlSystem
             this.autoManager = new AutoManager(this.IO);
             this.autoManager.Init();
 
-            this.scheduler = new Scheduler(eventAggregator, this.autoManager);
+            this.scheduler = new Scheduler(eventAggregator, this.autoManager, this.sql);
             this.scheduler.Init();
 
-            this.vehicle = new Vehicle(this.IO);
+            this.vehicle = new Vehicle(this.IO, this.sql);
             this.vehicle.Init();
 
-            this.hostManager = new HostManager(this.eventAggregator, this.vehicle);;
+            this.hostManager = new HostManager(this.eventAggregator, this.vehicle, this.sql);
             this.hostManager.Init();
         }
 

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

@@ -85,6 +85,7 @@
     <Compile Include="ControlLayer\Axis\Enum_Axis.cs" />
     <Compile Include="ControlLayer\Axis\EzAxis.cs" />
     <Compile Include="ControlLayer\Axis\IAxis.cs" />
+    <Compile Include="ControlLayer\Clamp.cs" />
     <Compile Include="ControlLayer\IO\BitBlock.cs" />
     <Compile Include="ControlLayer\IO\Delegates.cs" />
     <Compile Include="ControlLayer\IO\EzBoard.cs" />
@@ -105,7 +106,6 @@
     <Compile Include="Managers\AutoManager.cs" />
     <Compile Include="Managers\HostManager.cs" />
     <Compile Include="Managers\Scheduler.cs" />
-    <Compile Include="Managers\SqlManager.cs" />
     <Compile Include="VCSystem.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>