Qt继电器控制板代码

本文档展示了如何使用Qt编写代码来初始化、控制和获取继电器控制板的状态。通过设置串口参数,发送特定指令来打开或关闭继电器,并验证设备响应以确保命令正确执行。
摘要由CSDN通过智能技术生成
#ifndef ZIOMODULE_H
#define ZIOMODULE_H

#include <QObject>
#include <QDebug>
#include <QSerialPort>
#include <QSerialPortInfo>

#define ADDR_DEST   0x01
const uchar zresponse_failed[]={0xA3,0x0D,0x0A,};
const uchar zcmd_output1_open[]={0x3A,0x88,ADDR_DEST,0x01,0x00,0x0D,0x0A};
const uchar zcmd_output1_close[]={0x3A,0x88,ADDR_DEST,0x01,0xFF,0x0D,0x0A};
const uchar zcmd_output2_open[]={0x3A,0x88,ADDR_DEST,0x02,0x00,0x0D,0x0A};
const uchar zcmd_output2_close[]={0x3A,0x88,ADDR_DEST,0x02,0xFF,0x0D,0x0A};
const uchar zcmd_output3_open[]={0x3A,0x88,ADDR_DEST,0x03,0x00,0x0D,0x0A};
const uchar zcmd_output3_close[]={0x3A,0x88,ADDR_DEST,0x03,0xFF,0x0D,0x0A};
const uchar zcmd_output4_open[]={0x3A,0x88,ADDR_DEST,0x04,0x00,0x0D,0x0A};
const uchar zcmd_output4_close[]={0x3A,0x88,ADDR_DEST,0x04,0xFF,0x0D,0x0A};
const uchar zresponse_output_open_close[]={0xA3,ADDR_DEST,0x00,0xFF,0x0D,0x0A};

//get all relays status.
const uchar zcmd_get_all_relay_status[]={0x3A,0x99,ADDR_DEST,0x00,0x0D,0x0A};
const uchar zresponse_all_relay_status[]={0xA3,ADDR_DEST,0xFF,0xFF,0xFF,0xFF,0x0D,0x0A};
//get all input status.
const uchar zcmd_get_all_inputs_status[]={0x3A,0x98,ADDR_DEST,0x00,0x0D,0x0A};
const uchar zresponse_all_inputs_status[]={0xA5,ADDR_DEST,0xFF,0xFF,0xFF,0xFF,0x0D,0x0A};

class ZIOModule : public QObject
{
    Q_OBJECT
public:
    typedef enum
    {
        OutputPort1=1,
        OutputPort2=2,
        OutputPort3=3,
        OutputPort4=4,
    }ZOutputPort;
    //portName: ttyUSB0.
    //responseTimeout: the wait time for the device response.
    explicit ZIOModule(QString portName,qint32 responseTimeOut=2000,QObject *parent = 0);
    ~ZIOModule();

    //execute serial port initial operations.
    bool ZDoInit();

    //do some clean work here.
    void ZCleanUp();

    //set output status of specified port.
    bool ZSetOutputPort(ZOutputPort port,bool bOpen);

    //get all output port status.
    qint32 ZGetOutputPortsS
市面上大部分投影机的串口控制码,3M…………………………………………………………………1 ASK………………………………………………………………2 BARCO……………………………………………………………4 BOXLIGHT………………………………………………………4 CHRISTIE…………………………………………………………5 DIGITEL……………………………………………………………6 EIKI…………………………………………………………7 INFOCUS…………………………………………………………10 LENOVO…………………………………………………………14 LG…………………………………………………………………15 LIESEGANG………………………………………………………15 LUMENS…………………………………………………………15 MITSUBISHI……………………………………………………16 NEC………………………………………………………………17 OPTOMA…………………………………………………………18 PLUS………………………………………………………………19 POLAROID………………………………………………………19 PROJECTIONDESIGN……………………………………………19 PROXIMA…………………………………………………………20 VIEWSONIC………………………………………………………23 爱普生……………………………………………………………23 奥视………………………………………………………………27 东芝………………………………………………………………28 飞浰普……………………………………………………………30 富士通……………………………………………………………31 惠普………………………………………………………………31 佳能………………………………………………………………32 明基………………………………………………………………33 日立………………………………………………………………35 三洋………………………………………………………………36 胜利………………………………………………………………40 松下………………………………………………………………41 索尼………………………………………………………………42 夏普………………………………………………………………43
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值