コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: httpftpli/mdimh
void MainWindow::setup(){
    cntnumber = 1;
    QWidget *widget = new QWidget(this);
    QHBoxLayout *layout = new QHBoxLayout(widget);
    layout->addStretch(20);
    layout->addWidget(formheadl);
    layout->addStretch(20);
#if DUAL_SYSTEM
    layout->addWidget(formheadr);
    layout->addStretch(20);
    widget->setFixedSize(780,280);
    widget->move(10,80);
#else
    widget->setFixedSize(460,280);
    widget->move(170,80);
#endif

    connect(&hmiData,SIGNAL(time1sOuted()),this,SLOT(Timeout1s()));
    connect(&hmiData,SIGNAL(clothFinishCountChanged(int)),label_FinishCount,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(clothSetCountChanged(int)),label_setCount,SLOT(setNum(int)));
    connect(&patternData,SIGNAL(patternChanged(QString,QString)), SLOT(onpatternChange(QString,QString)));
    connect(&hmiData,SIGNAL(hmi_loopend(int)),label_loopEnd,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopleft(int)),label_loopLeft,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopStart(int)),label_loopStart,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopend(int)),label_loopEnd,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopTatal(int)),label_loopCount,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_cntNumber(unsigned short)),SLOT(runPatternRowChange(unsigned short)));
    connect(&hmiData,SIGNAL(hmi_jitouxiangduizhengshu(int)),label_zwz,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(xtGuilingError()),SLOT(onXtGuilingError()));
    connect(&hmiData,SIGNAL(xtRunOrGuiling(bool)),qMdPushButton_5,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(lineLock(bool)),qMdPushButton_6,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(speedLimit(bool)),qMdPushButton_8,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(stopPerOne(bool)),qMdPushButton_9,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(alarmLimit(bool)),qMdPushButton_10,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(shazuiUp(bool)),qMdPushButton_11,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(runing(bool)),SLOT(onHmidataRuning(bool)));
    connect(&hmiData,SIGNAL(powerDown()),SLOT(onPowerDown()));
    connect(&paramaData,SIGNAL(changed()),SLOT(onParamChanded()));
    azllist<<tr("空")<<tr("翻针")<<tr("编织");
    hzllist<<tr("空")<<tr("吊目")<<tr("接针")<<tr("吊目2")<<tr("编松2");
#if DUAL_SYSTEM
    connect(&hmiData,SIGNAL(sigDankouLock(bool)),SLOT(onDankouLock(bool)));
    label_dankoulock->setText(hmiData.dankouLock()?tr("锁定"):tr("不锁定"));
#else
    frame_dankoulock->hide();
#endif

}
コード例 #2
0
ファイル: Sim900.cpp プロジェクト: vesteraas/Sim900
void Sim900::process_line(char *line) {
    static int smsReceived;
    
    if (prefix("+CMT: ", line)) {
        smsReceived = true;
        powered = true;
        
        char *tmp = (char *)malloc((strlen(line) - 6 + 1) * sizeof(char));
        
        memcpy(tmp, &line[6], strlen(line) - 6 + 1);
        
        char **sms = split(tmp);
        
        strcpy(lastSMSFrom, sms[0]);
        free(sms);
        free(tmp);
    } else if (prefix("+CLIP: ", line)) {
        powered = true;
        char *tmp = (char *)malloc((strlen(line) - 7 + 1) * sizeof(char));
        
        memcpy(tmp, &line[7], strlen(line) - 7 + 1);
        
        char **clip = split(tmp);
        
        strcpy(callerId, clip[0]);
        
        free(clip);
        free(tmp);
    } else {
        if (strncmp(line, "OK", 2) == 0) {
            okReceived = true;
            errorReceived = false;
            powered = true;
        } else if (strncmp(line, "ERROR", 5) == 0) {
            okReceived = false;
            errorReceived = true;
            powered = true;
        } else if (strncmp(line, "RING", 4) == 0) {
            okReceived = false;
            errorReceived = true;
            powered = true;
            if (onRing) {
                if (callerId && callerId[0] == '\0') {
                    onRing(NULL);
                } else {
                    onRing(callerId);
                }
            }
        } else if (strncmp(line, "NO CARRIER", 10) == 0) {
            okReceived = false;
            errorReceived = true;
            powered = true;
            if (onNoCarrier) {
                onNoCarrier();
            }
        } else if (strncmp(line, "Call Ready", 10) == 0) {
            okReceived = false;
            errorReceived = false;
            ready = true;
            powered = true;
            if (onCallReady) {
                onCallReady();
            }
        } else if (strncmp(line, "NORMAL POWER DOWN", 10) == 0) {
            okReceived = false;
            errorReceived = false;
            ready = false;
            powered = false;
            if (onPowerDown) {
                onPowerDown();
            }
        } else {
            if (smsReceived) {
                strcpy(lastSMSText, line);

                if (onSMS) {
                    onSMS(lastSMSFrom, lastSMSText);
                }

                smsReceived = false;
            }
            
            okReceived = false;
            errorReceived = false;
            powered = true;
        }
    }
}