Преглед изворни кода

Fix int16/uint16 transfer bug.
Time display fixed.

xcbosa пре 3 година
родитељ
комит
883c2857f0
2 измењених фајлова са 20 додато и 3 уклоњено
  1. 16 2
      WpfTest1/ComAgent/Extension.cs
  2. 4 1
      WpfTest1/MainWindow.xaml.cs

+ 16 - 2
WpfTest1/ComAgent/Extension.cs

@@ -7,6 +7,8 @@ using System.Threading.Tasks;
 
 using uint16_t = System.UInt16;
 using uint8_t = System.Byte;
+using int16_t = System.Int16;
+using int8_t = System.SByte;
 
 namespace WpfTest1.ComAgent
 {
@@ -118,10 +120,22 @@ namespace WpfTest1.ComAgent
 
 		public static byte[] buff(this int i) => BitConverter.GetBytes(i);
 		public static byte[] buff(this uint i) => BitConverter.GetBytes(i);
-		public static byte[] buff(this uint16_t i) => BitConverter.GetBytes(i);
-		public static byte[] buff(this short i) => BitConverter.GetBytes(i);
 		public static byte[] buff(this uint8_t i) => i.pack();
 
+		public static byte[] buff(this uint16_t i)
+		{
+			byte[] buff = BitConverter.GetBytes(i);
+			Array.Reverse(buff);
+			return buff;
+		}
+
+		public static byte[] buff(this int16_t i)
+		{
+			byte[] buff = BitConverter.GetBytes(i);
+			Array.Reverse(buff);
+			return buff;
+		}
+
 		public static uint8_t[] packData(this uint8_t[] inputData)
         {
 			uint8_t[] data = pack0x10(inputData);

+ 4 - 1
WpfTest1/MainWindow.xaml.cs

@@ -1631,7 +1631,10 @@ namespace WpfTest1
             set
             {
                 treatmentTime_ = value > treatmentTimeMax ? treatmentTimeMax : value < treatmentTimeMin ? treatmentTimeMin : value;
-                labelTreatmentTime.Content = $"{(int)treatmentTime_}:{(treatmentTime_ - (int)treatmentTime_) * 60}";
+                labelTreatmentTime.Content = $"{(int)treatmentTime_}:";
+                int sec = (int)((treatmentTime_ - (int)treatmentTime_) * 60);
+                if (sec < 10) labelTreatmentTime.Content += "0";
+                labelTreatmentTime.Content += sec.ToString();
             }
         }