V2.07 检测参数自检命令验证成功
This commit is contained in:
@@ -66,6 +66,8 @@
|
|||||||
解决tcp不上报心跳的问题
|
解决tcp不上报心跳的问题
|
||||||
2024.1.29
|
2024.1.29
|
||||||
添加对hmi屏幕的支持,赋码仪按键按下时发送赋码请求
|
添加对hmi屏幕的支持,赋码仪按键按下时发送赋码请求
|
||||||
|
2024.3.12
|
||||||
|
V2.07 检测参数自检命令验证成功
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ SOURCES += \
|
|||||||
prot/prot_m4.cpp \
|
prot/prot_m4.cpp \
|
||||||
prot/prot_pc.cpp \
|
prot/prot_pc.cpp \
|
||||||
prot/prot_slave.cpp \
|
prot/prot_slave.cpp \
|
||||||
|
prot_cmd/cmd_checkself.cpp \
|
||||||
prot_cmd/cmd_cmdline.cpp \
|
prot_cmd/cmd_cmdline.cpp \
|
||||||
prot_cmd/cmd_coder.cpp \
|
prot_cmd/cmd_coder.cpp \
|
||||||
prot_cmd/cmd_hmi_coder.cpp \
|
prot_cmd/cmd_hmi_coder.cpp \
|
||||||
@@ -81,6 +82,7 @@ HEADERS += \
|
|||||||
prot/prot_m4.h \
|
prot/prot_m4.h \
|
||||||
prot/prot_pc.h \
|
prot/prot_pc.h \
|
||||||
prot/prot_slave.h \
|
prot/prot_slave.h \
|
||||||
|
prot_cmd/cmd_checkself.h \
|
||||||
prot_cmd/cmd_cmdline.h \
|
prot_cmd/cmd_cmdline.h \
|
||||||
prot_cmd/cmd_coder.h \
|
prot_cmd/cmd_coder.h \
|
||||||
prot_cmd/cmd_hmi_coder.h \
|
prot_cmd/cmd_hmi_coder.h \
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BUILD_DATE "2024-03-01 11:12:15"
|
#define BUILD_DATE "2024-03-12 10:30:39"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"build_date": "2024-03-01 11:12:15",
|
"build_date": "2024-03-12 10:30:39",
|
||||||
"hard_version": "MHPZ2_V1.00",
|
"hard_version": "MHPZ2_V1.00",
|
||||||
"private": [
|
"private": [
|
||||||
"info.json",
|
"info.json",
|
||||||
"json.lua",
|
"json.lua",
|
||||||
"prints.lua"
|
"prints.lua"
|
||||||
],
|
],
|
||||||
"soft_version": "V2.06"
|
"soft_version": "V2.07"
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ void prot_m4::init()
|
|||||||
|
|
||||||
void prot_m4::send_data_slot(myarray data)
|
void prot_m4::send_data_slot(myarray data)
|
||||||
{
|
{
|
||||||
|
if(data.size()==0) return;
|
||||||
if ((if_ != nullptr) && (codec_ != nullptr))
|
if ((if_ != nullptr) && (codec_ != nullptr))
|
||||||
{
|
{
|
||||||
myarray send = codec_->encode(0, 0, 0, data);
|
myarray send = codec_->encode(0, 0, 0, data);
|
||||||
|
191
prot_cmd/cmd_checkself.cpp
Normal file
191
prot_cmd/cmd_checkself.cpp
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
#include "prot_cmd/cmd_checkself.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|细分指令 |参数说明 |回复结果说明 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|电机归零(0x01) |无 |无 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|电机下降(0x02) |下降步数(2bytes,小端) |无 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|电机上升(0x03) |上升步数(2bytes,小端) |无 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|检桥丝电阻(0x04) |无 |小板地址+桥丝阻值(2bytes) |
|
||||||
|
| | |多块小板数据域追加相应数据 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|打开总线(0x05) |总线电压(2bytes,小端) |小板地址+总线电压(2bytes)(单位0.1V) |
|
||||||
|
| |(单位0.1V) |多块小板数据域追加相应数据 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|关闭总线(0x06) |无 |无 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|检总线电流(0x07) |无 |小板地址+总线电流(4bytes)(单位0.1uA)|
|
||||||
|
| | |多块小板数据域追加相应数据 |
|
||||||
|
+-----------------+-------------------------+----------------------------------------+
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 电机控制
|
||||||
|
int selfdev_checkself::dolater(int cmd, myarray data)
|
||||||
|
{
|
||||||
|
prot_m4 *m4 = protM4();
|
||||||
|
mycfg *cfg_=syscfg();
|
||||||
|
int subcmd=data[0];
|
||||||
|
if(subcmd>=1&&subcmd<=3){
|
||||||
|
connect(this, &selfdev_checkself::send_to_m4_signal, m4, &prot_m4::send_data_slot);
|
||||||
|
switch (subcmd)
|
||||||
|
{
|
||||||
|
case 0x01:
|
||||||
|
emit send_to_m4_signal("moterinit");
|
||||||
|
break;
|
||||||
|
case 0x02:
|
||||||
|
{
|
||||||
|
int count=data[1]|(data[2]<<8);
|
||||||
|
mystring s = mystring("moter %1").arg(count);
|
||||||
|
emit send_to_m4_signal(myarray(s.data()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
{
|
||||||
|
int count=data[1]|(data[2]<<8);
|
||||||
|
mystring s = mystring("moter %1").arg(-count);
|
||||||
|
emit send_to_m4_signal(myarray(s.data()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
myarray r;
|
||||||
|
r.append(char(0));
|
||||||
|
r.append(uint8_t(subcmd));
|
||||||
|
emit send_data_signal(0,r);
|
||||||
|
return 0;
|
||||||
|
}else{
|
||||||
|
pc_ret_cmd=0x50;
|
||||||
|
return selfdev_runtask::dolater(cmd, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 参数检测
|
||||||
|
myarray selfdev_checkself::cmd_pc_to_slave(myarray data)
|
||||||
|
{
|
||||||
|
myarray ret;
|
||||||
|
const task_def *table=nullptr;
|
||||||
|
uint16_t params[10]={0};
|
||||||
|
subcmd=data[0];
|
||||||
|
switch (subcmd)
|
||||||
|
{
|
||||||
|
case 0x04:
|
||||||
|
{
|
||||||
|
myarray d;
|
||||||
|
params[0]=0;
|
||||||
|
coder_add_task(d,"测量桥丝阻值",1,1,params);
|
||||||
|
coder_slave_pack(d,0x1f);
|
||||||
|
ret+=d;
|
||||||
|
// 检测模式3,只执行槽任务
|
||||||
|
ret.insert(0,uint8_t(3));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x05:
|
||||||
|
{
|
||||||
|
myarray d;
|
||||||
|
params[0]=data[1]|(data[2]<<8);
|
||||||
|
coder_add_task(d,"设置总线电压",1,1,params);
|
||||||
|
coder_slave_pack(d,0x1f);
|
||||||
|
ret+=d;
|
||||||
|
// 检测模式3,只执行槽任务
|
||||||
|
ret.insert(0,uint8_t(3));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
{
|
||||||
|
myarray d;
|
||||||
|
params[0]=data[1]|(data[2]<<8);
|
||||||
|
coder_add_task(d,"关总线",1,1,params);
|
||||||
|
coder_slave_pack(d,0x1f);
|
||||||
|
ret+=d;
|
||||||
|
// 检测模式3,只执行槽任务
|
||||||
|
ret.insert(0,uint8_t(3));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x07:
|
||||||
|
{
|
||||||
|
myarray d;
|
||||||
|
params[0]=data[1]|(data[2]<<8);
|
||||||
|
coder_add_task(d,"获取总线电流",1,1,params);
|
||||||
|
coder_slave_pack(d,0x1f);
|
||||||
|
ret+=d;
|
||||||
|
// 检测模式3,只执行槽任务
|
||||||
|
ret.insert(0,uint8_t(3));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 从机返回转pc
|
||||||
|
myarray selfdev_checkself::ret_slave_to_pc(QList<myarray> data)
|
||||||
|
{
|
||||||
|
myarray ret;
|
||||||
|
ret.append(uint8_t(0));
|
||||||
|
ret.append(uint8_t(subcmd));
|
||||||
|
switch (subcmd)
|
||||||
|
{
|
||||||
|
case 0x04:// 测量桥丝阻值
|
||||||
|
for (int i=0;i<data.size();i++)
|
||||||
|
{
|
||||||
|
myarray &sdata=data[i];
|
||||||
|
ret.append(sdata[0]);
|
||||||
|
myarray sret=coder_slave_find_ret_data(sdata.mid(2),1,2);
|
||||||
|
ret+=sret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x05:// 设置总线电压
|
||||||
|
for (int i=0;i<data.size();i++)
|
||||||
|
{
|
||||||
|
myarray &sdata=data[i];
|
||||||
|
ret.append(sdata[0]);
|
||||||
|
myarray sret=coder_slave_find_ret_data(sdata.mid(2),1,2);
|
||||||
|
ret+=sret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x06:// 关总线
|
||||||
|
break;
|
||||||
|
case 0x07:// 获取总线电流
|
||||||
|
for (int i=0;i<data.size();i++)
|
||||||
|
{
|
||||||
|
myarray &sdata=data[i];
|
||||||
|
ret.append(sdata[0]);
|
||||||
|
myarray sret=coder_slave_find_ret_data(sdata.mid(2),1,4);
|
||||||
|
ret+=sret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static HandlePc *get_selfdev_checkself(){
|
||||||
|
return new selfdev_checkself();
|
||||||
|
}
|
||||||
|
|
||||||
|
protpc_export(0x50, get_selfdev_checkself);
|
||||||
|
|
||||||
|
|
||||||
|
|
77
prot_cmd/cmd_checkself.h
Normal file
77
prot_cmd/cmd_checkself.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#ifndef cmd_checkerself_h__
|
||||||
|
#define cmd_checkerself_h__
|
||||||
|
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "prot_cmd/cmd_pc.h"
|
||||||
|
#include "base/check_cfg.h"
|
||||||
|
#include "elec/elec_judge.h"
|
||||||
|
#include "prot_cmd/cmd_coder.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
检测参数自检
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 电机 自研批检仪
|
||||||
|
class selfdev_checkself : public selfdev_runtask
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
selfdev_checkself():selfdev_runtask(){
|
||||||
|
pc_ret_cmd=0;
|
||||||
|
}
|
||||||
|
int dolater(int cmd, myarray data);
|
||||||
|
// pc指令转从机
|
||||||
|
myarray cmd_pc_to_slave(myarray data);
|
||||||
|
// pc指令生成从机列表
|
||||||
|
QList<int> cmd_pc_to_addrs(myarray data){
|
||||||
|
QList<int> addr_list;
|
||||||
|
addrs=0;
|
||||||
|
int len=syscfg()->slave_num;
|
||||||
|
for(int i=0;i<len;i++){
|
||||||
|
addr_list.append(i+1);
|
||||||
|
addrs|=1<<(i);
|
||||||
|
}
|
||||||
|
return addr_list;
|
||||||
|
}
|
||||||
|
// 从机发起命令
|
||||||
|
int cmd_slave(){
|
||||||
|
return 0x20;
|
||||||
|
}
|
||||||
|
// pc收到回复,返回0不回复
|
||||||
|
int cmd_pc_recv(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// 生成接收回复到pc
|
||||||
|
myarray cmd_pc_recv_to_pc(){
|
||||||
|
myarray r;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
// pc回复命令,返回0不回复
|
||||||
|
int cmd_pc_ret(){
|
||||||
|
return pc_ret_cmd;
|
||||||
|
}
|
||||||
|
// 从机返回转pc
|
||||||
|
myarray ret_slave_to_pc(QList<myarray> data);
|
||||||
|
protected:
|
||||||
|
int addrs;
|
||||||
|
int pc_ret_cmd;
|
||||||
|
int subcmd;
|
||||||
|
signals:
|
||||||
|
void send_to_m4_signal(myarray data);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@@ -14,7 +14,7 @@
|
|||||||
static const task_def g_ew_task_table[]={
|
static const task_def g_ew_task_table[]={
|
||||||
{"电源准备",0,1,10,0},
|
{"电源准备",0,1,10,0},
|
||||||
{"延时等待",1,1,2,1},
|
{"延时等待",1,1,2,1},
|
||||||
{"桥丝电阻测试",2,4,1,1},
|
{"测量桥丝阻值",2,4,1,1},
|
||||||
{"上电充能",3,2,3,2},
|
{"上电充能",3,2,3,2},
|
||||||
{"设置总线电压",4,1,1,1},
|
{"设置总线电压",4,1,1,1},
|
||||||
{"获取总线电流",5,1,0,2},
|
{"获取总线电流",5,1,0,2},
|
||||||
|
@@ -76,6 +76,13 @@ typedef struct{
|
|||||||
|
|
||||||
|
|
||||||
const task_def *coder_find_task(const char *str);
|
const task_def *coder_find_task(const char *str);
|
||||||
|
// 添加一个任务,返回0添加成功
|
||||||
|
int coder_add_task(myarray &d,const char *name,int slot_index,int task_index,uint16_t params[10]);
|
||||||
|
// 包装为一个小板的数据,返回0成功
|
||||||
|
// 包装前需要先添加任务
|
||||||
|
int coder_slave_pack(myarray &d,int addr);
|
||||||
|
// 找到指定任务序号的数据
|
||||||
|
myarray coder_slave_find_ret_data(myarray data,int task_index,int size);
|
||||||
|
|
||||||
|
|
||||||
// 赋码仪检测命令
|
// 赋码仪检测命令
|
||||||
|
@@ -907,7 +907,7 @@ void selfdev_runtask::timeout()
|
|||||||
busy=0;
|
busy=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 排序,再接收了从机数据之后
|
// 排序,在接收了从机数据之后
|
||||||
void selfdev_runtask::slave_sort(){
|
void selfdev_runtask::slave_sort(){
|
||||||
myarray temp;
|
myarray temp;
|
||||||
int slave_num=slave_acked.size();
|
int slave_num=slave_acked.size();
|
||||||
|
Reference in New Issue
Block a user