Skip to content

Commit a39e53e

Browse files
authored
Merge pull request #7 from Laith-S/master
Fixed Hbytes and added getType in KRLVariable class
2 parents f52e7cb + 9f642c1 commit a39e53e

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

JOpenShowVar-core/src/no/hials/crosscom/CrossComClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public String simpleRead(String name) throws IOException {
6464
List<Byte> header = new ArrayList<>();
6565
List<Byte> block = new ArrayList<>();
6666

67-
byte hbyte = (byte) ((cmd.length >> 8) & 0xff00);
67+
byte hbyte = (byte) ((cmd.length & 0xff00)>>8);
6868
byte lbyte = (byte) (cmd.length & 0x00ff);
6969

7070
int index = 0;
@@ -74,10 +74,10 @@ public String simpleRead(String name) throws IOException {
7474
for (int i = 0; i < cmd.length; i++) {
7575
block.add(index++, cmd[i]);
7676
}
77-
hbyte = (byte) ((block.size() >> 8) & 0xff00);
77+
hbyte = (byte) ((block.size() & 0xff00)>>8);
7878
lbyte = (byte) (block.size() & 0x00ff);
7979

80-
byte hbytemsg = (byte) ((id >> 8) & 0xff00);
80+
byte hbytemsg = (byte) ((id & 0xff00)>>8);
8181
byte lbytemsg = (byte) (id & 0x00ff);
8282

8383
index = 0;
@@ -123,7 +123,7 @@ public String simpleWrite(String name, String val) throws IOException {
123123
List<Byte> header = new ArrayList<>();
124124
List<Byte> block = new ArrayList<>();
125125

126-
byte hbyte = (byte) ((cmd.length >> 8) & 0xff00);
126+
byte hbyte = (byte) ((cmd.length & 0xff00)>>8);
127127
byte lbyte = (byte) (cmd.length & 0x00ff);
128128

129129
int index = 0;
@@ -134,7 +134,7 @@ public String simpleWrite(String name, String val) throws IOException {
134134
block.add(index++, cmd[i]);
135135
}
136136

137-
hbyte = (byte) ((value.length >> 8) & 0xff00);
137+
hbyte = (byte) ((value.length & 0xff00)>>8);
138138
lbyte = (byte) (value.length & 0x00ff);
139139

140140
block.add(index++, hbyte);
@@ -143,10 +143,10 @@ public String simpleWrite(String name, String val) throws IOException {
143143
block.add(index++, value[i]);
144144
}
145145

146-
hbyte = (byte) ((block.size() >> 8) & 0xff00);
146+
hbyte = (byte) ((block.size() & 0xff00)>>8);
147147
lbyte = (byte) (block.size() & 0x00ff);
148148

149-
byte hbytemsg = (byte) ((id >> 8) & 0xff00);
149+
byte hbytemsg = (byte) ((id & 0xff00)>>8);
150150
byte lbytemsg = (byte) (id & 0x00ff);
151151

152152
index = 0;

JOpenShowVar-core/src/no/hials/crosscom/KRL/KRLVariable.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ public int getId() {
6666
public String getName() {
6767
return name;
6868
}
69+
70+
/**
71+
* Return the Type of Variable that implements this class
72+
*
73+
* @return the Type of variable that implements this class
74+
*/
75+
public String getType(){
76+
return this.getClass().getSimpleName();
77+
}
6978

7079
/**
7180
* The time it took to read/write this variable
@@ -118,7 +127,7 @@ public Byte[] getReadCommand() {
118127
List<Byte> header = new ArrayList<>();
119128
List<Byte> block = new ArrayList<>();
120129

121-
byte hbyte = (byte) ((cmd.length >> 8) & 0xff00);
130+
byte hbyte = (byte) ((cmd.length & 0xff00)>>8);
122131
byte lbyte = (byte) (cmd.length & 0x00ff);
123132

124133
int index = 0;
@@ -128,10 +137,10 @@ public Byte[] getReadCommand() {
128137
for (int i = 0; i < cmd.length; i++) {
129138
block.add(index++, cmd[i]);
130139
}
131-
hbyte = (byte) ((block.size() >> 8) & 0xff00);
140+
hbyte = (byte) ((block.size() & 0xff00)>>8);
132141
lbyte = (byte) (block.size() & 0x00ff);
133142

134-
byte hbytemsg = (byte) ((id >> 8) & 0xff00);
143+
byte hbytemsg = (byte) ((id & 0xff00)>>8);
135144
byte lbytemsg = (byte) (id & 0x00ff);
136145

137146
index = 0;
@@ -156,7 +165,7 @@ public Byte[] getWriteCommand() {
156165
List<Byte> header = new ArrayList<>();
157166
List<Byte> block = new ArrayList<>();
158167

159-
byte hbyte = (byte) ((cmd.length >> 8) & 0xff00);
168+
byte hbyte = (byte) ((cmd.length & 0xff00)>>8);
160169
byte lbyte = (byte) (cmd.length & 0x00ff);
161170

162171
int index = 0;
@@ -167,7 +176,7 @@ public Byte[] getWriteCommand() {
167176
block.add(index++, cmd[i]);
168177
}
169178

170-
hbyte = (byte) ((value.length >> 8) & 0xff00);
179+
hbyte = (byte) ((value.length & 0xff00)>>8);
171180
lbyte = (byte) (value.length & 0x00ff);
172181

173182
block.add(index++, hbyte);
@@ -176,10 +185,10 @@ public Byte[] getWriteCommand() {
176185
block.add(index++, value[i]);
177186
}
178187

179-
hbyte = (byte) ((block.size() >> 8) & 0xff00);
188+
hbyte = (byte) ((block.size() & 0xff00)>>8);
180189
lbyte = (byte) (block.size() & 0x00ff);
181190

182-
byte hbytemsg = (byte) ((id >> 8) & 0xff00);
191+
byte hbytemsg = (byte) ((id & 0xff00)>>8);
183192
byte lbytemsg = (byte) (id & 0x00ff);
184193

185194
index = 0;

0 commit comments

Comments
 (0)