Jelajahi Sumber

R25 node topic data cpu company code delete

shjung 8 bulan lalu
induk
melakukan
e75274f3c9

+ 1 - 0
conn_comm1.bat

@@ -0,0 +1 @@
+ssh cvim@10.4.4.11

+ 1 - 0
conn_comm2.bat

@@ -0,0 +1 @@
+ssh cvim@10.4.4.12

+ 17 - 13
src/main/java/com/tsi/app/common/utils/ByteUtils.java

@@ -268,13 +268,25 @@ public class ByteUtils {
 		return result;
 	}
 
-	public static int getBitField(byte b, int field)
-	{
-		return (b & 1 << field) > 0 ? 1 : 0;
+	public static int getBitField(byte b, int field) {
+		return Math.min(1, b & 255 & 1 << (field % 8));
+//		byte setter = (byte)(1 << (field % 8));
+//		return (b & setter) > 0 ? 1 : 0;
 	}
 
-	public static int getBitField(byte b, int field, int count)
-	{
+	public static byte setBitField(byte b, int field, int value) {
+		byte result;
+		byte setter = (byte)(1 <<  (field % 8));
+		if (value == 1) {
+			result = (byte)(b | setter);
+		}
+		else {
+			result = (byte)(b & ~setter);
+		}
+		return result;
+	}
+
+	public static int getBitField(byte b, int field, int count) {
 		if (count == 1) {
 			count = 1;
 		} else if (count == 2) {
@@ -311,14 +323,6 @@ public class ByteUtils {
 		return b >> field & count;
 	}
 
-	public static byte setBitField(byte b, int field, int value)
-	{
-		if ((value == 0) || (value == 1)) {
-			b = (byte)(b | value << field);
-		}
-		return b;
-	}
-
 	public static byte setBitField(byte b, int field, int count, int value)
 	{
 		if ((field + count <= 8) && (value < Math.pow(2.0D, count))) {

+ 1 - 1
src/main/java/com/tsi/app/common/utils/TimeUtils.java

@@ -30,7 +30,7 @@ public class TimeUtils {
         long nanoSeconds = TimeUnit.NANOSECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
 
         if (seconds > 0) {
-            return String.format("Elapsed: %,d sec. %3d ms. %d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
+            return String.format("Elapsed: %,d sec. %3d ms. %3d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
         }
         if (miliSeconds > 0) {
             return String.format("Elapsed: %3d ms. %3d us. %3d ns.", miliSeconds, microSeconds, nanoSeconds);

+ 6 - 1
src/main/java/com/tsi/comm/server/protocol/TsiCpuPacket.java

@@ -306,7 +306,12 @@ public class TsiCpuPacket extends AbstractTsiPacket {
         TsiNodeAddVo tsiNodeAddVo = TsiNodeAddManager.getInstance().get(this.nodeId);
         if (tsiNodeAddVo == null) {
             // 연등지 정보가 없는 경우
-            final int addLength = this.buf.length-SIZE_NODE_DUMMY;
+            // R25 인 경우 마지막 CPU 제조사 코드를 복사하지 않도록 수정
+            int addLength = this.buf.length-SIZE_NODE_DUMMY;
+            final int r25Length = SIZE_NODE_HEAD + (this.count * SIZE_STATUS_DATA);
+            if (addLength > r25Length) {
+                addLength = r25Length;
+            }
             this.nodeData = new byte[addLength];
             System.arraycopy(this.buf, INDEX_NODE_ID, this.nodeData, 0, addLength);
             return true;