Zixuan 2 days ago
parent
commit
2fe91f9db9

+ 15 - 53
Data/DataService/DBProcessData.cs

@@ -1,83 +1,45 @@
 namespace DataService;
 
-public class DBProcessData<T_Hierarchy, T_PrimaryKey, T_Value>(Func<object, T_PrimaryKey?> KeyConverter, char spilter, string keyName, int skip)
-    where T_PrimaryKey : unmanaged
+public class DBProcessData<T_Hierarchy>(char spilter, int skip)
     where T_Hierarchy : IDictionary<string, object>, new()
-    where T_Value : IDictionary<T_PrimaryKey, object>, new()
 {
-
-    public bool ToDictionary(IEnumerable<dynamic> inputs, out T_Hierarchy? output)
+    public bool ToDictionary(IDictionary<string, object> input, out T_Hierarchy? output)
     {
         output = default;
 
-        if (inputs is null)
+        if (input is null)
             return false;
 
         T_Hierarchy cache = [];
-
-        foreach (dynamic input in inputs)
+        foreach (KeyValuePair<string, object> rawData in input)
         {
-            if (input is null)
-                return false;
-
-            if (input is not IDictionary<string, object> inputPair)
-                return false;
-
-            if (!inputPair.TryGetValue(keyName, out object? primaryKeyValue) || primaryKeyValue is null)
-                return false;
-
-            if (KeyConverter?.Invoke(primaryKeyValue) is not T_PrimaryKey primaryKey)
-                return false;
-
-            if (!inputPair.Remove(keyName))
-                return false;
-            foreach (KeyValuePair<string, object> rawData in input)
-                ColumAnalizer(cache, rawData.Key.Split(spilter).AsSpan()[skip..], primaryKey, rawData.Value);
+            Span<string> source = rawData.Key.Split(spilter).AsSpan()[skip..];
+            ColumAnalizer(cache, source, rawData.Value);
         }
 
         output = cache;
         return true;
     }
 
-    private static void ColumAnalizer(/*ref*/ T_Hierarchy cache, Span<string> seprated, T_PrimaryKey key, object value)
+    private static void ColumAnalizer(/*ref*/ T_Hierarchy cache, Span<string> seprated, object value)
     {
-        if (seprated.Length == 1)
+        if (seprated.Length <= 1)
         {
-            TryGetValueElseCreateNew<T_Value>(cache, seprated[0]).TryAdd(key, value);
-            Console.Write($"{seprated[0]},{value}");
-            Console.WriteLine();
+            cache[seprated[0]] = value;
             return;
         }
 
-        cache = TryGetValueElseCreateNew<T_Hierarchy>(cache, seprated[0]);
-        Console.Write($"{seprated[0]},");
-        ColumAnalizer(cache, seprated[1..], key, value);
-    }
-
-
-    private static T TryGetValueElseCreateNew<T>(T_Hierarchy cache, string key) where T : new()
-    {
-        if (!cache.TryGetValue(key, out object? output) || output is not T dic)
+        if (!cache.TryGetValue(seprated[0], out object? output) || output is not T_Hierarchy hierarchy)
         {
-            dic = new();
-            cache[key] = dic;
+            hierarchy = [];
+            cache[seprated[0]] = hierarchy;
         }
 
-        return dic;
-    }
-}
-
-public class GeneralHeaderAnalizer
-{
-    public static DateTime? LongToDateTime(object o)
-    {
-        if (o is not long l)
-            return null;
-        return new(l);
+        cache = hierarchy;
+        ColumAnalizer(cache, seprated[1..], value);
     }
 }
 
-public class GeneralProcessData(int skip = 0)
-    : DBProcessData<Dictionary<string, object>, DateTime, Dictionary<DateTime, object>>(GeneralHeaderAnalizer.LongToDateTime, '.', "time", skip)
+public class GeneralProcessData(int skip = 0) : DBProcessData<Dictionary<string, object>>('.', skip)
 {
 }

+ 5 - 0
DataBase/DB_Proxima/DB_Proxima.csproj

@@ -6,4 +6,9 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
 
+  <ItemGroup>
+    <ProjectReference Include="..\..\Data\DataService\DataService.csproj" />
+    <ProjectReference Include="..\SqlSugarORM\SqlSugarORM.csproj" />
+  </ItemGroup>
+
 </Project>

+ 1 - 1
DataBase/DB_Proxima/Data.cs

@@ -2,7 +2,7 @@
 
 public class DataCollection<T> : GeneralDB
 {
-    public Dictionary<string, T>? ValueCollection { get; set; }
+    public Dictionary<string, T> ValueCollection { get; } = [];
 }
 
 public class PairValue<T> where T : unmanaged

+ 147 - 107
DataBase/DB_Proxima/ProximaPM.cs

@@ -1,7 +1,12 @@
 namespace DB_Proxima;
 
-public class PM1
+public class PM : GeneralDB
 {
+    public PM(Guid guid, DateTime dateTime)
+    {
+        this.UID = guid;
+        this.Time = dateTime;
+    }
     public APC? APC { get; set; }
     public Shutter? Shutter { get; set; }
     public APCVATGV? APCVATGV { get; set; }
@@ -9,22 +14,27 @@ public class PM1
     public BoatElevatorServo? BoatElevatorServo { get; set; }
     public BoatRotationServo? BoatRotationServo { get; set; }
     public Recipe? RecipeInfo { get; set; }
+    public BufferServo? BufferServo { get; set; }
 
-    public DataCollection<float>? FS { get; set; }
-    public DataCollection<float>? VG { get; set; }
-    public DataCollection<float>? PGPS { get; set; }
-    public DataCollection<bool>? Sensor { get; set; }
+    //FS VG PG PS
+    public DataCollection<float>? ValueSensor { get; set; }
+    //Sensor.. 
+    public DataCollection<bool>? StatusSensor { get; set; }
     public DataCollection<float>? AOValue { get; set; }
     public DataCollection<FFU>? FFU { get; set; }
-    public DataCollection<BufferFoup>? BufferFoup{ get; set; }
     public DataCollection<MFC>? MFC { get; set; }
+    public DataCollection<BufferFoup>? BufferFoup { get; set; }
+    // ..Enable
     public DataCollection<PairValue<bool>>? AVValve { get; set; }
-    public DataCollection<PairValue<float>>? IoValve { get; set; }
+
     public DataCollection<PairValue<float>>? GaslineHeater { get; set; }
 }
 
-public class APC : GeneralDB
+public class APC : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public bool IsError { get; set; }
     public float HomingStatus { get; set; }
     public float Interlock1 { get; set; }
@@ -44,11 +54,13 @@ public class APC : GeneralDB
     public float SlowRateSetPoint { get; set; }
     public float SlowVacuumModeSetting { get; set; }
     public float ValveStatusThreshold { get; set; }
-
 }
 
-public class APCVATGV : GeneralDB
+public class APCVATGV : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public bool IsError { get; set; }
     public float InterlockConstantOfInterlock3 { get; set; }
     public float ModeSetPoint { get; set; }
@@ -62,31 +74,62 @@ public class APCVATGV : GeneralDB
     public float SlowRateSetPoint { get; set; }
     public float SlowVacuumModeSetting { get; set; }
     public float ValveStatusThreshold { get; set; }
+}
+
+public class Recipe : IBasicInfo
+{
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public bool IsError { get; set; }
+    public bool IsExecuteSubRecipe { get; set; }
+    public bool IsInMaintainMode { get; set; }
+    public bool IsLooping { get; set; }
+    public bool IsOnline { get; set; }
+    public bool IsProcessing { get; set; }
 
+    public float DG1 { get; set; }
+    public float MP21_PS { get; set; }
+    public float NewShowTime { get; set; }
+    public bool RecipeHold { get; set; }
+    public bool RecipeHolded { get; set; }
+    public float RecipeHoldTime { get; set; }
+    public float RecipeStepElapseTime { get; set; }
+    public float RecipeStepNumber { get; set; }
+    public float RecipeStepTime { get; set; }
+    public float RecipeTotalElapseTime { get; set; }
+    public float RecipeTotalTime { get; set; }
+    public bool RecipeWait { get; set; }
+    public float SubRecipeCurrentLoopCount { get; set; }
+    public float SubRecipeLoopCount { get; set; }
 }
 
-public class BoatElevatorServo : GeneralDB
+public class BoatElevatorServo : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public bool AtHomePosition { get; set; }
     public bool AtPosition1 { get; set; }
     public bool AtPosition2 { get; set; }
     public bool AtPosition3 { get; set; }
-    public bool CurrentPosition { get; set; }
-    public bool CurrentSpeed { get; set; }
+    public float CurrentPosition { get; set; }
+    public float CurrentSpeed { get; set; }
     public bool IsAlarm { get; set; }
     public bool IsMoving { get; set; }
     public bool IsReady { get; set; }
     public bool IsServoOn { get; set; }
-    public bool TargetPosition { get; set; }
-    public bool TargetPositionFb { get; set; }
-
-
+    public float TargetPosition { get; set; }
+    public float TargetPositionFb { get; set; }
 }
 
-public class BoatRotationServo : GeneralDB
+public class BoatRotationServo : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public bool AtHomePosition { get; set; }
-    public bool CurrentSpeed { get; set; }
+    public float CurrentSpeed { get; set; }
     public bool IsAlarm { get; set; }
     public bool IsHomeDone { get; set; }
     public bool IsHoming { get; set; }
@@ -94,30 +137,11 @@ public class BoatRotationServo : GeneralDB
     public bool IsReady { get; set; }
 }
 
