396 lines
11 KiB
C
396 lines
11 KiB
C
|
#ifndef __DATADEF_H__
|
|||
|
#define __DATADEF_H__
|
|||
|
|
|||
|
#include "typedef.h"
|
|||
|
#include "config.h"
|
|||
|
//-------------------------------------------------------------------------
|
|||
|
|
|||
|
#define PATTERN_LARGE_NEEDLES 1280000
|
|||
|
|
|||
|
// 绝对位置数据
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u8 ctrl; //控制字节
|
|||
|
u8 attr; //属性字节
|
|||
|
WORD action;//控制动作
|
|||
|
double ax; //X位置
|
|||
|
double ay; //Y位置
|
|||
|
double ar; //R角度
|
|||
|
|
|||
|
}__attribute__ ((packed)) DsAbsItem;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
QList<DsAbsItem> absItemList;
|
|||
|
|
|||
|
}LineItem;
|
|||
|
|
|||
|
// 画图格式数据
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u8 ctrl;//控制字节
|
|||
|
u8 attr;//属性字节
|
|||
|
|
|||
|
WORD action;// 附加动作
|
|||
|
s16 bx, by;//绘制起点
|
|||
|
s16 ex, ey;//绘制终点
|
|||
|
s16 ar;//角度
|
|||
|
u32 rgb;
|
|||
|
|
|||
|
}__attribute__ ((packed)) DispItem;
|
|||
|
|
|||
|
|
|||
|
//机头间距表地址
|
|||
|
typedef struct {
|
|||
|
unsigned char iswork; //1-8机头是否工作
|
|||
|
unsigned char doubleHead; //双机头
|
|||
|
unsigned short int distance1_2; //机头2和机头1的机头间距(单位0.1mm,范围0-5000.0)
|
|||
|
unsigned short int distance1_3;
|
|||
|
unsigned short int distance1_4;
|
|||
|
unsigned short int distance1_5;
|
|||
|
unsigned short int distance1_6;
|
|||
|
unsigned short int distance1_7;
|
|||
|
unsigned short int distance1_8;
|
|||
|
|
|||
|
} HeadTable;
|
|||
|
|
|||
|
// 画图格式数据
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u8 ctrl;//控制字节
|
|||
|
u8 attr;//属性字节
|
|||
|
|
|||
|
WORD action;// 附加动作
|
|||
|
s16 bx, by;//绘制起点
|
|||
|
s16 ex, ey;//绘制终点
|
|||
|
s16 ar;//角度
|
|||
|
HeadTable headtable;
|
|||
|
u32 rgb;
|
|||
|
|
|||
|
}__attribute__ ((packed)) Disp_HeadItem;
|
|||
|
|
|||
|
// 执行数据定义
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u8 ctrl; // 控制字节
|
|||
|
u8 attr; // 属性字节
|
|||
|
s16 dx; // X偏移
|
|||
|
s16 dy; // Y偏移
|
|||
|
s16 dr; // R偏移
|
|||
|
u16 len; // xy分量合成长度
|
|||
|
u8 action[2]; //附加动作
|
|||
|
|
|||
|
u8 rev[4]; // 保留
|
|||
|
|
|||
|
}__attribute__ ((packed)) DataItem, Ds16Item;
|
|||
|
|
|||
|
// ds8格式
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u8 ctrl; // 控制字节
|
|||
|
u8 attr; // 属性字节
|
|||
|
s16 dx; // X偏移
|
|||
|
s16 dy; // Y偏移
|
|||
|
s16 dr; // R偏移
|
|||
|
|
|||
|
}__attribute__ ((packed)) Ds8Item;
|
|||
|
|
|||
|
// 兼容dsr格式
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u8 ctrl; // 控制字节
|
|||
|
u8 attr; // 属性字节
|
|||
|
u8 dx; // X偏移
|
|||
|
u8 dy; // Y偏移
|
|||
|
|
|||
|
}__attribute__ ((packed)) DsrItem, Ds4Item;
|
|||
|
|
|||
|
|
|||
|
// 双字节压缩格式
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
s8 cdx; // X数据
|
|||
|
s8 cdy; // Y数据
|
|||
|
|
|||
|
/*
|
|||
|
格式定义
|
|||
|
cdx x分量控制数据
|
|||
|
cdy y分量控制数据
|
|||
|
|
|||
|
每个字节的最低位为控制位,高7个位为数据位。数据位的最高位是符号位。
|
|||
|
|
|||
|
两个控制位合在一起形成4种控制数据,定义如下:
|
|||
|
cdx.0 cdy.0
|
|||
|
0 0 缝纫数据,数据范围从-128 -- +126, 只有偶数可用(精度0.2mm),单位0.1mm
|
|||
|
0 1 空走数据,数据范围从-128 -- +126, 只有偶数可用(精度0.2mm),单位0.1mm
|
|||
|
1 0 大步空走数据,数据范围从-128 -- +126, 只有偶数可用(精度2mm),单位1mm
|
|||
|
1 1 控制数据,数据位定义为控制码和参数 cdx 为控制码, cdx 为参数
|
|||
|
|
|||
|
*/
|
|||
|
}__attribute__ ((packed)) ToBItem, Ds2Item;
|
|||
|
|
|||
|
|
|||
|
// ctrl 定义
|
|||
|
// 控制字节, 作为功能码,定义如下
|
|||
|
|
|||
|
#define DATA_NULL 0x00 // 文件结束
|
|||
|
#define DATA_SEWING 0x01 // 缝纫数据, 该数据需要缝纫机针扎一次(主轴可以转动多圈(如果有跳针功能的话)), 同时 X, Y,R 偏移运动dx,dy,dr, 框步进式运动或连续运动
|
|||
|
#define DATA_OFFSET 0x02 // 偏移数据, 该数据只移动 X, Y,R 偏移 dx,dy,dr,连续运动
|
|||
|
#define DATA_CUTTING 0x03 // 切刀数据, 该数据需要切刀先运转,同时 X, Y,R 偏移 dx,dy,dr,根据切刀类型选择动框方式
|
|||
|
#define DATA_LASER 0x04 // 激光数据, 该数据需要激光出光, 同时X, Y,R偏移 dx,dy,dr,框连续运动,激光强度和运动线速度有关系
|
|||
|
#define DATA_DRAWING 0x05 // 记号数据, 该数据需要记号笔先放下来, 同时X, Y,R偏移dx,dy,dr,框连续运动
|
|||
|
#define DATA_SEWING_R 0x06 // 右机头缝纫,该数据需要缝纫机针扎一次(主轴可以转动多圈(如果有跳针功能的话)), 同时 X, Y,R 偏移运动dx,dy,dr, 框步进式运动或连续运动
|
|||
|
|
|||
|
#define DATA_SECF_SEW 0x11 // 第二框缝纫
|
|||
|
#define DATA_SECF_OFST 0x12 // 第二框偏移
|
|||
|
|
|||
|
#define DATA_SECF_SEW_R 0x16 // 第二框右机头缝纫,该数据需要缝纫机针扎一次(主轴可以转动多圈(如果有跳针功能的话)), 同时 X, Y,R 偏移运动dx,dy,dr, 框步进式运动或连续运动
|
|||
|
|
|||
|
// 兼容DSR控制码
|
|||
|
#define DATA_SYNCSEW 0x07 // 同步缝纫数据, 该数据需要缝纫机针扎一次, 同时 X, Y,R 偏移运动 dx,dy,dr,X2, Y2 也运动 dx,dy,框步进式运动或连续运动
|
|||
|
#define DATA_PAUSE_OLD 0x08 // 暂停
|
|||
|
#define DATA_ANGLE_OLD 0x09 // 拐点
|
|||
|
#define DATA_CUT_OLD 0x0A // 剪线
|
|||
|
#define DATA_END_OLD 0x10 // 结束码
|
|||
|
|
|||
|
#define DATA_JUMP 0x0B // 跳针数据,该数据要求缝纫机主轴不动, 但 X, Y,R 偏移运动 dx,dy,dr, 框步进式运动或连续运动
|
|||
|
#define DATA_PUNCH 0x0C // 冲孔数据, 该数据需要冲孔主轴运转一圈,同时 X, Y,R 偏移 dx,dy,dr,
|
|||
|
#define DATA_EMB 0x0D // 绣花数据,该数据需要平绣针扎一次, 同时 X, Y,偏移运动dx,dy, 框步进式运动
|
|||
|
#define DATA_CHGND_OLD 0x0E // 换色功能码 lxs 20220628添加
|
|||
|
#define DATA_SYNCOFST 0x0F // 同步偏移数据
|
|||
|
|
|||
|
#define DATA_MILLING 0x21 // 铣刀数据
|
|||
|
#define DATA_DRILL 0x22 // 钻孔数据
|
|||
|
#define DATA_RKNIFE 0x23 // 圆刀数据, 该数据需要震刀先运转,同时 X, Y,R 偏移 dx,dy,dr,
|
|||
|
#define DATA_SKNIFE 0x24 // 震刀数据, 该数据需要震刀先运转,同时 X, Y,R 偏移 dx,dy,dr,
|
|||
|
|
|||
|
#define DATA_END 0x80 // 结束码
|
|||
|
#define DATA_PAUSE 0x81 // 暂停功能码
|
|||
|
#define DATA_CHGND 0x82 // 换色
|
|||
|
#define DATA_CUTTRD 0x83 // 剪线功能码
|
|||
|
|
|||
|
#define DATA_ANGLE 0x89 // 拐点
|
|||
|
|
|||
|
// atrr, 属性字节,作为运动属性字节
|
|||
|
|
|||
|
// 缝纫针步的属性定义:
|
|||
|
// dx, x向偏移值, 有符号数, 范围为 -32768--32767, 单位为 0.01mm
|
|||
|
// dy, y向偏移值, 有符号数, 范围为 -32768--32767, 单位为 0.01mm
|
|||
|
// dr, r向偏移值, 有符号数, 范围为 -32768--32767, 单位为 0.0001 弧度
|
|||
|
// len, xy 分量的合成长度,无符号数,范围0--65535, 单位为 0.01mm
|
|||
|
|
|||
|
#define HEAD_NAME_STR_LEN 0x20
|
|||
|
#define HEAD_FIX_INFO_LEN 0x32
|
|||
|
|
|||
|
|
|||
|
#pragma pack(1)//设定为1字节对齐
|
|||
|
//ds16头文件-发给下位机的
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
// 0x00
|
|||
|
char fileName[32]; // 文件名称
|
|||
|
|
|||
|
// 0x20
|
|||
|
u32 dataSize; // 数据字节数
|
|||
|
u32 itemNums; // 数据项个数
|
|||
|
u16 bytesPerItem; // 每项占的字节数
|
|||
|
u16 bytesPerBlk; // 数据内容划分块大小
|
|||
|
u32 dataChecksum; // 数据累加校验和
|
|||
|
u16 checkCrc; // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值)
|
|||
|
|
|||
|
// 0x32
|
|||
|
u16 rev0;
|
|||
|
u32 fileid; // 文件唯一标识符,识别是否为同一个文件
|
|||
|
|
|||
|
// 0x38
|
|||
|
u8 reserved1[0x40-0x38]; // 保留区1
|
|||
|
|
|||
|
// 0x40
|
|||
|
s32 anchorX; // 定位点坐标X
|
|||
|
s32 anchorY; // 定位点坐标Y
|
|||
|
|
|||
|
// 0x48
|
|||
|
s32 beginX; // 数据起点坐标X
|
|||
|
s32 beginY; // 数据起点坐标Y
|
|||
|
s32 beginR; // 数据起点坐标R
|
|||
|
|
|||
|
// 0x54
|
|||
|
s32 minX;
|
|||
|
s32 maxX;
|
|||
|
s32 minY;
|
|||
|
s32 maxY; // 轮廓范围
|
|||
|
|
|||
|
// 0x64
|
|||
|
u32 sizeX;
|
|||
|
u32 sizeY; // 裁片大小
|
|||
|
|
|||
|
// 0x6C
|
|||
|
s32 anchorX2; // 定位点坐标X2
|
|||
|
s32 anchorY2; // 定位点坐标Y2
|
|||
|
s32 beginX2; // 数据起点坐标X2
|
|||
|
s32 beginY2; // 数据起点坐标Y2
|
|||
|
s32 beginR2; // 数据起点坐标Z2
|
|||
|
|
|||
|
// 0x80
|
|||
|
u32 runAct; // 附加动作,
|
|||
|
// bit0: 0:完成后不拍照 1:完成后拍照
|
|||
|
|
|||
|
// 0x84
|
|||
|
u8 reserved3[0x100-0x84];
|
|||
|
|
|||
|
// 100
|
|||
|
s32 pullMateOffset[6];
|
|||
|
u8 reserved4[0x200-0x118];
|
|||
|
|
|||
|
// 0x200
|
|||
|
u8 switchNeedleTable[0x400-0x200]; // 色序设定表, 支持512个色序设定
|
|||
|
|
|||
|
}__attribute__ ((packed)) DataDs16FileHead;//下发给主控的ds16文件头
|
|||
|
#pragma pack(1)//恢复对齐状态
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
// 0
|
|||
|
char HMIVerStr[16]; // 界面版本
|
|||
|
|
|||
|
// 4
|
|||
|
u32 machineNumber; // 机器编号
|
|||
|
|
|||
|
// 5
|
|||
|
u16 motorNum; //电机个数
|
|||
|
u16 debugProgress; //调试进度
|
|||
|
// 6
|
|||
|
char fileName[32]; // 文件名称
|
|||
|
|
|||
|
#if(0)
|
|||
|
// 52
|
|||
|
char sensorStartBtn; // 启动按钮1
|
|||
|
char sensorStopBtn; // 暂停按钮1
|
|||
|
char sensorJogBtn; // 点动按钮1
|
|||
|
char sensorMainFrameXZeroPos; // 主框架X零位
|
|||
|
char sensorMainFrameYZeroPos; // 主框架Y零位
|
|||
|
char sensorMainFrameXNegLimit; // 主框架X负限位
|
|||
|
char sensorMainFrameYNegLimit; // 主框架Y负限位
|
|||
|
char sensorMainFrameXPosLimit; // 主框架X正限位
|
|||
|
char sensorMainFrameYPosLimit; // 主框架Y正限位
|
|||
|
char sensorScissorsReturn; // 剪刀回位
|
|||
|
#endif
|
|||
|
|
|||
|
//14
|
|||
|
char deliveryTime[32]; //交付日期
|
|||
|
|
|||
|
//22
|
|||
|
u32 workProgress; //机器工作进度(花样执行进度)
|
|||
|
|
|||
|
//26
|
|||
|
u32 rev2[256-26];
|
|||
|
|
|||
|
} __attribute__ ((packed)) HMILotData; // 界面物联网数据
|
|||
|
|
|||
|
//-------------------------------------------------------------------------
|
|||
|
|
|||
|
|
|||
|
// 升级文件头
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
// 0x00
|
|||
|
char fileName[32]; // 文件名称
|
|||
|
// 0x20
|
|||
|
u32 dataSize; // 数据字节数
|
|||
|
u32 dataChecksum; // 数据累加校验和
|
|||
|
|
|||
|
// 0x28
|
|||
|
u8 reserved1[0x30-0x28]; // 保留区1
|
|||
|
// 0x30
|
|||
|
u8 reserved2[0x64-0x30]; // 保留区1
|
|||
|
|
|||
|
// 0x64
|
|||
|
u8 reserved3[0x80-0x64]; // 保留区2
|
|||
|
|
|||
|
// 0x80
|
|||
|
u8 reserved4[0x100-0x80];
|
|||
|
}__attribute__ ((packed)) AppFileHead;
|
|||
|
|
|||
|
|
|||
|
// 文件参数结构
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
// 0x00
|
|||
|
u8 hdIdenti[0x40];
|
|||
|
|
|||
|
// 0x40
|
|||
|
s32 anchorX; // 定位点坐标X
|
|||
|
s32 anchorY; // 定位点坐标Y
|
|||
|
// 0x48
|
|||
|
s32 beginX; // 数据起点坐标X
|
|||
|
s32 beginY; // 数据起点坐标Y
|
|||
|
s32 beginR; // 数据起点坐标Z
|
|||
|
|
|||
|
// 0x54
|
|||
|
s32 minX;
|
|||
|
s32 maxX;
|
|||
|
s32 minY;
|
|||
|
s32 maxY; // 轮廓范围
|
|||
|
|
|||
|
// 0x64
|
|||
|
u32 sizeX;
|
|||
|
u32 sizeY; // 裁片大小
|
|||
|
|
|||
|
// 0x6C
|
|||
|
s32 anchorX2; // 定位点坐标X2
|
|||
|
s32 anchorY2; // 定位点坐标Y2
|
|||
|
s32 beginX2; // 数据起点坐标X2
|
|||
|
s32 beginY2; // 数据起点坐标Y2
|
|||
|
s32 beginR2; // 数据起点坐标Z2
|
|||
|
|
|||
|
// 0x80
|
|||
|
u8 reserved0[0x200-0x80];
|
|||
|
// 0x200
|
|||
|
u8 reserved1[0x400-0x200];
|
|||
|
|
|||
|
}__attribute__ ((packed)) DataFilePara;
|
|||
|
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
s32 anchorX; // 定位点坐标X
|
|||
|
s32 anchorY; // 定位点坐标Y
|
|||
|
s32 beginX; // 数据起点坐标X
|
|||
|
s32 beginY; // 数据起点坐标Y
|
|||
|
|
|||
|
}__attribute__ ((packed)) DataFilePos;
|
|||
|
//-------------------------------------------------------------------------
|
|||
|
|
|||
|
// 文件执行参数结构
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u32 newIdx;
|
|||
|
s32 newXPos;
|
|||
|
s32 newYPos;
|
|||
|
s32 newRPos;
|
|||
|
u32 newColorIdx; // 新针位
|
|||
|
u32 rev[256-5];
|
|||
|
}__attribute__ ((packed)) FileExecPara;
|
|||
|
|
|||
|
//-------------------------------------------------------------------------
|
|||
|
|
|||
|
//参数文件头
|
|||
|
struct ParaFile
|
|||
|
{
|
|||
|
unsigned char s_head[4] ; // 默认 PARA
|
|||
|
int s_type ; // 默认 0
|
|||
|
int s_len ; // 数据 默认 4096
|
|||
|
|
|||
|
unsigned int s_para_buff[1024] ; //工作 参数体
|
|||
|
|
|||
|
unsigned short s_crc ; //参数体的CRC
|
|||
|
|
|||
|
unsigned short rev ; //预留 保持 结构体四字节对齐
|
|||
|
};
|
|||
|
|
|||
|
//-------------------------------------------------------------------------
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|