| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- //package com.mes.ui;
- //
- //import com.mes.ygsl.YgslClient2;
- //import com.mes.ygsl.YgslClient3;
- //import io.netty.buffer.ByteBuf;
- //import io.netty.buffer.Unpooled;
- //
- //public class YgslUtil3 {
- //
- // // 心跳
- // public static Boolean comHeart(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002099990010 ";
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // // 通讯启动 对应回复 0002 通讯启动确认
- // public static Boolean comStart(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002000010050 ";
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // // 通讯停止 对应回复 0005 命令被接受 0004 命令错误
- // public static Boolean comStop(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002000030050 ";
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // // 使能工具 回复 0004/0005
- // public static Boolean enableTool(YgslClient3 ygslClient){
- // try{
- // String synr_str = "00200043000 01 ";
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- //
- // String synr_str2 = "002300180010 001";
- // System.out.println("切换到Pset1模式,开启枪");
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str2)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // // 禁用工具 回复 0004/0005
- // public static Boolean disableTool(YgslClient3 ygslClient){
- // try{
- // String synr_str = "00200042000 01 ";
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- //
- // String synr_str2 = "002300180010 002";
- // System.out.println("切换到Pset2模式,开启枪");
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str2)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // // 设置setId 对应回复 0010 pset
- // public static Boolean pSet(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002000100010 ";
- // System.out.println("pSet3:"+synr_str);
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // // 选择 setId 0018 pset
- // public static Boolean selectSet(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002300180010 001";
- // System.out.println("selectSet3:"+synr_str);
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // //上次拧紧结果数据订阅 0061 拧紧数据上报
- // public static Boolean lastTighteningResultSubscribe(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002000600010 ";
- // System.out.println(stringToHex(synr_str));
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // // 接收到订阅拧紧数据后回复
- // public static Boolean lastTighteningResultDataAcknowledge(YgslClient3 ygslClient){
- // try{
- // String synr_str = "0020006200010 ";
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // public static Boolean jobIdUpload(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002000300010 ";
- // System.out.println("jobIdUpload3:"+synr_str);
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // public static Boolean selectJob(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002000380010 03";
- // System.out.println("selectJob3:"+synr_str);
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // public static Boolean restartJob(YgslClient3 ygslClient){
- // try{
- // String synr_str = "002000390010 01";
- // System.out.println("restartJob3:"+synr_str);
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // public static String stringToHex(String input) {
- // StringBuilder hexString = new StringBuilder();
- //
- // for (char ch : input.toCharArray()) {
- // hexString.append(Integer.toHexString((int) ch));
- // }
- //
- // return hexString.toString();
- // }
- //
- // /**
- // * 将字符串消息转为ByteBuf
- // * 16进制字符串转二进制
- // * @param hex 字符串消息
- // */
- // public static ByteBuf getSendByteBuf(String hex) {
- // hex = hex + "00";
- // byte[] bytes = new byte[hex.length() / 2];
- // for (int i = 0; i < hex.length(); i += 2) {
- // int value = Integer.parseInt(hex.substring(i, i + 2), 16);
- // bytes[i/2] = (byte)(value & 0xFF);
- // }
- // return Unpooled.wrappedBuffer(bytes);
- // }
- //
- // public static Boolean uploadVin(YgslClient3 ygslClient, String sn){
- // try{
- // String synr_str = "05400050002 "+"01"+formatSn(sn)+"02"+formatSn("")+"03"+formatSn("")+"04"+formatSn("");
- // System.out.println("3上传VIN【0050】:"+synr_str+":"+synr_str.length());
- // ygslClient.future.channel().writeAndFlush(getSendByteBuf(stringToHex(synr_str)));
- // return true;
- // }catch (Exception e){
- // e.printStackTrace();
- // return false;
- // }
- // }
- //
- // public static String formatSn(String sn){
- // int length = 128;
- // return String.format("%1$-" + length + "s", sn);
- // }
- //}
- //
|