-public class BufferFoup
+public class BufferServo : IBasicInfo
 {
-    public float N2Flow { get; set; }
-    public float N2Pressure { get; set; }
-}
-
-public class BufferServo
-{
-    public bool AtPositionA1 { get; set; }
-    public bool AtPositionA2 { get; set; }
-    public bool AtPositionA3 { get; set; }
-    public bool AtPositionA4 { get; set; }
-    public bool AtPositionB1 { get; set; }
-    public bool AtPositionB2 { get; set; }
-    public bool AtPositionB3 { get; set; }
-    public bool AtPositionB4 { get; set; }
-    public bool AtPositionC1 { get; set; }
-    public bool AtPositionC2 { get; set; }
-    public bool AtPositionC3 { get; set; }
-    public bool AtPositionC4 { get; set; }
-    public bool AtPositionD1 { get; set; }
-    public bool AtPositionD2 { get; set; }
-    public bool AtPositionD3 { get; set; }
-    public bool AtPositionD4 { get; set; }
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public float CurrentPosition { get; set; }
     public float CurrentSpeed { get; set; }
     public float CurrentTorque { get; set; }
@@ -130,88 +154,104 @@ public class BufferServo
     public float TargetPosition { get; set; }
 }
 
-public class FFU
+public class LeakCheck : IBasicInfo
 {
-    public float CurrentSpeed { get; set; }
-    public bool IsSwitch { get; set; }
-    public float SetSpeed { get; set; }
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public float LeakCheckActualLeak { get; set; }
+    public float LeakCheckBasePressure { get; set; }
+    public float LeakCheckBasePressureLimit { get; set; }
+    public float LeakCheckCheckTime { get; set; }
+    public float LeakCheckDelayElapseTime { get; set; }
+    public float LeakCheckDelayMonitorPressure { get; set; }
+    public float LeakCheckDelayStartPressure { get; set; }
+    public float LeakCheckDelayTime { get; set; }
+    public float LeakCheckElapseTime { get; set; }
+    public float LeakCheckHighLimit { get; set; }
+    public float LeakCheckLeakLimit { get; set; }
+    public float LeakCheckLowLimit { get; set; }
+    public float LeakCheckMonitorPressure { get; set; }
+    public float LeakCheckRetryCurrentCount { get; set; }
+    public float LeakCheckRetryLimit { get; set; }
+    public float LeakCheckStartPressure { get; set; }
+
 }
 
-public class LeakCheck : GeneralDB
-{
-    public float ActualLeak { get; set; }
-    public float BasePressure { get; set; }
-    public float BasePressureLimit { get; set; }
-    public float CheckTime { get; set; }
-    public float DelayElapseTime { get; set; }
-    public float DelayMonitorPressure { get; set; }
-    public float DelayStartPressure { get; set; }
-    public float DelayTime { get; set; }
-    public float ElapseTime { get; set; }
-    public float HighLimit { get; set; }
-    public float LeakLimit { get; set; }
-    public float LowLimit { get; set; }
-    public float MonitorPressure { get; set; }
-    public float RetryCurrentCount { get; set; }
-    public float RetryLimit { get; set; }
-    public float StartPressure { get; set; }
+public class Shutter : IBasicInfo
+{
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public bool DiClose { get; set; }
+    public bool DiOpen { get; set; }
+    public bool DoClose { get; set; }
+    public bool DoOpen { get; set; }
+}
+
+
+public class BufferFoup : IBasicInfo
+{
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public float N2Flow { get; set; }
+    public float N2Pressure { get; set; }
+}
 
+public class FFU : IBasicInfo
+{
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public float? CurrentSpeed { get; set; }
+    public bool? IsSwitch { get; set; }
+    public float? SetSpeed { get; set; }
 }
 
-public class MFC
+public class MFC : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public float Feedback { get; set; }
     public float LastSetPoint { get; set; }
     public float MFCUnitEnum { get; set; }
 }
 
-public class Shutter : GeneralDB
+public class GaslineHeater : IBasicInfo
 {
-    public bool DiClose { get; set; }
-    public bool DiOpen { get; set; }
-    public bool DoClose { get; set; }
-    public bool DoOpen { get; set; }
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public float TempFeedback { get; set; }
+    public float TempSetPoint { get; set; }
 }
 
-public class Recipe : GeneralDB
+public class IoValve : IBasicInfo
 {
-    public bool IsError { get; set; }
-    public bool IsExecuteSubRecipe { get; set; }
-    public bool IsInMaintainMode { get; set; }
-    public bool IsLooping { get; set; }
-    public bool IsOnline { get; set; }
-    public bool IsProcessing { get; set; }
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public bool Status { get; set; }
+    public bool SetPoint { get; set; }
+}
 
 
-    public bool AGVEnable { get; set; }
-    public float DG1 { get; set; }
-    public bool DPEnable { get; set; }
-    public bool DPR1Enable { get; set; }
-    public bool DPR2Enable { get; set; }
-    public bool ECOEnable { get; set; }
-    public bool F2ClnEnable { get; set; }
-    public bool FNEnable { get; set; }
-    public bool MBPEnable { get; set; }
-    public float MP21_PS { get; set; }
-    public bool NDIREnable { get; set; }
-    public float NewShowTime { get; set; }
-    public bool NF3ClnEnable { get; set; }
-    public bool PZEROEnable { get; set; }
-    public bool RecipeHold { get; set; }
-    public bool RecipeHolded { get; set; }
-    public float RecipeHoldTime { get; set; }
-    public float RecipeStepElapseTime { get; set; }
-    public float RecipeStepNumber { get; set; }
-    public float RecipeStepTime { get; set; }
-    public float RecipeTotalElapseTime { get; set; }
-    public float RecipeTotalTime { get; set; }
-    public bool RecipeWait { get; set; }
-    public bool SP1Enable { get; set; }
-    public float SubRecipeCurrentLoopCount { get; set; }
-    public float SubRecipeLoopCount { get; set; }
-    public bool TADJEnable { get; set; }
-    public bool TMNTEnable { get; set; }
-    public bool WAT1Enable { get; set; }
-    public bool WAT2Enable { get; set; }
+public class AvValue : IBasicInfo
+{
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+    public bool Feedback { get; set; }
+    public bool SetPoint { get; set; }
+    public bool VirtualStatus { get; set; }
+}
+
+public interface IBasicInfo
+{
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
 
 }

+ 31 - 7
DataBase/DB_Proxima/ProximaSystem.cs

@@ -7,7 +7,8 @@ public class ProximaSystem
     public Schedule? Schedule { get; set; }
     public CarrierRobot? CarrierRobot { get; set; }
     public WaferRobot? WaferRobot { get; set; }
-    public DataCollection<FIMS>? Fims { get; set; }
+
+    public DataCollection<FIMS>? FIMS { get; set; }
     public DataCollection<LoadPort>? LPs { get; set; }
     public DataCollection<Stocker>? Stockers { get; set; }
     public DataCollection<Heater>? Heaters { get; set; }
@@ -63,15 +64,21 @@ public class WaferRobot : GeneralDB
 
 }
 
-public class FIMS
+public class FIMS : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public float FIMSCycledCount { get; set; }
     public bool IsError { get; set; }
     public bool IsOnline { get; set; }
 }
 
-public class LoadPort
+public class LoadPort : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public float CasstleType { get; set; }
     public float InfoPadCarrierIndex { get; set; }
     public float IntAccessMode { get; set; }
@@ -106,8 +113,11 @@ public class Schedule : GeneralDB
     public bool CycleSetPoint { get; set; }
 }
 
-public class Stocker
+public class Stocker : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public bool CassetteHasWafer { get; set; }
     public bool FoupPresent { get; set; }
     public bool IsError { get; set; }
@@ -115,8 +125,11 @@ public class Stocker
     public bool StatusAbnormal { get; set; }
 }
 
-public class Heater
+public class Heater : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public float CascadeControlModeSV { get; set; }
     public float CascadePID_D { get; set; }
     public float CascadePID_I { get; set; }
@@ -146,8 +159,11 @@ public class Heater
 
 }
 
-public class System : GeneralDB
+public class System : IBasicInfo
 {
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
     public bool HasActiveAlarm { get; set; }
     public bool IsAlarm { get; set; }
     public bool IsAlarmConditionBuzzerOn { get; set; }
@@ -157,5 +173,13 @@ public class System : GeneralDB
     public bool IsInitialized { get; set; }
     public bool IsRecipeEditView { get; set; }
     public bool IsSpoolingEnable { get; set; }
-    public bool SpoolingState { get; set; }
+    public float SpoolingState { get; set; }
+}
+
+public class AlarmSignalHeater : IBasicInfo
+{
+    public Guid UID { get; set; }
+    public DateTime Time { get; set; }
+    public string? Name { get; set; }
+
 }

+ 476 - 0
DataBase/DB_Proxima/RemoteToLocal.cs

