//头文件
#pragma once
#include "BaseSocket.h"
#include <afxtempl.h>
struct ChassisAction
{
char way;
char hSpeed;
char lSpeed;
char time;
};
typedef CArray<ChassisAction, ChassisAction&> ChassisArray;
class CCobotAIA1 :
public CBaseSocket
{
public:
CCobotAIA1();
~CCobotAIA1();
BOOL Platform_Up(char speed = 0x21);
BOOL Platform_Down(char speed = 0x21);
BOOL Platform_Left(char speed = 0x21);
BOOL Platform_Right(char speed = 0x21);
BOOL Platform_LeftUp(char speed = 0x21);
BOOL Platform_LeftDown(char speed = 0x21);
BOOL Platform_RightUp(char speed = 0x21);
BOOL Platform_RightDown(char speed = 0x21);
BOOL Platform_Stop();
BOOL Lift_Up();
BOOL Lift_Down();
BOOL Lift_Stop();
void Chassis_Forward(char hSpeed=0xFF, char lSpeed=0x38);
void Chassis_Back(char hSpeed = 0x00, char lSpeed = 0xC8);
void Chassis_LeftForward(char hSpeed = 0xFF, char lSpeed = 0x38);
void Chassis_RightForward(char hSpeed = 0xFF, char lSpeed = 0x38);
void Chassis_LeftBack(char hSpeed = 0x00, char lSpeed = 0xC8);
void Chassis_RightBack(char hSpeed = 0x00, char lSpeed = 0xC8);
void Chassis_Stop();
void Chassis_Left();
void Chassis_Right();
BOOL SetAlarmLampState(BOOL bAlarm = 1);
BOOL SetAlarmSoundState(BOOL bAlarm);
BOOL SetHeadLightState(BOOL bOpen);
BOOL SetTailLightState(BOOL bOpen);
BOOL SetRunningPlan(ChassisArray & chassisAry);
};
//cpp文件
#include "stdafx.h"
#include "CobotAIA1.h"
char g_pBuff[14] = {0};
BOOL g_bRun = FALSE;
UINT SendThread(LPVOID lp)
{
CCobotAIA1 *pCombot = (CCobotAIA1 *)lp;
while (g_bRun)
{
pCombot->SendSocketData(g_pBuff, 14);
Sleep(10);
}
return 0;
}
CCobotAIA1::CCobotAIA1()
{
}
CCobotAIA1::~CCobotAIA1()
{
}
BOOL CCobotAIA1::Platform_Up(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;
chBuff[5] = 0x00;
chBuff[6] = 0x00;
chBuff[7] = 0x00;
chBuff[8] = 0x00;
chBuff[9] = 0x00;
chBuff[10] = 0x08;
//chBuff[11] = 0x21;
chBuff[11] = speed;
chBuff[12] = 0x29;
return SendSocketData(chBuff, 13);
}
BOOL CCobotAIA1::Platform_Down(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;
chBuff[5] = 0x00;
chBuff[6] = 0x00;
chBuff[7] = 0x00;
chBuff[8] = 0x00;
chBuff[9] = 0x00;
chBuff[10] = 0x10;
//chBuff[11] = 0x21;
chBuff[11] = speed;
chBuff[12] = 0x31;
return SendSocketData(chBuff, 13);
}
BOOL CCobotAIA1::Platform_Left(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;
chBuff[5] = 0x00;
chBuff[6] = 0x00;
chBuff[7] = 0x00;
chBuff[8] = 0x00;
chBuff[9] = 0x00;
chBuff[10] = 0x04;
//chBuff[11] = 0x21;
chBuff[11] = speed;
chBuff[12] = 0x25;
return SendSocketData(chBuff, 13);
}
BOOL CCobotAIA1::Platform_Right(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;