Files
EF3-Interface/PcDmis/Base/Interfac/Msi/Hsi/KeyenceTM065/KeyenceTM065_Proto.h
T
TAO Cheng 5a8e27e70d Merge
2013-07-22 14:34:50 +08:00

214 lines
5.8 KiB
C++

// protocol for control SevenOcean's Machine
//
//////////////////////////////////////////////////////////////////////
#ifndef AFX_KEYENCE_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
#define AFX_KEYENCE_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "..\..\..\..\..\ThirdParty\UsbSupport\LibUsb_Win\Include\lusb0_usb.h"
#include "..\KeyenceTM065\KeyenceStatus.h"
#define _CMD0_0800 0x08000000
#define _CMD0_0C00 0x0c000000 // -> 0704 Reply 0800 0705
// -> 0710 Reply 0c00 0711
// -> 071a Reply 8400 071b
#define _CMD0_100a 0x100a0000 // -> 0730 Reply 0c00 0731
#define _CMD0_1400 0x14000000 // ???? Send 4 bytes 1400,
// then send 200 bytes
// Request 40000 bytes image
#define _CMD0_3000 0x30000000 // -> 0730 Reply 0c00 0731
#define _CMD0_4800 0x48000000 // -> 0730 Reply 0c00 0731
#define _CMD0_4c00 0x4c000000 // -> 0730 Reply 0c00 0731
#define _CMD1_0730 0x07300000
#define _CMD1_0731 0x07310000
#define MAX_KEYENCE_EP_BUFF_SIZE 0X40000
#define USB_ENDPOINT_TYPE_CONTROL 0
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
#define USB_ENDPOINT_TYPE_BULK 2
#define USB_ENDPOINT_TYPE_INTERRUPT 3
#define USB_DEVICE_DESCRIPTOR_TYPE 1
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
// Device configuration and interface id.
#define KEYENCE_USB_CONFIG 1
#define KEYENCE_USB_INTF 0
#define EP_KEYENCE_01 0x01
#define EP_KEYENCE_82 0x82
#pragma pack(push)
#pragma pack(1)
#define KEYENCE_VID 0x0720
#define KEYENCE_PID 0x0015
struct struct_ep
{
unsigned char _iEP;
unsigned char *_buff;
BYTE *_bin;
int _cmd0;
int _cmd1;
int _send_size;
int _recv_size;
void *_async_context;
};
struct TM_PRS_BUFF {
struct TM_PRS_HDR {
char _tm_name[20];
unsigned char _tm_id[4];
} _tm_hdr;
struct TM_PRS_PROG {
unsigned char _pid[4];
DWORD _nbr;
char _name[16];
BYTE _trigger_mode; // Ext/Cont
BYTE _int_prevention; // ON/Off
BYTE _trigger_rate; // ON/OFF
BYTE _unk1;
unsigned char _unk2[4];
struct TM_HEAD {
BYTE _x_measure_range;
BYTE _y_measure_range;
BYTE _threshold;
BYTE _unk1; // Not used
struct TM_MASK {
BYTE _mk_type[4];
short int _mk_x1; // Triangle has three pairs, rectangle has two pairs.
short int _mk_y1;
short int _mk_x2;
short int _mk_y2;
short int _mk_x3;
short int _mk_y3;
} _tm_mask[5];
} _tm_head[2];
BYTE _unk3[4];
BYTE _unk4[4];
struct TM_CORR {
BYTE _unk1[4];
short int _i1;
short int _i2;
short int _i3;
short int _i4;
BYTE _unk5[4];
BYTE _unk6[4];
BYTE _unk7[4];
BYTE _unk8[4];
BYTE _unk9[4];
BYTE _unk10[4];
} _tm_head_corr[2];
struct TM_CORR1 {
BYTE _img_reg;
BYTE _img_src_speed;
BYTE _img_src_ang;
BYTE _img_corr_val;
BYTE _unk4[4];
short int _i[12];
BYTE _unk5[4];
BYTE _unk6[4];
short int _i1[4];
BYTE _unk7[4];
BYTE _unk8[4];
BYTE _unk9[4];
} _tm_head_corr1[2];
BYTE _meas_type;
BYTE _unk_type_1;
BYTE _a_b_calculation;
BYTE _unk_type_3;
BYTE _unk11[4];
short int _x1;
short int _y1;
short int _x2;
short int _y2;
BYTE _unk5[1008];
struct TM_OUT
{
char _out_name[16];
BYTE _unk1[4];
BYTE _ave_meas; // bin pos;
BYTE _alarm;
BYTE _meas_mode;
BYTE _min_disp_unit;
long _unk_scale1;
long _meas_input_1_v1;
long _meas_input_1_d1;
long _meas_input_2_v2;
long _meas_input_2_d2;
long _unk_scale6;
long _unk_scale7;
long _offset;
long _tol_upper_limit;
long _tol_lower_limit;
} _tm_out[16];
BYTE _tm_timing_term_byte[16];
BYTE _tm_zero_term_byte[16];
BYTE _tm_binary_output_byte[16];
BYTE _unk_flag[4];
struct {
long _meas_val_1;
long _output_voltage_1;
long _meas_val_2;
long _output_voltage_2;
} _tm_analog[2];
BYTE _storage;
BYTE _image_storage_head;
BYTE _image_storage_mode;
BYTE _unk_flag11;
BYTE _image_storage_no_data_pts;
BYTE _image_storage_skipping;
BYTE _unk_flags2[2];
BYTE _auto_send[16]; //
BYTE _data_out_timing;
BYTE _unk_flags3[3];
long _checksum;
} _tm_prs[16];
BYTE _tm_unk[580];
struct TM_TRLR {
BYTE _aaa[4];
DWORD _trailer[33*8];
BYTE _a8a[4];
} _tm_trailer;
};
//======================================================================================
class CKeyenceTM065_Proto
{
public:
//
CKeyenceTM065_Proto();
virtual ~CKeyenceTM065_Proto();
struct_ep ep_buff;
usb_dev_handle *g_dev;
int Init_Keyence();
int Exit_Keyence();
void _process_rcv_transfer_data();
usb_dev_handle* _open_usb_dev(void);
int _usb_reset(void);
int _start_machine();
int _shutdown_machine();
int _send_usb_data();
int _send_cmd_KEYENCE_CMD_GET_DATA();
int _process_KEYENCE_CMD_GET_DATA();
int _get_image();
int _put_program();
int _get_program();
int _init_program();
int _read_env();
int _write_env();
int _set_config(); // sets trigger etc.
int _replay_capture(CString cFileName);
int _read_prs_file(CString cFileName);
TM_PRS_BUFF TM_Buff;
};
#endif