@@ -0,0 +1,476 @@
+using Dm.util;
+using SqlSugar;
+using SqlSugarORM;
+using System.Reflection;
+using Universal;
+
+namespace DB_Proxima;
+
+public class RemoteToLocal
+{
+
+    private SqlSugarCustom? _orm;
+
+    public bool Initialize(string dbName, string password, string host, string username)
+    {
+        if (this._orm is not null)
+            return false;
+        _orm = new SqlSugarCustom();
+        _orm.CreateDataBase(dbName);
+        _orm.Initialize(null);
+        string dbString = $"Database={dbName};Password={password};Host={host};Username={username};Persist Security Info=True";
+        return _orm.Open(dbString, DbType.PostgreSQL, true);
+    }
+
+    public bool CreateTablePM(IDictionary<string, object> data)
+    {
+        if (this._orm is null)
+            return false;
+
+        Dictionary<string, object> ValueSensor = [];
+        Dictionary<string, object> StatusSensor = [];
+        Dictionary<string, object> leakCheck = [];
+        Dictionary<string, object> recipe = [];
+        Dictionary<string, object> aoValue = [];
+
+        Dictionary<string, object> ffu = [];
+        Dictionary<string, object> mfc = [];
+        Dictionary<string, object> gaslineHeater = [];
+        Dictionary<string, object> bufferFoup = [];
+        Dictionary<string, object> avValue = [];
+
+
+
+        foreach (var item in data)
+        {
+            if (item.Value is not IDictionary<string, object> values)
+            {
+                switch (item.Key)
+                {
+                    case string s when s.EndsWith("Enable"):
+                        continue;
+                    case string s when s.StartsWith("LeakCheck"):
+                        leakCheck.Add(item.Key, item.Value);
+                        continue;
+                    default:
+                        recipe.Add(item.Key, item.Value);
+                        continue;
+                }
+            }
+
+            switch (item.Key)
+            {
+                case "APC":
+                case "APCVATGV":
+                case "BoatElevatorServo":
+                case "BoatRotationServo":
+                case "BufferServo":
+                case "Shutter":
+                    CreateTable(item.Key, values);
+                    continue;
+
+                case string s when s.startsWith("Trig"):
+                    if (item.Value is IDictionary<string, object> value)
+                        aoValue.Add(item.Key, value["AOValue"]);
+                    continue;
+
+                case string s when s.startsWith("FS"):
+                case string s1 when s1.startsWith("PG"):
+                case string s2 when s2.startsWith("PS"):
+                case string s3 when s3.startsWith("VG"):
+                    if (item.Value is IDictionary<string, object> vss)
+                        ValueSensor.Add(item.Key, vss["Value"]);
+                    continue;
+
+                case string s when s.StartsWith("Sensor"):
+                    if (item.Value is IDictionary<string, object> status)
+                        StatusSensor.Add(item.Key, status["Value"]);
+                    continue;
+                case string s when s.StartsWith("MFC"):
+                    if (item.Value is IDictionary<string, object> mfcs)
+                        mfcs.Foreach(t => mfc.Add($"{item.Key}_{t.Key}", t.Value));
+                    continue;
+                case string s when s.StartsWith("FFU"):
+                    if (item.Value is IDictionary<string, object> ffus)
+                        ffus.Foreach(t => ffu.Add($"{item.Key}_{t.Key}", t.Value));
+                    continue;
+                case string s when s.StartsWith("GaselineHeater"):
+                    if (item.Value is IDictionary<string, object> gaslines)
+                        gaslines.Foreach(t => gaslineHeater.Add($"{item.Key}_{t.Key}", t.Value));
+                    continue;
+                case string s when s.StartsWith("Valve"):
+                    if (item.Value is IDictionary<string, object> valves)
+                        valves.Foreach(t => avValue.Add($"{item.Key}_{t.Key}", t.Value));
+                    continue;
+                default:
+                    continue;
+            }
+        }
+        CreateTable("MFC", mfc);
+        CreateTable("FFU", ffu);
+        CreateTable("Valve", avValue);
+        CreateTable("GaselineHeater", gaslineHeater);
+        CreateTable("ValueSensor", ValueSensor);
+        CreateTable("StatusSensor", StatusSensor);
+        CreateTable("LeakCheck", leakCheck);
+        CreateTable("AoValue", aoValue);
+        CreateTable("Recipe", recipe);
+
+
+
+        return true;
+    }
+
+    public void CreateTableSystem(Dictionary<string, object> data)
+    {
+        if (_orm is null)
+            return;
+
+        Dictionary<string, object> systemCollection = [];
+        Dictionary<string, object> alarmCollection = [];
+
+        _orm.CreateTable<Heater>("Heater");
+        _orm.CreateTable<Stocker>("Stocker");
+        _orm.CreateTable<LoadPort>("LoadPort");
+        _orm.CreateTable<FIMS>("FIMS");
+
+        foreach (var item in data)
+        {
+            if (item.Value is not IDictionary<string, object> values)
+                continue;
+
+            switch (item.Key)
+            {
+                case "Boat":
+                case "CarrierRobot":
+                case "Scheduler":
+                case "WaferRobot":
+                    CreateTable(item.Key, values);
+                    continue;
+
+                case "System":
+                    if (values is not IDictionary<string, object> systems)
+                        continue;
+                    foreach (var system in systems)
+                    {
+                        switch (system.Key)
+                        {
+                            case string s when s.StartsWith("Heater"):
+                                continue;
+                            case string s when s.StartsWith("AlarmSignalHeater"):
+                                alarmCollection.Add(system.Key, ((IDictionary<string, object>)system.Value)["Value"] ??= false);
+                                continue;
+                            default:
+                                systemCollection.Add(system.Key, system.Value);
+                                break;
+                        }
+                    }
+                    continue;
+                default:
+                    break;
+            }
+
+            CreateTable("System", systemCollection);
+            CreateTable("AlarmSignalHeater", alarmCollection);
+        }
+    }
+
+    public bool InsertDataPM(IDictionary<string, object> data, Guid guid, DateTime time)
+    {
+        if (this._orm is null)
+            return false;
+
+        Dictionary<string, object> ValueSensor = [];
+        Dictionary<string, object> StatusSensor = [];
+        Dictionary<string, object> leakCheck = [];
+        Dictionary<string, object> recipe = [];
+        Dictionary<string, object> aoValue = [];
+
+        Dictionary<string, object> mfc = [];
+        Dictionary<string, object> ffu = [];
+        Dictionary<string, object> gaslineHeater = [];
+        Dictionary<string, object> bufferFoup = [];
+        Dictionary<string, object> avValue = [];
+        foreach (var item in data)
+        {
+            if (item.Value is not IDictionary<string, object> values)
+            {
+                switch (item.Key)
+                {
+                    case string s when s.EndsWith("Enable"):
+                        continue;
+                    case string s when s.StartsWith("LeakCheck"):
+                        leakCheck.Add(item.Key, item.Value);
+                        continue;
+                    default:
+                        recipe.Add(item.Key, item.Value);
+                        continue;
+                }
+            }
+
+            switch (item.Key)
+            {
+                case "APC":
+                case "APCVATGV":
+                case "BoatElevatorServo":
+                case "BoatRotationServo":
+                case "BufferServo":
+                case "Shutter":
+                    InsertData(item.Key, time, guid, values);
+                    continue;
+
+                case string s when s.startsWith("Trig"):
+                    if (item.Value is IDictionary<string, object> value)
+                        aoValue.Add(item.Key, value["AOValue"]);
+                    continue;
+
+                case string s when s.startsWith("FS"):
+                case string s1 when s1.startsWith("PG"):
+                case string s2 when s2.startsWith("PS"):
+                case string s3 when s3.startsWith("VG"):
+                    if (item.Value is IDictionary<string, object> vss)
+                        ValueSensor.Add(item.Key, vss["Value"]);
+                    continue;
+
+                //case string s when s.StartsWith("ValveAV"):
+                //    _orm.Insert<AvValue>("AvValue", CreateData<AvValue>(guid, time, item));
+                //    continue;
+
+                case string s when s.StartsWith("Sensor"):
+                    if (item.Value is IDictionary<string, object> status)
+                        StatusSensor.Add(item.Key, status["Value"]);
+                    continue;
+
+                //case string s when s.StartsWith("FFU"):
+                //    _orm.Insert<FFU>("FFU", CreateData<FFU>(guid, time, item));
+                //    continue;
+
+                //case string s when s.StartsWith("GaslineHeater"):
+                //    _orm.Insert<GaslineHeater>("GaslineHeater", CreateData<GaslineHeater>(guid, time, item));
+                //    continue;
+
+                case string s when s.StartsWith("MFC"):
+                    if (item.Value is IDictionary<string, object> mfcs)
+                        mfcs.Foreach(t => mfc.Add($"{item.Key}_{t.Key}", t.Value));
+                    //_orm.Insert<MFC>("MFC", CreateData<MFC>(guid, time, item));
+                    continue;
+
+                case string s when s.StartsWith("FFU"):
+                    if (item.Value is IDictionary<string, object> ffus)
+                        ffus.Foreach(t => ffu.Add($"{item.Key}_{t.Key}", t.Value));
+                    continue;
+                case string s when s.StartsWith("GaselineHeater"):
+                    if (item.Value is IDictionary<string, object> gaslines)
+                        gaslines.Foreach(t => gaslineHeater.Add($"{item.Key}_{t.Key}", t.Value));
+                    continue;
+                case string s when s.StartsWith("Valve"):
+                    if (item.Value is IDictionary<string, object> valves)
+                        valves.Foreach(t => avValue.Add($"{item.Key}_{t.Key}", t.Value));
+                    continue;
+
+                default:
+                    continue;
+            }
+        }
+
+        InsertData("StatusSensor", time, guid, StatusSensor);
+        InsertData("Recipe", time, guid, recipe);
+        InsertData("LeakCheck", time, guid, leakCheck);
+        InsertData("AoValue", time, guid, aoValue);
+        InsertData("MFC", time, guid, mfc);
+        InsertData("FFU", time, guid, ffu);
+        InsertData("Valve", time, guid, avValue);
+        InsertData("GaselineHeater", time, guid, gaslineHeater);
+
+        return true;
+    }
+
+    public void InsertDataSystem(Dictionary<string, object> data, Guid guid, DateTime time)
+    {
+        if (_orm is null)
+            return;
+
+        Dictionary<string, object> systemCollection = [];
+        Dictionary<string, object> alarmCollection = [];
+
+        foreach (var item in data)
+        {
+            if (item.Value is not IDictionary<string, object> values)
+                continue;
+
+            switch (item.Key)
+            {
+                case "Boat":
+                case "CarrierRobot":
+                case "Scheduler":
+                case "WaferRobot":
+                    InsertData(item.Key, time, guid, values);
+                    continue;
+
+                case "System":
+                    if (values is not IDictionary<string, object> systems)
+                        continue;
+                    foreach (var system in systems)
+                    {
+                        switch (system.Key)
+                        {
+                            case string s when s.StartsWith("Heater"):
+                                _orm.Insert("Heater", CreateData<Heater>(guid, time, item));
+                                continue;
+                            case string s when s.StartsWith("AlarmSignalHeater"):
+                                alarmCollection.Add(system.Key, ((IDictionary<string, object>)system.Value)["Value"] ??= false);
+                                continue;
+                            default:
+                                systemCollection.Add(system.Key, system.Value);
+                                break;
+                        }
+                    }
+                    continue;
+                case string s when s.StartsWith("Stocker"):
+                    _orm.Insert("Stocker", CreateData<Stocker>(guid, time, item));
+                    continue;
+                case string s when s.StartsWith("LP"):
+                    continue;
+                case string s when s.StartsWith("FIMS"):
+                    continue;
+
+                default:
+                    break;
+            }
+        }
+
+        InsertData("System", time, guid, systemCollection);
+        InsertData("AlarmSignalHeater", time, guid, alarmCollection);
+    }
+
+
+    private static T? CreateData<T>(Guid guid, DateTime time, KeyValuePair<string, object> input) where T : class, new()
+    {
+        if (input.Value is not IDictionary<string, object> values)
+            return null;
+
+        T source = new();
+        if (source is not IBasicInfo basicInfo)
+            return null;
+
+        basicInfo.UID = guid;
+        basicInfo.Time = time;
+        basicInfo.Name = input.Key;
+
+        DicToClass(ref source, values);
+        return source;
+    }
+
+    private static void DicToClass<T>(ref T input, IDictionary<string, object> source)
+    {
+        if (input is null)
+            return;
+
+        foreach (PropertyInfo property in input.GetType().GetProperties())
+        {
+            if (!source.TryGetValue(property.Name, out object? value))
+                continue;
+            property.SetValue(input, value);
+        }
+    }
+
+    private void CreateTable(string tableName, IDictionary<string, object> source)
+    {
+        if (_orm is null || _orm.Client is null || source is null)
+            return;
+
+        DynamicProperyBuilder builder = _orm.Client.DynamicBuilder().CreateClass(tableName, new SugarTable());
+        builder.CreateProperty("UID", typeof(Guid), new SugarColumn() { });
+        builder.CreateProperty("time", typeof(DateTime), new SugarColumn() { });
+        source.Foreach(t => builder.CreateProperty(t.Key.Replace('.', '_'), t.Value?.GetType(), new SugarColumn() { IsNullable = true }));
+
+        _orm.Client.CodeFirst.InitTables(builder.BuilderType());
+    }
+
+    public void CreateTableRaw(string tableName, IDictionary<string, object> source)
+    {
+        if (_orm is null || _orm.Client is null || source is null)
+            return;
+
+        DynamicProperyBuilder builder = _orm.Client.DynamicBuilder().CreateClass(tableName, new SugarTable());
+        //builder.CreateProperty("UID", typeof(Guid), new SugarColumn() { });
+        //builder.CreateProperty("time", typeof(DateTime), new SugarColumn() { });
+        source.Foreach(t => builder.CreateProperty(t.Key.Replace('.', '_'), t.Value?.GetType(), new SugarColumn() { IsNullable = true }));
+
+        _orm.Client.CodeFirst.InitTables(builder.BuilderType());
+    }
+
+    public void CreateTableRaw(string tableName, IList<DbColumnInfo> source)
+    {
+        if (_orm is null || _orm.Client is null || source is null)
+            return;
+
+        DynamicProperyBuilder builder = _orm.Client.DynamicBuilder().CreateClass(tableName, new SugarTable());
+
+        foreach (var t in source)
+        {
+
+
+            Type type = t.DataType switch
+            {
+                "float4" => typeof(float),
+                "float8"=>typeof(double),
+                "bool" => typeof(bool),
+                "int4" => typeof(int),
+                "int8" => typeof(long),
+                "text" => typeof(char[]),
+                "varchar"=> typeof(char[]),
+                "timestamp" => typeof(DateTime),
+                "time" => typeof(TimeSpan),
+                _ => typeof(object),
+            };
+
+
+            if (t.DataType == "text"||t.DataType== "varchar")
+                builder.CreateProperty(t.DbColumnName.Replace('.', '_'), type, new SugarColumn() { IsNullable = true, Length = 1000 });
+            else
+                builder.CreateProperty(t.DbColumnName.Replace('.', '_'), type, new SugarColumn() { IsNullable = true });
+            //$"\"{t.DbColumnName.Replace('.', '_')}\""
+        }
+
+        //source.Foreach(t => builder.CreateProperty(t.DbColumnName.Replace('.', '_'), t.PropertyType, new SugarColumn() { IsNullable = true }));
+
+        _orm.Client.CodeFirst.InitTables(builder.BuilderType());
+    }
+
+    private int InsertData(string tableName, DateTime dateTime, Guid guid, IDictionary<string, object> source)
+    {
+        if (_orm is null || _orm.Client is null)
+            return 0;
+
+        Dictionary<string, object> column = new() { ["UID"] = guid, ["time"] = dateTime, };
+        source.Foreach(t => column.Add(t.Key, t.Value));
+
+        return _orm.Client.Insertable(column).AS(tableName).ExecuteCommand();
+    }
+
+    public int InsertDataRaw(string tableName, IDictionary<string, object> source)
+    {
+        if (_orm is null || _orm.Client is null)
+            return 0;
+        _orm.Client.CurrentConnectionConfig.MoreSettings ??= new();
+        _orm.Client.CurrentConnectionConfig.MoreSettings.IsCorrectErrorSqlParameterName = false;
+
+        Dictionary<string, object> column = [];
+        //source.Foreach(t => column.Add(t.Key.Replace('.', '_'), t.Value));
+        foreach (var t in source)
+        {
+            if (t.Value is null)
+            {
+                continue;
+            }
+            if (t.Key.contains("-"))
+                _orm.Client.CurrentConnectionConfig.MoreSettings.IsCorrectErrorSqlParameterName = true;
+            column.Add(t.Key.Replace('.', '_'), t.Value);
+
+        }
+
+
+        return _orm.Client.Insertable(column).AS(tableName).ExecuteCommand();
+    }
+}

