ZNWC_T_L_H SDK 使用说明
一、集成到项目
1、将ZNWC_T_L_H_v1.0.aar拷贝到libs
2、Gradle Dependency
dependencies {
......
implementation files('libs/ZNWC_T_L_H-release.aar')
implementation'com.aill:AndroidSerialPort:1.0.8'
}
3、权限
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
二、函数调用
1、简单的初始化
import com.yhjy.znwc_t_l_h.Manager;
//初始化
manager = Manager.getInstance();
manager.init(getApplicationContext());
2、获取设备所有串口
String[] allDevicesPath =manager.getAllDevicesPath();
3、连接串口
参数1:串口路径
参数2:波特率
返回: true 已连接 false 未连接
manager.openSerial("/dev/ttymxc4",9600); //微超系统
manager.openSerial2("/dev/ttymxc2");//电子价签
4、开始出货
参数1:货道号
参数2:加热时间
参数3:出货回调
manager.startShipment(huodao,1,new OpenDoorCall() {
@Override
public void succeed() {//成功取货到微波炉
}
@Override
public void hotFinish() {//加热完成
}
@Override
public void finish() {//出货完成
}
@Override
public void failure(String msg) {//出货失败 msg:失败信息
}
});
5、出货流程以外的指令通信回调
manager.setSerialCall(new CommandCall() {
@Override
public void Call(HardwareResultsBean hardwareResultsBean) {
switch (hardwareResultsBean.mCommands){
case Commands.OPS://打开,关闭维护
if (hardwareResultsBean.commonResultBean.result ==1){//1 成功 0 失败}
break;
case Commands.OPEN_DOOR://开门
if (hardwareResultsBean.commonResultBean.result ==1){//1 成功 0 失败}
break;
case Commands.TEMP_GET://当前温度
"当前温度:" + Long.parseLong(hardwareResultsBean.commonTempBean.temp.substring(0,2),16)
break;
case Commands.AISLE_TIER://货道结构取得
String aisleTier = hardwareResultsBean.commonAisleTierBean.aisleTier;//货道数据
break;
case Commands.GET_HD_COOR://当前货斗坐标查询指令
int X = (int) Long.parseLong(hardwareResultsBean.commonResult.result.substring(0,4),16);
int Y = (int) Long.parseLong(hardwareResultsBean.commonResult.result.substring(4,8),16);
break;
case Commands.SET_HDPZ_COOR://货道坐标设置指令
if (hardwareResultsBean.commonResult.result.equals("01")){
ToastUtils.show("启动设置");
}else{
ToastUtils.show("未启动设置");
}
break;
case Commands.GET_HDPZ_RESULT://货道坐标设置结果查询指令
if (hardwareResultsBean.commonResult.result.equals("01")){
//设置成功
}else if(hardwareResultsBean.commonResult.result.equals("02")){
//设置进行中
}else if(hardwareResultsBean.commonResult.result.equals("00")){
//设置失败
}
break;
case Commands.GET_HDPZ://货道配置信息查询指令
//每层的类型 01履带
String hd_type = hardwareResultsBean.hdConfigResults.hd_type;
//每层的货道数量
String hd_size = hardwareResultsBean.hdConfigResults.hd_size;
//所有的Y坐标
String y_coor = hardwareResultsBean.hdConfigResults.y_coor;
//所有的X坐标
String x_coor = hardwareResultsBean.hdConfigResults.x_coor;
int[] typeArr =new int[hd_type.length()/2];
int[] YXsizeArr =new int[hd_size.length()/2];
int[] YArr =new int[y_coor.length()/4];
int[] XArr =new int[x_coor.length()/4];
int index =0;
for (int i =0;i < hd_type.length();i+=2){
typeArr[index] = (int) Long.parseLong(hd_type.substring(i, i +2),16);
index++;
}
index =0;
for (int i =0;i < hd_size.length();i+=2){
YXsizeArr[index] = (int) Long.parseLong(hd_size.substring(i, i +2),16);
index++;
}
index =0;
for (int i =0;i < y_coor.length();i+=4){
YArr[index] = (int) Long.parseLong(y_coor.substring(i, i +4),16);
index++;
}
index =0;
for (int i =0;i < x_coor.length();i+=4){
XArr[index] = (int) Long.parseLong(x_coor.substring(i, i +4),16);
index++;
}
etDateBeanList.clear();
index =0;
for (int i =0;i < typeArr.length;i++){
EtDateBean etDateBean =new EtDateBean();
etDateBean.layer_Type = typeArr[i];
etDateBean.layer_Y = YArr[i];
for (int j =0;j < YXsizeArr[i];j++){
etDateBean.layer_X_list.add(XArr[index]);
index++;
}
etDateBeanList.add(etDateBean);
}
for (int i =0;i < etDateBeanList.size();i++){
et_List.get(i).layer_Type.setText(etDateBeanList.get(i).layer_Type+"");
et_List.get(i).layer_Y.setText(etDateBeanList.get(i).layer_Y+"");
for(int j =0;j < etDateBeanList.get(i).layer_X_list.size();j++){
et_List.get(i).layer_X_list.get(j).setText(etDateBeanList.get(i).layer_X_list.get(j)+"");
}
}
break;
case Commands.SET_CALL:
if (hardwareResultsBean.commonResultBean.result ==1){
ToastUtils.show("执行成功");
}else{
ToastUtils.show("执行失败");
}
break;
}
}
});
6、打开维护
manager.startOps()
7、关闭维护
manager.stopOps()
8、关闭使能
manager.stopCALL()
9、货道结构取得
manager.aisle_tier()
10、系统状态取得
manager.getSystemState()
11、温度取得
manager.getTemp()
12、开门
manager.openDoor()
13、整机传感器状态取得
manager.SENSOR_STATE_GET()
14、故障码取得
manager.getBreakdown()
15、当前货斗坐标查询指令
manager.GET_HD_COOR()
16、货道坐标设置结果查询指令
manager.GET_HDPZ_RESULT()
17、货道配置信息查询指令
manager.GET_HDPZ()
18、货道坐标设置指令
manager.SET_HDPZ_COOR(int[] typeArr,int[] YArr,int[] YXsizeArr,int[] XArr)
19、加热
manager.HOT_zs(int size)//参数:加热时间:秒
20、设置电子价签显示
manager.Digital_show_CMD(String address, String data)//参数1:价签地址,参数2:显示内容