Browse Source

revise gold cell power enable bug

chenzk 1 month ago
parent
commit
3118710154
1 changed files with 15 additions and 2 deletions
  1. 15 2
      CyberX8_Simulator/Devices/PowerSupplierSocketSimulator.cs

+ 15 - 2
CyberX8_Simulator/Devices/PowerSupplierSocketSimulator.cs

@@ -40,9 +40,13 @@ namespace CyberX8_Simulator.Devices
         private byte _currentStep = 0;
         private int _currentLength = 0;
         private DateTime _currentTime = DateTime.Now;
+        private bool _isGoldPower = false;
 
         private System.Timers.Timer _timer;
-        private byte[] _powerSupplierSetPoint = new byte[4];//记录每次设置的电流值
+        /// <summary>
+        /// 记录每次设置的电流值
+        /// </summary>
+        private byte[] _powerSupplierSetPoint = new byte[4];
 
         public PowerSupplierSocketSimulator(int port):base(port)
         {
@@ -140,6 +144,7 @@ namespace CyberX8_Simulator.Devices
                 }
                 else if(startAddress == GOLD_CURRENT_SETTING_ADDRESS)
                 {
+                    _isGoldPower = true;
                     OnWriteMessage(CreateReadResponse(flag, channel, command, registerCount, _powerSupplierSetPoint));
                     return;
                 }
@@ -183,7 +188,15 @@ namespace CyberX8_Simulator.Devices
                     {
                         if (_powerSupplierDic[channel].RunModel == 1)
                         {
-                            _powerSupplierDic[channel].Current = _powerSupplierDic[channel].CurrentSetting * 10;
+                            if (_isGoldPower)
+                            {
+                                int count = byteTransform.TransInt32(_powerSupplierSetPoint, 0);
+                                _powerSupplierDic[channel].Current = count / 100;
+                            }
+                            else
+                            {
+                                _powerSupplierDic[channel].Current = _powerSupplierDic[channel].CurrentSetting * 10;
+                            }
                         }
                     }
                     else