+ 32 - 28
DataBase/SqlSugarORM/SqlSugarCustom.cs

@@ -13,7 +13,7 @@ public class SqlSugarCustom
 
     #region Internal
     private IOrmProvider? _provider;
-    public SqlSugarClient? _Client;
+    public SqlSugarClient? Client;
     private bool disposedValue;
     private readonly EventQueue<(string, DateTime, LogLevel)> _logQueue;
     private void LogQueueHandler((string log, DateTime time, LogLevel level) logItem)
@@ -43,7 +43,7 @@ public class SqlSugarCustom
 
     public bool Open(string connectionString, SqlSugar.DbType dbType, bool isAutoConnection)
     {
-        if (this._Client is not null)
+        if (this.Client is not null)
             return false;
 
         ConnectionConfig config = new()
@@ -56,7 +56,7 @@ public class SqlSugarCustom
         {
             SqlSugarClient Db = new(config, Config);
             Db.DbMaintenance.CreateDatabase();
-            this._Client = Db;
+            this.Client = Db;
         }
         catch
         {
@@ -67,7 +67,7 @@ public class SqlSugarCustom
 
     public bool CreateDataBase(string dbName)
     {
-        if (this._Client is null)
+        if (this.Client is null)
             return false;
 
         if (string.IsNullOrEmpty(dbName))
@@ -75,7 +75,7 @@ public class SqlSugarCustom
 
         try
         {
-            this._Client.DbMaintenance.CreateDatabase(dbName);
+            this.Client.DbMaintenance.CreateDatabase(dbName);
         }
         catch
         {
@@ -88,15 +88,15 @@ public class SqlSugarCustom
 
     public bool CreateTable<T>(string? tableName)
     {
-        if (this._Client is null)
+        if (this.Client is null)
             return false;
 
         try
         {
             if (string.IsNullOrEmpty(tableName))
-                this._Client.CodeFirst.InitTables<T>();
+                this.Client.CodeFirst.InitTables<T>();
             else
-                this._Client.CodeFirst.As(typeof(T), tableName).InitTables<T>();
+                this.Client.CodeFirst.As(typeof(T), tableName).InitTables<T>();
         }
         catch
         {
@@ -110,11 +110,13 @@ public class SqlSugarCustom
 
     public bool Insert<T>(T data) where T : class, new()
     {
-        if (this._Client is null)
+        if (this.Client is null)
+            return false;
+        if (data is null)
             return false;
         try
         {
-            this._Client.Insertable(data).ExecuteCommand();
+            this.Client.Insertable(data).ExecuteCommand();
         }
         catch
         {
@@ -126,16 +128,18 @@ public class SqlSugarCustom
         return true;
     }
 
-    public bool Insert<T>(string tablename, T data) where T : class, new()
+    public bool Insert<T>(string tablename, T? data) where T : class, new()
     {
-        if (this._Client is null)
+        if (this.Client is null)
+            return false;
+        if (data is null)
             return false;
         try
         {
             if (string.IsNullOrEmpty(tablename))
-                this._Client.Insertable(data).ExecuteCommand();
+                this.Client.Insertable(data).ExecuteCommand();
             else
-                this._Client.Insertable(data).AS(tablename).ExecuteCommand();
+                this.Client.Insertable(data).AS(tablename).ExecuteCommand();
         }
         catch
         {
@@ -152,14 +156,14 @@ public class SqlSugarCustom
 
     public async Task<bool> Query<T>(Action<List<T>> results)
     {
-        if (this._Client is null)
+        if (this.Client is null)
             return false;
 
         return await Task<bool>.Factory.StartNew(() =>
         {
             try
             {
-                results?.Invoke(this._Client.Queryable<T>().ToList());
+                results?.Invoke(this.Client.Queryable<T>().ToList());
             }
             catch
             {
@@ -172,7 +176,7 @@ public class SqlSugarCustom
 
     public async Task<bool> Query<T>(string tableName, Action<List<T>> results)
     {
-        if (this._Client is null)
+        if (this.Client is null)
             return false;
 
         return await Task<bool>.Factory.StartNew(() =>
@@ -180,9 +184,9 @@ public class SqlSugarCustom
             try
             {
                 if (string.IsNullOrEmpty(tableName))
-                    results?.Invoke(this._Client.Queryable<T>().ToList());
+                    results?.Invoke(this.Client.Queryable<T>().ToList());
                 else
-                    results?.Invoke(this._Client.Queryable<T>().AS(tableName).ToList());
+                    results?.Invoke(this.Client.Queryable<T>().AS(tableName).ToList());
             }
             catch
             {
@@ -195,14 +199,14 @@ public class SqlSugarCustom
 
     public async Task<bool> Query<T>(Expression<Func<T, bool>> expression, Action<List<T>> results)
     {
-        if (this._Client is null)
+        if (this.Client is null)
             return false;
 
         return await Task<bool>.Factory.StartNew(() =>
             {
                 try
                 {
-                    results?.Invoke(this._Client.Queryable<T>().Where(expression).ToList());
+                    results?.Invoke(this.Client.Queryable<T>().Where(expression).ToList());
                 }
                 catch
                 {
@@ -215,7 +219,7 @@ public class SqlSugarCustom
 
     public async Task<bool> Query<T>(string tableName, Expression<Func<T, bool>> expression, Action<List<T>> results)
     {
-        if (this._Client is null)
+        if (this.Client is null)
             return false;
 
         return await Task<bool>.Factory.StartNew(() =>
@@ -223,9 +227,9 @@ public class SqlSugarCustom
               try
               {
                   if (string.IsNullOrEmpty(tableName))
-                      results?.Invoke(this._Client.Queryable<T>().Where(expression).ToList());
+                      results?.Invoke(this.Client.Queryable<T>().Where(expression).ToList());
                   else
-                      results?.Invoke(this._Client.Queryable<T>().AS(tableName).Where(expression).ToList());
+                      results?.Invoke(this.Client.Queryable<T>().AS(tableName).Where(expression).ToList());
               }
               catch
               {
@@ -242,11 +246,11 @@ public class SqlSugarCustom
 
     public bool Delete<T>(string tableName, Expression<Func<T, bool>> expression) where T : class, new()
     {
-        if (this._Client is null)
+        if (this.Client is null)
             return false;
         try
         {
-            this._Client.Deleteable<T>().AS(tableName).Where(expression).ExecuteCommand();
+            this.Client.Deleteable<T>().AS(tableName).Where(expression).ExecuteCommand();
         }
         catch
         {
@@ -265,8 +269,8 @@ public class SqlSugarCustom
                 while (_logQueue is not null && _logQueue.Count != 0)
                     Thread.Sleep(200);
 
-                this._Client?.Dispose();
-                this._Client = null;
+                this.Client?.Dispose();
+                this.Client = null;
                 this._logQueue?.Dispose();
                 this._provider = null;
             }

+ 433 - 22
Test/DBTest.cs

@@ -1,39 +1,450 @@
 using DataService;
+using DB_Proxima;
+using Dm.util;
+using Mapster;
+using Newtonsoft.Json.Linq;
+using ORM;
 using SqlSugar;
+using SqlSugar.Extensions;
 using SqlSugarORM;
+using System;
+using System.Diagnostics;
+using System.Dynamic;
+using System.Numerics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
 using System.Text.Json;
+using Universal;
 
-namespace Test
+namespace Test;
+
+internal class DBTest
 {
-    internal class DBTest
+
+    private SqlSugarCustom _orm;
+
+    public bool Initialize()
     {
-        public static void Test()
-        {
-            SqlSugarCustom orm = new();
+        _orm = new SqlSugarCustom();
+        _orm.CreateDataBase("DBTest");
+        _orm.Initialize(null);
+        string dbString = "Database=DBTest;Password=123456;Host=localhost;Username=postgres;Persist Security Info=True";
+        return _orm.Open(dbString, SqlSugar.DbType.PostgreSQL, true);
 
-            orm.Initialize(null);
-            string dbString = "Database=thermaldb;Password=123456;Host=localhost;Username=postgres;Persist Security Info=True";
-            //string dbString = "Database=Kepler;Password=123456;Host=localhost;Username=postgres;Persist Security Info=True";
-            if (!orm.Open(dbString, DbType.PostgreSQL, true))
-                return;
+    }
+
+    public void TestRaw()
+    {
 
-            dynamic[] t = orm._Client!.Queryable<dynamic>().AS("\"20250627.System\"").Take(1).ToArray();
-            //dynamic[] t = orm._Client!.Queryable<dynamic>().AS("\"20250626.Data\"").Take(1).ToArray();
+        SqlSugarCustom orm = new();
 
-            GeneralProcessData processData = new(0);
-            if (!processData.ToDictionary(t, out Dictionary<string, object>? outputs) || outputs is null)
+        orm.Initialize(null);
+        string dbString = "Database=FROMTIN;Password=123456;Host=localhost;Username=postgres;Persist Security Info=True";
+        //string dbString = "Database=Kepler;Password=123456;Host=localhost;Username=postgres;Persist Security Info=True";
+
+        if (!orm.Open(dbString, SqlSugar.DbType.PostgreSQL, true))
+            return;
+
+        List<DbTableInfo> tables = orm.Client.DbMaintenance.GetTableInfoList();
+
+        Stopwatch sw = new();
+        sw.Start();
+        int i = 0;
+        Parallel.ForEach(tables, table =>
+        {
+            string localName = table.Name.Replace('.', '_');
+            if (localName== "Recipe_History")
                 return;
+            if (localName == "event_data")
+                return;
+
+            var client = orm.Client.CopyNew();
+
+            List<DbColumnInfo> dbColumns = client.DbMaintenance.GetColumnInfosByTableName(table.Name);
+            RemoteToLocal remoteToLocal = new();
+            //remoteToLocal.Initialize("DBTestKepler", "123456", "localhost", "postgres");
+            remoteToLocal.Initialize("DBTestTIN", "123456", "localhost", "postgres");
+            remoteToLocal.CreateTableRaw(localName, dbColumns);
+
+            int totalCount = 0;
+            int totalPage = 0;
+            int currentPage = 1;
+
+            int line = 0;
+            lock (this)
+                line = i++;
+            do
+            {
+                dynamic[] dataCollection = client.Queryable<dynamic>().AS($"\"{table.Name}\"").ToPageList(currentPage, 100, ref totalCount, ref totalPage).ToArray();
+                //Console.SetCursorPosition(0, Console.CursorTop - 1);
+                lock (this)
+                {
+                    Console.SetCursorPosition(0, line);
+                    Console.WriteLine($"{table.Name.PadRight(35)} Columns {dbColumns.Count.ToString().PadRight(15)}  100 Rows / page     Page {currentPage}/{totalPage}");
+                }
+                foreach (dynamic data in dataCollection)
+                {
+                    if (data is IDictionary<string, object> rawData)
+                        remoteToLocal.InsertDataRaw(localName, rawData);
+                }
+            } while (++currentPage <= totalPage);
+        });
+
+
+        //foreach (DbTableInfo table in tables)
+        //{
+        //    string localName = table.Name.Replace('.', '_');
+        //    List<DbColumnInfo> dbColumns = orm.Client.DbMaintenance.GetColumnInfosByTableName(table.Name);
+        //    RemoteToLocal remoteToLocal = new();
+        //    remoteToLocal.Initialize("DBTestKepler", "123456", "localhost", "postgres");
+        //    remoteToLocal.CreateTableRaw(localName, dbColumns);
+
+        //    int totalCount = 0;
+        //    int totalPage = 0;
+        //    int currentPage = 1;
+
+
+        //    Console.WriteLine($"Move Table {localName} total column {dbColumns.Count}");
+        //    Console.WriteLine();
+        //    do
+        //    {
+        //        dynamic[] dataCollection = orm.Client!.Queryable<dynamic>().AS($"\"{table.Name}\"").ToPageList(currentPage, 100, ref totalCount, ref totalPage).ToArray();
+        //        Console.SetCursorPosition(0, Console.CursorTop - 1);
+        //        Console.WriteLine($"Page {currentPage}/{totalPage}");
+        //        foreach (dynamic data in dataCollection)
+        //        {
+        //            if (data is IDictionary<string, object> rawData)
+        //                remoteToLocal.InsertDataRaw(localName, rawData);
+        //        }
+        //    } while (++currentPage <= totalPage);
+        //}
+
+        sw.Stop();
+        Console.SetCursorPosition(0, ++i);
+
+        Console.WriteLine($"{sw.Elapsed.TotalSeconds} seconds");
+
+    }
+
+    public void TestOthers()
+    {
+        SqlSugarCustom orm = new();
+
+        orm.Initialize(null);
+        string dbString = "Database=tin01_db;Password=123456;Host=10.4.6.48;Username=postgres;Persist Security Info=True";
+
+        if (!orm.Open(dbString, SqlSugar.DbType.PostgreSQL, true))
+            return;
+
+        dynamic system = orm.Client!.Queryable<dynamic>().AS("\"20250708.System\"").First();
+        dynamic pm = orm.Client!.Queryable<dynamic>().AS("\"20250708.PM1\"").First();
+
+        GeneralProcessData processData = new(0);
+        if (!processData.ToDictionary(system, out Dictionary<string, object>? systemDic) || systemDic is null)
+            return;
+        if (!processData.ToDictionary(pm, out Dictionary<string, object>? pmDic) || pmDic is null)
+            return;
+        if (pmDic["PM1"] is not IDictionary<string, object> data)
+            return;
+
+        RemoteToLocal remoteToLocal = new();
+        remoteToLocal.Initialize("DBTest", "123456", "localhost", "postgres");
+        //remoteToLocal.CreateTableSystem(systemDic);
+        remoteToLocal.CreateTablePM(data);
+        Stopwatch sw = new();
+        sw.Start();
+        int totalCount = 0;
+        int totalPage = 0;
+        int currentPage = 1;
+        do
+        {
+            Console.WriteLine($"page {currentPage}");
+            foreach (var item in orm.Client!.Queryable<dynamic>().AS("\"20250708.PM1\"").ToPageList(currentPage, 1000, ref totalCount, ref totalPage).ToArray())
+            {
+
+                if (!processData.ToDictionary(item, out Dictionary<string, object>? pms) || pms is null)
+                    return;
+
+                DateTime time = LongToDateTime(pms["time"]).Value;
+                Guid guid = Guid.NewGuid();
+
+                if (pms["PM1"] is not IDictionary<string, object> pmc)
+                    return;
+
+                remoteToLocal.InsertDataPM(pmc, guid, time);
+
+            }
+        } while (++currentPage <= totalPage);
+
+        //foreach (dynamic item in orm.Client!.Queryable<dynamic>().AS("\"20250708.PM1\"").ToArray())
+        //{
+        //    if (!processData.ToDictionary(item, out Dictionary<string, object>? pms) || pms is null)
+        //        return;
+
+        //    DateTime time = LongToDateTime(pms["time"]).Value;
+        //    Guid guid = Guid.NewGuid();
+
+        //    if (pms["PM1"] is not IDictionary<string, object> pmc)
+        //        return;
+
+        //    remoteToLocal.InsertDataPM(pmc, guid, time);
+        //}
+        sw.Stop();
+        Console.WriteLine(sw.Elapsed.TotalSeconds);
+    }
+
+    //public void Test(IDictionary<string, object> data, Guid guid, DateTime time)
+    public void Test()
+    {
+        SqlSugarCustom orm = new();
+        orm.Initialize(null);
+
+        string dbString = "Database=tin01_db;Password=123456;Host=10.4.6.48;Username=postgres;Persist Security Info=True";
+        if (!orm.Open(dbString, SqlSugar.DbType.PostgreSQL, true))
+            return;
+
+        dynamic t = orm.Client!.Queryable<dynamic>().AS("\"20250708.PM1\"").First();
+        GeneralProcessData processData = new(0);
+        if (!processData.ToDictionary(t, out Dictionary<string, object>? outputs) || outputs is null)
+            return;
+
+        DateTime time = LongToDateTime(outputs["time"]).Value;
+
+        if (outputs["PM1"] is not IDictionary<string, object> data)
+            return;
+        Guid guid = Guid.NewGuid();
+
+        _orm.CreateTable<FFU>("FFU");
+        _orm.CreateTable<MFC>("MFC");
+        _orm.CreateTable<GaslineHeater>("GaslineHeater");
+        _orm.CreateTable<BufferFoup>("GaslineHeater");
+        _orm.CreateTable<AvValue>("AvValue");
+
+        Dictionary<string, object> ValueSensor = [];
+        Dictionary<string, object> StatusSensor = [];
+        Dictionary<string, object> leakCheck = [];
+        Dictionary<string, object> recipe = [];
+        Dictionary<string, object> aoValue = [];
+
+
+        foreach (var item in data)
+        {
+            if (item.Value is not IDictionary<string, object> values)
+            {
+                switch (item.Key)
+                {
+                    case string s when s.EndsWith("Enable"):
+                        continue;
+                    case string s when s.startsWith("LeakCheck"):
+                        leakCheck.Add(item.Key, item.Value);
+                        continue;
+                    default:
+                        recipe.Add(item.Key, item.Value);
+                        continue;
+                }
+            }
 
-            
-            foreach (var item in outputs)
+            switch (item.Key)
             {
-                //string s = JsonSerializer.Serialize(item);
-                //Console.WriteLine(s);
-     
+                case "APC":
+                case "APCVATGV":
+                case "BoatElevatorServo":
+                case "BoatRotationServo":
+                case "BufferServo":
+                case "Shutter":
+                    CreateTable(item.Key, values);
+                    InsertData(item.Key, time, guid, values);
+                    continue;
+
+                case string s when s.startsWith("Trig"):
+                    if (item.Value is IDictionary<string, object> value)
+                        aoValue.Add(item.Key, value["AOValue"]);
+                    continue;
+
+                case string s when s.startsWith("FS"):
+                case string s1 when s1.startsWith("PG"):
+                case string s2 when s2.startsWith("PS"):
+                case string s3 when s3.startsWith("VG"):
+                    if (item.Value is IDictionary<string, object> vss)
+                        ValueSensor.Add(item.Key, vss["Value"]);
+                    continue;
+
+                case string s when s.startsWith("ValveAV"):
+                    _orm.Insert<AvValue>("AvValue", CreateData<AvValue>(guid, time, item));
+                    continue;
+
+                case string s when s.startsWith("Sensor"):
+                    if (item.Value is IDictionary<string, object> status)
+                        StatusSensor.Add(item.Key, status["Value"]);
+                    continue;
+
+                case string s when s.startsWith("FFU"):
+                    _orm.Insert<FFU>("FFU", CreateData<FFU>(guid, time, item));
+                    continue;
+
+                case string s when s.startsWith("GaslineHeater"):
+                    _orm.Insert<GaslineHeater>("GaslineHeater", CreateData<GaslineHeater>(guid, time, item));
+                    continue;
+
+                case string s when s.startsWith("MFC"):
+                    _orm.Insert<MFC>("MFC", CreateData<MFC>(guid, time, item));
+                    continue;
+                default:
+                    continue;
             }
-            //int totalCount = 0;
-            //int totalPages = 0;
-            //dynamic[] page = orm._Client!.Queryable<dynamic>().AS("\"20250626.Data\"").ToPageList(1, 1000, ref totalCount, ref totalPages).ToArray();
         }
+
+        CreateTable("ValueSensor", ValueSensor);
+        CreateTable("StatusSensor", StatusSensor);
+        CreateTable("Recipe", recipe);
+        CreateTable("LeakCheck", leakCheck);
+        CreateTable("AoValue", aoValue);
+
+        InsertData("ValueSensor", time, guid, ValueSensor);
+        InsertData("StatusSensor", time, guid, StatusSensor);
+        InsertData("Recipe", time, guid, recipe);
+        InsertData("LeakCheck", time, guid, leakCheck);
+        InsertData("AoValue", time, guid, aoValue);
     }
+
+    public void TestSystem()
+    {
+        SqlSugarCustom orm = new();
+
+        orm.Initialize(null);
+        string dbString = "Database=tin01_db;Password=123456;Host=10.4.6.48;Username=postgres;Persist Security Info=True";
+
+        if (!orm.Open(dbString, SqlSugar.DbType.PostgreSQL, true))
+            return;
+
+        dynamic t = orm.Client!.Queryable<dynamic>().AS("\"20250708.System\"").First();
+        GeneralProcessData processData = new(0);
+        if (!processData.ToDictionary(t, out Dictionary<string, object>? outputs) || outputs is null)
+            return;
+
+        DateTime time = LongToDateTime(outputs["time"]).Value;
+        Guid guid = Guid.NewGuid();
+
+        Dictionary<string, object> systemCollection = [];
+        Dictionary<string, object> alarmCollection = [];
+
+        _orm.CreateTable<DB_Proxima.Heater>("Heater");
+        _orm.CreateTable<Stocker>("Stocker");
+        _orm.CreateTable<LoadPort>("LoadPort");
+        _orm.CreateTable<FIMS>("FIMS");
+
+
+        foreach (var item in outputs)
+        {
+            if (item.Value is not IDictionary<string, object> values)
+                continue;
+
+            switch (item.Key)
+            {
+                case "Boat":
+                case "CarrierRobot":
+                case "Scheduler":
+                case "WaferRobot":
+                    CreateTable(item.Key, values);
+                    InsertData(item.Key, time, guid, values);
+                    continue;
+
+                case "System":
+                    if (values is not IDictionary<string, object> systems)
+                        continue;
+                    foreach (var system in systems)
+                    {
+                        switch (system.Key)
+                        {
+                            case string s when s.startsWith("Heater"):
+                                _orm.Insert<DB_Proxima.Heater>("Heater", CreateData<DB_Proxima.Heater>(guid, time, item));
+                                continue;
+                            case string s when s.startsWith("AlarmSignalHeater"):
+                                alarmCollection.Add(system.Key, ((IDictionary<string, object>)system.Value)["Value"] ??= false);
+                                continue;
+                            default:
+                                systemCollection.Add(system.Key, system.Value);
+                                break;
+                        }
+                    }
+                    continue;
+                case string s when s.startsWith("Stocker"):
+                    _orm.Insert<Stocker>("Stocker", CreateData<Stocker>(guid, time, item));
+                    continue;
+                case string s when s.startsWith("LP"):
+                    continue;
+                case string s when s.startsWith("FIMS"):
+                    continue;
+
+                default:
+                    break;
+            }
+        }
+
+
+        CreateTable("System", systemCollection);
+        CreateTable("AlarmSignalHeater", alarmCollection);
+
+        InsertData("System", time, guid, systemCollection);
+        InsertData("AlarmSignalHeater", time, guid, alarmCollection);
+    }
+
+
+    public static T? CreateData<T>(Guid guid, DateTime time, KeyValuePair<string, object> input) where T : class, new()
+    {
+        if (input.Value is not IDictionary<string, object> values)
+            return null;
+
+        T source = new();
+        if (source is not IBasicInfo basicInfo)
+            return null;
+
+        basicInfo.UID = guid;
+        basicInfo.Time = time;
+        basicInfo.Name = input.Key;
+
+        DicToClass(ref source, values);
+        return source;
+    }
+
+
+    public static DateTime? LongToDateTime(object o)
+    {
+        if (o is not long l)
+            return null;
+        return new(l);
+    }
+
+    public static void DicToClass<T>(ref T input, IDictionary<string, object> source)
+    {
+        foreach (PropertyInfo property in input.GetType().GetProperties())
+        {
+            if (!source.TryGetValue(property.Name, out object value) || value is null)
+                continue;
+            property.SetValue(input, value);
+        }
+    }
+
+    public void CreateTable(string tableName, IDictionary<string, object> source)
+    {
+        DynamicProperyBuilder builder = _orm.Client.DynamicBuilder().CreateClass(tableName, new SugarTable());
+        builder.CreateProperty("UID", typeof(Guid), new SugarColumn() { IsPrimaryKey = true });
+        builder.CreateProperty("time", typeof(DateTime), new SugarColumn() { });
+        foreach (var item in source)
+            builder.CreateProperty(item.Key, item.Value.GetType(), new SugarColumn() { IsNullable = true });
+        var type = builder.BuilderType();
+        _orm.Client.CodeFirst.InitTables(type);
+    }
+
+    public int InsertData(string tableName, DateTime dateTime, Guid guid, IDictionary<string, object> source)
+    {
+        var dc = new Dictionary<string, object>();
+        dc.Add("UID", guid);
+        dc.Add("time", dateTime);
+        foreach (var item in source)
+            dc.Add(item.Key, item.Value);
+
+        return _orm.Client.Insertable(dc).AS(tableName).ExecuteCommand();
+    }
+
 }

+ 125 - 2
Test/Program.cs

@@ -1,11 +1,134 @@
-namespace Test;
+using Microsoft.Win32;
+using System.Data;
+using System.Diagnostics;
+using System.Text;
+
+namespace Test;
 
 internal class Program
 {
     static void Main()
     {
-        DBTest.Test();
+        int[,] timeStamp = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
+        int s = timeStamp[0, 1];
+        int length = timeStamp.Length;
+        foreach (var item in timeStamp)
+        {
+
+        }
+        var t = timeStamp.GetValue(0,0);
+
+        //DBTest test = new();
+        //test.Initialize();
+        //test.Test();
+        //test.TestSystem();
+        //test.TestOthers();
+        //test.TestRaw();
+
+        ProcessTest processTest = new();
+        processTest.Initialize();
+        processTest.BackUp("10.4.6.48", 5432, "postgres", "123456", "D://source_db_dump.custom", "tin01_db");
+        //processTest.BackUpSingleTable("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "FROMTIN", "20250630.PM1");
+        //processTest.BackUpByDateTime("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "FROMTIN", "20250630");
+        processTest.Restore("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "DBTestTIN");
+    }
+}
+
+internal class ProcessTest
+{
+    //HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql*
+    private string? _binPath;
+    private string? pg_dump;
+    private string? pg_restore;
+
+    public bool Initialize()
+    {
+        RegistryKey key = Registry.LocalMachine;
+        key = key.OpenSubKey("SOFTWARE\\PostgreSQL\\Installations");
+
+        if (key is null)
+            key = key.OpenSubKey("SOFTWARE\\WOW6432Node\\PostgreSQL\\Installations");
+
+        if (key is null)
+            return false;
+
+        if (key.GetSubKeyNames().FirstOrDefault(t => t.Contains("postgresql")) is not string nextKey)
+            return false;
+
+        key = key.OpenSubKey(nextKey);
+        if (key.GetValue("Base Directory") is not string path)
+            return false;
+
+        this.pg_dump = Path.Combine(path, "bin", "pg_dump.exe");
+        this.pg_restore = Path.Combine(path, "bin", "pg_restore.exe");
+
+        return true;
+    }
+
+    public bool BackUp(string serverAddress, int port, string userName, string password, string savePath, string dbName)
+    {
+        if (string.IsNullOrEmpty(this.pg_dump))
+            return false;
+
+        Process process = new Process();
+        process.StartInfo.Environment.Add("PGPASSWORD", password);
+        process.StartInfo.FileName = this.pg_dump;
+        process.StartInfo.Arguments = string.Format($"-h {serverAddress} -p {port} -U {userName} -F c -v -f \"{savePath}\" {dbName}");
+        process.StartInfo.CreateNoWindow = false;
+        process.Start();
+        process.WaitForExit();
+        return true;
+    }
+
+    public bool Restore(string serverAddress, int port, string userName, string password, string savePath, string dbName)
+    {
+        if (string.IsNullOrEmpty(this.pg_restore))
+            return false;
+
+        Process process = new Process();
+        process.StartInfo.Environment.Add("PGPASSWORD", password);
+        process.StartInfo.FileName = this.pg_restore;
+        process.StartInfo.Arguments = string.Format($"-h {serverAddress} -p {port} -U {userName} -v -d {dbName} --clean \"{savePath}\"");
+        process.StartInfo.CreateNoWindow = false;
+        process.Start();
+        process.WaitForExit();
+
+        return true;
+    }
+
+    public bool BackUpSingleTable(string serverAddress, int port, string userName, string password, string savePath, string dbName, string tableName)
+    {
+        if (string.IsNullOrEmpty(this.pg_dump))
+            return false;
+
+        Process process = new Process();
+        process.StartInfo.RedirectStandardOutput = true;
 
+        process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
+        process.StartInfo.Environment.Add("PGPASSWORD", password);
+        process.StartInfo.FileName = this.pg_dump;
+        process.StartInfo.Arguments = string.Format($"-h {serverAddress} -p {port} -U {userName} -F c -v -f \"{savePath}\" --table \"{tableName}\" {dbName}");
+        process.StartInfo.CreateNoWindow = false;
+        process.Start();
+        process.WaitForExit();
+        return true;
+    }
+
+    public bool BackUpByDateTime(string serverAddress, int port, string userName, string password, string savePath, string dbName, string time)
+    {
+        if (string.IsNullOrEmpty(this.pg_dump))
+            return false;
 
+        Process process = new Process();
+        process.StartInfo.RedirectStandardOutput = true;
+        process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
+        process.StartInfo.Environment.Add("PGPASSWORD", password);
+        process.StartInfo.FileName = this.pg_dump;
+        process.StartInfo.Arguments = string.Format($"-h {serverAddress} -p {port} -U {userName} -F c -v -f \"{savePath}\" --table {time}* {dbName}");
+        process.StartInfo.CreateNoWindow = false;
+        process.Start();
+        process.WaitForExit();
+        return true;
     }
+
 }

+ 0 - 210
Test/ProximaPM.cs

@@ -1,210 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection.Metadata.Ecma335;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Test;
-
-public class PM1
-{
-    public APC APC { get; set; }
-    public Shutter Shutter { get; set; }
-    public APCVATGV APCVATGV { get; set; }
-    public LeakCheck LeakCheck { get; set; }
-    public BoatElevatorServo BoatElevatorServo { get; set; }
-    public BoatRotationServo BoatRotationServo { get; set; }
-    public Recipe RecipeInfo { get; set; }
-
-    public DataCollection<float> FS { get; set; }
-    public DataCollection<float> VG { get; set; }
-    public DataCollection<float> PGPS { get; set; }
-    public DataCollection<bool> Sensor { get; set; }
-    public DataCollection<float> AOValue { get; set; }
-    public DataCollection<PairValue<FFU>> FFU { get; set; }
-    public DataCollection<PairValue<MFC>> MFC { get; set; }
-    public DataCollection<PairValue<bool>> AVValve { get; set; }
-    public DataCollection<PairValue<float>> IoValve { get; set; }
-    public DataCollection<PairValue<float>> GaslineHeater { get; set; }
-}
-
-public class APC
-{
-    public bool IsError { get; set; }
-    public float HomingStatus { get; set; }
-    public float Interlock1 { get; set; }
-    public float Interlock2 { get; set; }
-    public float Interlock3 { get; set; }
-    public float InterlockConstantOfInterlock3 { get; set; }
-    public float ModeFeedback { get; set; }
-    public float ModeSetPoint { get; set; }
-    public float P1SensorOffsetSetting { get; set; }
-    public float PositionFeedback { get; set; }
-    public float PositionSetPoint { get; set; }
-    public float PosMonOffsetSetting { get; set; }
-    public float Pressure1Feedback { get; set; }
-    public float Pressure2Feedback { get; set; }
-    public float PressureSetPoint { get; set; }
-    public float SelectedControllerFeedback { get; set; }
-    public float SlowRateSetPoint { get; set; }
-    public float SlowVacuumModeSetting { get; set; }
-    public float ValveStatusThreshold { get; set; }
-
-}
-
-public class APCVATGV
-{
-    public bool IsError { get; set; }
-    public float InterlockConstantOfInterlock3 { get; set; }
-    public float ModeSetPoint { get; set; }
-    public float P1SensorOffsetSetting { get; set; }
-    public float PositionFeedback { get; set; }
-    public float PositionSetPoint { get; set; }
-    public float PosMonOffsetSetting { get; set; }
-    public float Pressure1Feedback { get; set; }
-    public float Pressure2Feedback { get; set; }
-    public float PressureSetPoint { get; set; }
-    public float SlowRateSetPoint { get; set; }
-    public float SlowVacuumModeSetting { get; set; }
-    public float ValveStatusThreshold { get; set; }
-
-}
-
-public class BoatElevatorServo
-{
-    public bool AtHomePosition { get; set; }
-    public bool AtPosition1 { get; set; }
-    public bool AtPosition2 { get; set; }
-    public bool AtPosition3 { get; set; }
-    public bool CurrentPosition { get; set; }
-    public bool CurrentSpeed { get; set; }
-    public bool IsAlarm { get; set; }
-    public bool IsMoving { get; set; }
-    public bool IsReady { get; set; }
-    public bool IsServoOn { get; set; }
-    public bool TargetPosition { get; set; }
-    public bool TargetPositionFb { get; set; }
-
-
-}
-
-public class BoatRotationServo
-{
-    public bool AtHomePosition { get; set; }
-    public bool CurrentSpeed { get; set; }
-    public bool IsAlarm { get; set; }
-    public bool IsHomeDone { get; set; }
-    public bool IsHoming { get; set; }
-    public bool IsMoving { get; set; }
-    public bool IsReady { get; set; }
-}
-
-public class BufferFoup
-{
-    public float N2Flow { get; set; }
-    public float N2Pressure { get; set; }
-}
-
-public class BufferServo
-{
-    public bool AtPositionA1 { get; set; }
-    public bool AtPositionA2 { get; set; }
-    public bool AtPositionA3 { get; set; }
-    public bool AtPositionA4 { get; set; }
-    public bool AtPositionB1 { get; set; }
-    public bool AtPositionB2 { get; set; }
-    public bool AtPositionB3 { get; set; }
-    public bool AtPositionB4 { get; set; }
-    public bool AtPositionC1 { get; set; }
-    public bool AtPositionC2 { get; set; }
-    public bool AtPositionC3 { get; set; }
-    public bool AtPositionC4 { get; set; }
-    public bool AtPositionD1 { get; set; }
-    public bool AtPositionD2 { get; set; }
-    public bool AtPositionD3 { get; set; }
-    public bool AtPositionD4 { get; set; }
-    public float CurrentPosition { get; set; }
-    public float CurrentSpeed { get; set; }
-    public float CurrentTorque { get; set; }
-    public bool IsAlarm { get; set; }
-    public bool IsInPosition { get; set; }
-    public bool IsMotorRun { get; set; }
-    public bool IsReady { get; set; }
-    public bool IsServoOn { get; set; }
-    public bool IsServoOnBufferAxis { get; set; }
-    public float TargetPosition { get; set; }
-}
-
-public class FFU
-{
-    public float CurrentSpeed { get; set; }
-    public bool IsSwitch { get; set; }
-    public float SetSpeed { get; set; }
-}
-
-public class LeakCheck
-{
-    public float ActualLeak { get; set; }
-    public float BasePressure { get; set; }
-    public float BasePressureLimit { get; set; }
-    public float CheckTime { get; set; }
-    public float DelayElapseTime { get; set; }
-    public float DelayMonitorPressure { get; set; }
-    public float DelayStartPressure { get; set; }
-    public float DelayTime { get; set; }
-    public float ElapseTime { get; set; }
-    public float HighLimit { get; set; }
-    public float LeakLimit { get; set; }
-    public float LowLimit { get; set; }
-    public float MonitorPressure { get; set; }
-    public float RetryCurrentCount { get; set; }
-    public float RetryLimit { get; set; }
-    public float StartPressure { get; set; }
-
-}
-
-public class MFC
-{
-    public float Feedback { get; set; }
-    public float LastSetPoint { get; set; }
-    public float MFCUnitEnum { get; set; }
-}
-
-public class Shutter
-{
-    public bool DiClose { get; set; }
-    public bool DiOpen { get; set; }
-    public bool DoClose { get; set; }
-    public bool DoOpen { get; set; }
-}
-
-public class Recipe
-{
-    public float ChamberPressure { get; set; }
-    public bool IsError { get; set; }
-    public bool IsExecuteSubRecipe { get; set; }
-    public bool IsInMaintainMode { get; set; }
-    public bool IsLooping { get; set; }
-    public bool IsOnline { get; set; }
-    public bool IsProcessing { get; set; }
-    public float LoopCountCurrent { get; set; }
-    public float LoopCountSet { get; set; }
-    public bool MBPEnable { get; set; }
-    public bool NDIREnable { get; set; }
-    public float NewShowTime { get; set; }
-    public bool RecipeHold { get; set; }
-    public float RecipeHolded { get; set; }
-    public float RecipeHoldTime { get; set; }
-    public float RecipeStepElapseTime { get; set; }
-    public float RecipeStepNumber { get; set; }
-    public float RecipeStepTime { get; set; }
-    public float RecipeTotalElapseTime { get; set; }
-    public float RecipeTotalTime { get; set; }
-    public bool RecipeWait { get; set; }
-    public bool SensorMini8OffLine { get; set; }
-    public bool SP1Enable { get; set; }
-    public float SubRecipeCurrentLoopCount { get; set; }
-    public float SubRecipeLoopCount { get; set; }
-}

+ 0 - 160
Test/ProximaSystem.cs

@@ -1,160 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection.Metadata;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Test;
-
-public class ProximaSystem
-{
-    public Boat Boat { get; set; }
-}
-
-public class Boat
-{
-    public float BoatTestCycledCount { get; set; }
-    public bool IsError { get; set; }
-    public bool IsOnline { get; set; }
-    public float ShutterCycledCount { get; set; }
-}
-
-public class CarrierRobot
-{
-    public float CurrentExtensionPosition { get; set; }
-    public float CurrentThetaPosition { get; set; }
-    public float CycleSwapCycledCount { get; set; }
-    public bool IsCommandExecutionReady { get; set; }
-    public bool IsControllerBatteryLow { get; set; }
-    public bool IsError { get; set; }
-    public bool IsErrorOccurred { get; set; }
-    public bool IsManipulatorBatteryLow { get; set; }
-    public bool IsOnline { get; set; }
-    public bool IsPause { get; set; }
-    public bool IsServoON { get; set; }
-    public bool IsWaferPresenceOnBlade1 { get; set; }
-    public float SwapCycledCount { get; set; }
-    public bool TPStatus { get; set; }
-}
-
-public class WaferRobot
-{
-    public bool CurrentArm1Position { get; set; }
-    public bool CurrentArm2Position { get; set; }
-    public bool CurrentExtensionPosition { get; set; }
-    public bool CurrentThetaPosition { get; set; }
-    public bool CurrentZPosition { get; set; }
-    public bool IsCommandExecutionReady { get; set; }
-    public bool IsControllerBatteryLow { get; set; }
-    public bool IsErrorOccurred { get; set; }
-    public bool IsManipulatorBatteryLow { get; set; }
-    public bool IsOnline { get; set; }
-    public bool IsPause { get; set; }
-    public bool IsServoON { get; set; }
-    public bool IsWaferPresenceOnBlade1 { get; set; }
-    public bool IsWaferPresenceOnBlade2 { get; set; }
-    public bool IsWaferPresenceOnBlade3 { get; set; }
-    public bool IsWaferPresenceOnBlade4 { get; set; }
-    public bool IsWaferPresenceOnBlade5 { get; set; }
-    public bool SwapCycledCount { get; set; }
-    public bool TPStatus { get; set; }
-
-}
-
-public class FIMS
-{
-    public float FIMSCycledCount { get; set; }
-    public bool IsError { get; set; }
-    public bool IsOnline { get; set; }
-}
-
-public class LoadPort
-{
-    public float CasstleType { get; set; }
-    public float InfoPadCarrierIndex { get; set; }
-    public float intAccessMode { get; set; }
-    public float intAccessStatus { get; set; }
-    public float intAssociationState { get; set; }
-    public float intCarrierIDStatus { get; set; }
-    public float intReserveState { get; set; }
-    public float intSlotMapStatus { get; set; }
-    public float intTransferState { get; set; }
-    public bool IsAccessSwPressed { get; set; }
-    public bool IsAutoDetectCarrierType { get; set; }
-    public bool IsClamped { get; set; }
-    public bool IsDocked { get; set; }
-    public bool IsDoorOpen { get; set; }
-    public bool IsError { get; set; }
-    public bool IsFoupPresent { get; set; }
-    public bool IsMapped { get; set; }
-    public bool IsOnline { get; set; }
-    public bool IsPlaced { get; set; }
-    public bool IsPresent { get; set; }
-    public bool IsVerifyPreDefineWaferCount { get; set; }
-    public float PreDefineWaferCount { get; set; }
-}
-
-public class Schedule
-{
-    public bool CoolingRemainTime { get; set; }
-    public bool CoolingTime { get; set; }
-    public bool CycledCount { get; set; }
-    public bool CycledTotalWafer { get; set; }
-    public bool CycledWafer { get; set; }
-    public bool CycleSetPoint { get; set; }
-}
-
-public class Stocker
-{
-    public bool CassetteHasWafer { get; set; }
-    public bool FoupPresent { get; set; }
-    public bool IsError { get; set; }
-    public bool IsOnline { get; set; }
-    public bool StatusAbnormal { get; set; }
-}
-
-public class Heater_
-{
-    public float CascadeControlModeSV { get; set; }
-    public float CascadePID_D { get; set; }
-    public float CascadePID_I { get; set; }
-    public float CascadePID_P { get; set; }
-    public float CascadePV { get; set; }
-    public float ControlMode { get; set; }
-    public float DownRate { get; set; }
-    public float HeaterControlModeSV { get; set; }
-    public float HeaterPID_D { get; set; }
-    public float HeaterPID_I { get; set; }
-    public float HeaterPID_P { get; set; }
-    public float HeaterPV { get; set; }
-    public bool IsAutoManual { get; set; }
-    public bool IsCascadeMode { get; set; }
-    public bool IsCascadePVBreak { get; set; }
-    public bool IsEnableIn { get; set; }
-    public bool IsEnableOutput { get; set; }
-    public bool IsHeaterPVBreak { get; set; }
-    public bool IsSelect { get; set; }
-    public float OverTemp { get; set; }
-    public float TCOpenOffsetOffset { get; set; }
-    public float TempFeedback { get; set; }
-    public float TempOffset { get; set; }
-    public float TempSetPoint { get; set; }
-    public float UpRate { get; set; }
-    public float WorkingOutput { get; set; }
-
-}
-
-public class System
-{
-    public bool HasActiveAlarm { get; set; }
-    public bool IsAlarm { get; set; }
-    public bool IsAlarmConditionBuzzerOn { get; set; }
-    public bool IsAutoRunning { get; set; }
-    public bool IsBusy { get; set; }
-    public bool IsIdle { get; set; }
-    public bool IsInitialized { get; set; }
-    public bool IsRecipeEditView { get; set; }
-    public bool IsSpoolingEnable { get; set; }
-    public bool SpoolingState { get; set; }
-}

+ 5 - 0
Test/Test.csproj

@@ -16,6 +16,11 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="Mapster" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\DataBase\DB_Proxima\DB_Proxima.csproj" />
     <ProjectReference Include="..\DataBase\SqlSugarORM\SqlSugarORM.csproj" />
     <ProjectReference Include="..\Data\DataService\DataService.csproj" />
   </ItemGroup>