Przeglądaj źródła

处方模式停止指令修复

xcbosa 3 lat temu
rodzic
commit
323df0ca01
2 zmienionych plików z 20 dodań i 15 usunięć
  1. 19 14
      WpfTest1/ComAgent/ComAgent.cs
  2. 1 1
      WpfTest1/MainWindow.xaml.cs

+ 19 - 14
WpfTest1/ComAgent/ComAgent.cs

@@ -60,23 +60,28 @@ namespace WpfTest1.ComAgent
         public static byte[] createIdleCommand() => 0x49.b().pack(0x00.b());
         public static byte[] createIdleCommand() => 0x49.b().pack(0x00.b());
         public static byte[] createChangeStrongthCommand(byte strongth) => 0x40.b().pack(strongth);
         public static byte[] createChangeStrongthCommand(byte strongth) => 0x40.b().pack(strongth);
 
 
-        public static byte[] createStartDefinedCommand(int mode, ushort time, byte strongth)
+        public static byte getTCIDByIndex(int index)
         {
         {
-            List<byte> buff = new List<byte>();
-            switch (mode)
+            switch (index)
             {
             {
-                case 0: buff.Add(0x10); break;
-                case 1: buff.Add(0x11); break;
-                case 2: buff.Add(0x12); break;
-                case 3: buff.Add(0x13); break;
-                case 4: buff.Add(0x14); break;
-                case 5: buff.Add(0x25); break;
-                case 6: buff.Add(0x26); break;
-                case 7: buff.Add(0x27); break;
-                case 8: buff.Add(0x28); break;
-                case 9: buff.Add(0x29); break;
-                default: throw new ComException($"Invaild mode {mode}");
+                case 0: return 0x10;
+                case 1: return 0x11;
+                case 2: return 0x12;
+                case 3: return 0x13;
+                case 4: return 0x14;
+                case 5: return 0x25;
+                case 6: return 0x26;
+                case 7: return 0x27;
+                case 8: return 0x28;
+                case 9: return 0x29;
+                default: throw new ComException($"Invaild mode {index}");
             }
             }
+        }
+
+        public static byte[] createStartDefinedCommand(int mode, ushort time, byte strongth)
+        {
+            List<byte> buff = new List<byte>();
+            buff.Add(getTCIDByIndex(mode));
             buff.Add(0x53);
             buff.Add(0x53);
             buff.AddRange(time.buff());
             buff.AddRange(time.buff());
             buff.AddRange(strongth.buff());
             buff.AddRange(strongth.buff());

+ 1 - 1
WpfTest1/MainWindow.xaml.cs

@@ -1701,7 +1701,7 @@ namespace WpfTest1
             }
             }
             else
             else
             {
             {
-                comAgent.enqueueCommand(Com.createStopCommand(targetTreatment.id.b()));
+                comAgent.enqueueCommand(Com.createStopCommand(Com.getTCIDByIndex(targetTreatment.id)));
             }
             }
 
 
             isRunning = false;
             isRunning = false;