YgslUtil3.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. //package com.mes.ui;
  2. //
  3. //import com.mes.ygsl.YgslClient2;
  4. //import com.mes.ygsl.YgslClient3;
  5. //import io.netty.buffer.ByteBuf;
  6. //import io.netty.buffer.Unpooled;
  7. //
  8. //public class YgslUtil3 {
  9. //
  10. // // 心跳
  11. // public static Boolean comHeart(YgslClient3 ygslClient){
  12. // try{
  13. // String synr_str = "002099990010 ";
  14. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  15. // return true;
  16. // }catch (Exception e){
  17. // e.printStackTrace();
  18. // return false;
  19. // }
  20. // }
  21. //
  22. // // 通讯启动 对应回复 0002 通讯启动确认
  23. // public static Boolean comStart(YgslClient3 ygslClient){
  24. // try{
  25. // String synr_str = "002000010050 ";
  26. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  27. // return true;
  28. // }catch (Exception e){
  29. // e.printStackTrace();
  30. // return false;
  31. // }
  32. // }
  33. //
  34. // // 通讯停止 对应回复 0005 命令被接受 0004 命令错误
  35. // public static Boolean comStop(YgslClient3 ygslClient){
  36. // try{
  37. // String synr_str = "002000030050 ";
  38. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  39. // return true;
  40. // }catch (Exception e){
  41. // e.printStackTrace();
  42. // return false;
  43. // }
  44. // }
  45. //
  46. // // 使能工具 回复 0004/0005
  47. // public static Boolean enableTool(YgslClient3 ygslClient){
  48. // try{
  49. // String synr_str = "00200043000 01 ";
  50. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  51. //
  52. // String synr_str2 = "002300180010 001";
  53. // System.out.println("切换到Pset1模式,开启枪");
  54. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str2)));
  55. // return true;
  56. // }catch (Exception e){
  57. // e.printStackTrace();
  58. // return false;
  59. // }
  60. // }
  61. //
  62. // // 禁用工具 回复 0004/0005
  63. // public static Boolean disableTool(YgslClient3 ygslClient){
  64. // try{
  65. // String synr_str = "00200042000 01 ";
  66. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  67. //
  68. // String synr_str2 = "002300180010 002";
  69. // System.out.println("切换到Pset2模式,开启枪");
  70. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str2)));
  71. // return true;
  72. // }catch (Exception e){
  73. // e.printStackTrace();
  74. // return false;
  75. // }
  76. // }
  77. //
  78. // // 设置setId 对应回复 0010 pset
  79. // public static Boolean pSet(YgslClient3 ygslClient){
  80. // try{
  81. // String synr_str = "002000100010 ";
  82. // System.out.println("pSet3:"+synr_str);
  83. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  84. // return true;
  85. // }catch (Exception e){
  86. // e.printStackTrace();
  87. // return false;
  88. // }
  89. // }
  90. //
  91. // // 选择 setId 0018 pset
  92. // public static Boolean selectSet(YgslClient3 ygslClient){
  93. // try{
  94. // String synr_str = "002300180010 001";
  95. // System.out.println("selectSet3:"+synr_str);
  96. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  97. // return true;
  98. // }catch (Exception e){
  99. // e.printStackTrace();
  100. // return false;
  101. // }
  102. // }
  103. //
  104. // //上次拧紧结果数据订阅 0061 拧紧数据上报
  105. // public static Boolean lastTighteningResultSubscribe(YgslClient3 ygslClient){
  106. // try{
  107. // String synr_str = "002000600010 ";
  108. // System.out.println(stringToHex(synr_str));
  109. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  110. // return true;
  111. // }catch (Exception e){
  112. // e.printStackTrace();
  113. // return false;
  114. // }
  115. // }
  116. //
  117. // // 接收到订阅拧紧数据后回复
  118. // public static Boolean lastTighteningResultDataAcknowledge(YgslClient3 ygslClient){
  119. // try{
  120. // String synr_str = "0020006200010 ";
  121. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  122. // return true;
  123. // }catch (Exception e){
  124. // e.printStackTrace();
  125. // return false;
  126. // }
  127. // }
  128. //
  129. // public static Boolean jobIdUpload(YgslClient3 ygslClient){
  130. // try{
  131. // String synr_str = "002000300010 ";
  132. // System.out.println("jobIdUpload3:"+synr_str);
  133. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  134. // return true;
  135. // }catch (Exception e){
  136. // e.printStackTrace();
  137. // return false;
  138. // }
  139. // }
  140. //
  141. // public static Boolean selectJob(YgslClient3 ygslClient){
  142. // try{
  143. // String synr_str = "002000380010 03";
  144. // System.out.println("selectJob3:"+synr_str);
  145. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  146. // return true;
  147. // }catch (Exception e){
  148. // e.printStackTrace();
  149. // return false;
  150. // }
  151. // }
  152. //
  153. // public static Boolean restartJob(YgslClient3 ygslClient){
  154. // try{
  155. // String synr_str = "002000390010 01";
  156. // System.out.println("restartJob3:"+synr_str);
  157. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  158. // return true;
  159. // }catch (Exception e){
  160. // e.printStackTrace();
  161. // return false;
  162. // }
  163. // }
  164. //
  165. // public static String stringToHex(String input) {
  166. // StringBuilder hexString = new StringBuilder();
  167. //
  168. // for (char ch : input.toCharArray()) {
  169. // hexString.append(Integer.toHexString((int) ch));
  170. // }
  171. //
  172. // return hexString.toString();
  173. // }
  174. //
  175. // /**
  176. // * 将字符串消息转为ByteBuf
  177. // * 16进制字符串转二进制
  178. // * @param hex 字符串消息
  179. // */
  180. // public static ByteBuf getSendByteBuf(String hex) {
  181. // hex = hex + "00";
  182. // byte[] bytes = new byte[hex.length() / 2];
  183. // for (int i = 0; i < hex.length(); i += 2) {
  184. // int value = Integer.parseInt(hex.substring(i, i + 2), 16);
  185. // bytes[i/2] = (byte)(value & 0xFF);
  186. // }
  187. // return Unpooled.wrappedBuffer(bytes);
  188. // }
  189. //
  190. // public static Boolean uploadVin(YgslClient3 ygslClient, String sn){
  191. // try{
  192. // String synr_str = "05400050002 "+"01"+formatSn(sn)+"02"+formatSn("")+"03"+formatSn("")+"04"+formatSn("");
  193. // System.out.println("3上传VIN【0050】:"+synr_str+":"+synr_str.length());
  194. // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
  195. // return true;
  196. // }catch (Exception e){
  197. // e.printStackTrace();
  198. // return false;
  199. // }
  200. // }
  201. //
  202. // public static String formatSn(String sn){
  203. // int length = 128;
  204. // return String.format("%1$-" + length + "s", sn);
  205. // }
  206. //}
  207. //