static int createCode(struct JsonNode *code) { int id = -1; int unit = -1; int state = -1; double itmp = -1; if(json_find_number(code, "id", &itmp) == 0) id = (int)round(itmp); if(json_find_number(code, "unit", &itmp) == 0) unit = (int)round(itmp); if(json_find_number(code, "down", &itmp) == 0) state=0; else if(json_find_number(code, "up", &itmp) == 0) state=1; if(id == -1 || unit == -1 || state == -1) { logprintf(LOG_ERR, "arctech_screen_old: insufficient number of arguments"); return EXIT_FAILURE; } else if(id > 31 || id < 0) { logprintf(LOG_ERR, "arctech_screen_old: invalid id range"); return EXIT_FAILURE; } else if(unit > 15 || unit < 0) { logprintf(LOG_ERR, "arctech_screen_old: invalid unit range"); return EXIT_FAILURE; } else { createMessage(id, unit, state); clearCode(); createUnit(unit); createId(id); createState(state); createFooter(); arctech_screen_old->rawlen = RAW_LENGTH; } return EXIT_SUCCESS; }
static int createCode(struct JsonNode *code) { int systemcode = -1; int programcode = -1; int state = -1; double itmp = 0; if(json_find_number(code, "systemcode", &itmp) == 0) systemcode = (int)round(itmp); if(json_find_number(code, "programcode", &itmp) == 0) programcode = (int)round(itmp); if(json_find_number(code, "off", &itmp) == 0) state=0; else if(json_find_number(code, "on", &itmp) == 0) state=1; if(systemcode == -1 || programcode == -1 || state == -1) { logprintf(LOG_ERR, "rsl366: insufficient number of arguments"); return EXIT_FAILURE; } else if(systemcode > 4 || systemcode < 0) { logprintf(LOG_ERR, "rsl366: invalid systemcode range"); return EXIT_FAILURE; } else if(programcode > 4 || programcode < 0) { logprintf(LOG_ERR, "rsl366: invalid programcode range"); return EXIT_FAILURE; } else { createMessage(systemcode, programcode, state); clearCode(); createSystemCode(systemcode); createProgramCode(programcode); createState(state); createFooter(); rsl366->rawlen = RAW_LENGTH; } return EXIT_SUCCESS; }
static int createCode(struct JsonNode *code) { int systemcode = -1; int unitcode = -1; int state = -1; double itmp = -1; if(json_find_number(code, "systemcode", &itmp) == 0) systemcode = (int)round(itmp); if(json_find_number(code, "unitcode", &itmp) == 0) unitcode = (int)round(itmp); if(json_find_number(code, "off", &itmp) == 0) state=1; else if(json_find_number(code, "on", &itmp) == 0) state=0; if(systemcode == -1 || unitcode == -1 || state == -1) { logprintf(LOG_ERR, "pollin: insufficient number of arguments"); return EXIT_FAILURE; } else if(systemcode > 31 || systemcode < 0) { logprintf(LOG_ERR, "pollin: invalid systemcode range"); return EXIT_FAILURE; } else if(unitcode > 31 || unitcode < 0) { logprintf(LOG_ERR, "pollin: invalid unitcode range"); return EXIT_FAILURE; } else { createMessage(systemcode, unitcode, state); clearCode(); createSystemCode(systemcode); createUnitCode(unitcode); createState(state); createFooter(); pollin->rawlen = RAW_LENGTH; } return EXIT_SUCCESS; }
static int createCode(struct JsonNode *code) { int id = -1; int unit = -1; int state = -1; int all = 0; int learn = -1; double itmp = -1; if(json_find_number(code, "id", &itmp) == 0) id = (int)round(itmp); if(json_find_number(code, "unit", &itmp) == 0) unit = (int)round(itmp); if(json_find_number(code, "all", &itmp) == 0) all = (int)round(itmp); if(json_find_number(code, "off", &itmp) == 0) state=0; else if(json_find_number(code, "on", &itmp) == 0) state=1; if(json_find_number(code, "learn", &itmp) == 0) learn = 1; if(all > 0 && learn > -1) { logprintf(LOG_ERR, "arctech_switch: all and learn cannot be combined"); return EXIT_FAILURE; } else if(id == -1 || (unit == -1 && all == 0) || state == -1) { logprintf(LOG_ERR, "arctech_switch: insufficient number of arguments"); return EXIT_FAILURE; } else if(id > 67108863 || id < 1) { logprintf(LOG_ERR, "arctech_switch: invalid id range"); return EXIT_FAILURE; } else if((unit > 15 || unit < 0) && all == 0) { logprintf(LOG_ERR, "arctech_switch: invalid unit range"); return EXIT_FAILURE; } else { if(unit == -1 && all == 1) { unit = 0; } createMessage(id, unit, state, all, learn); createStart(); clearCode(); createId(id); createAll(all); createState(state); createUnit(unit); createFooter(); arctech_switch->rawlen = RAW_LENGTH; } return EXIT_SUCCESS; }
static int createCode(JsonNode *code) { int id = -1; int systemcode = -1; int unit = -1; int state = -1; double itmp = -1; if(json_find_number(code, "id", &itmp) == 0) id = (int)round(itmp); if(json_find_number(code, "systemcode", &itmp) == 0) systemcode = (int)round(itmp); if(json_find_number(code, "unit", &itmp) == 0) unit = (int)round(itmp); if(json_find_number(code, "off", &itmp) == 0) state=1; if(json_find_number(code, "on", &itmp) == 0) state=0; if(id == -1 || systemcode == -1 || unit == -1 || state == -1) { logprintf(LOG_ERR, "daycom: insufficient number of arguments"); return EXIT_FAILURE; } else if(id > 63 || id < 0) { logprintf(LOG_ERR, "daycom: invalid id range"); return EXIT_FAILURE; } else if(systemcode > 16999 || systemcode < 0) { logprintf(LOG_ERR, "daycom: invalid systemcode range"); return EXIT_FAILURE; } else if(unit > 7 || unit < 0) { logprintf(LOG_ERR, "daycom: invalid unit range"); return EXIT_FAILURE; } else { createMessage(id, systemcode, unit, state); clearCode(); createId(id); createSystemCode(systemcode); createState(state); createUnit(unit); createFooter(); daycom->rawlen = RAW_LENGTH; state = 0; } return EXIT_SUCCESS; }
static int createCode(struct JsonNode *code) { int id = -1; int unit = -1; int state = -1; int all = 0; double itmp = -1; if(json_find_number(code, "id", &itmp) == 0) id = (int)round(itmp); if(json_find_number(code, "unit", &itmp) == 0) unit = (int)round(itmp); if(json_find_number(code, "all", &itmp) == 0) all = 1; if(json_find_number(code, "off", &itmp) == 0) state=0; if(json_find_number(code, "on", &itmp) == 0) state=1; if(id == -1 || (unit == -1 && all == 0) || (state == -1 && all == 1)) { logprintf(LOG_ERR, "beamish_switch: insufficient number of arguments"); return EXIT_FAILURE; } else if(id > 65535 || id < 1) { logprintf(LOG_ERR, "beamish_switch: invalid id range"); return EXIT_FAILURE; } else if((unit > 4 || unit < 1) && all == 0) { logprintf(LOG_ERR, "beamish_switch: invalid unit range"); return EXIT_FAILURE; } else { if(all == 1 && state == 1) unit = 5; if(all == 1 && state == 0) unit = 6; createMessage(id, unit, state, all); clearCode(); createId(id); unit = map[unit]; createUnit(unit); createFooter(); beamish_switch->rawlen = RAW_LENGTH; } return EXIT_SUCCESS; }
static int createCode(JsonNode *code) { double itmp = -1; int unit = -1, id = -1, learn = -1, state = -1, all = 0; if(json_find_number(code, "id", &itmp) == 0) id = (int)round(itmp); if(json_find_number(code, "unit", &itmp) == 0) unit = (int)round(itmp); if(json_find_number(code, "all", &itmp) == 0) all = (int)round(itmp); if(json_find_number(code, "learn", &itmp) == 0) learn = (int)round(itmp); if(json_find_number(code, "off", &itmp) == 0) state=0; else if(json_find_number(code, "on", &itmp) == 0) state=1; if(id==-1 || (unit==-1 && all==0) || state==-1) { logprintf(LOG_ERR, "quigg_gt7000: insufficient number of arguments"); return EXIT_FAILURE; } else if(id > 4095 || id < 0) { logprintf(LOG_ERR, "quigg_gt7000: invalid programm code id range"); return EXIT_FAILURE; } else if((unit > 3 || unit < 0) && all == 0) { logprintf(LOG_ERR, "quigg_gt7000: invalid button code unit range"); return EXIT_FAILURE; } else { if(unit == -1 && all == 1) { unit = 4; } quigg_gt7000->rawlen = RAW_LENGTH; createMessage(id, state, unit, all, learn); clearCode(); createId(id); createUnit(unit); createState(state); createParity(); createFooter(); } return EXIT_SUCCESS; }
ProgramTab::ProgramTab(QString & filename, QWidget *parent) : QFrame(parent) { m_tabWidget = NULL; while (parent != NULL) { QTabWidget * tabWidget = qobject_cast<QTabWidget *>(parent); if (tabWidget) { m_tabWidget = tabWidget; break; } parent = parent->parentWidget(); } if (AsteriskIcon == NULL) { AsteriskIcon = new QIcon(":/resources/images/icons/asterisk.png"); } m_canCopy = false; m_canCut = false; m_canUndo = false; m_canRedo = false; m_language = ""; m_port = ""; m_filename = filename; m_updateEnabled = false; QGridLayout *editLayout = new QGridLayout(this); editLayout->setMargin(0); editLayout->setSpacing(0); m_programWindow = qobject_cast<ProgramWindow *>(window()); // m_textEdit needs to be initialized before createFooter so // some signals get connected properly. m_textEdit = new QTextEdit; m_textEdit->setFontFamily("Droid Sans Mono"); m_textEdit->setLineWrapMode(QTextEdit::NoWrap); QFontMetrics fm(m_textEdit->currentFont()); m_textEdit->setTabStopWidth(fm.averageCharWidth() * 4); m_textEdit->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); m_textEdit->setUndoRedoEnabled(true); connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(m_textEdit, SIGNAL(undoAvailable(bool)), this, SLOT(enableUndo(bool))); connect(m_textEdit, SIGNAL(redoAvailable(bool)), this, SLOT(enableRedo(bool))); connect(m_textEdit, SIGNAL(copyAvailable(bool)), this, SLOT(enableCopy(bool))); connect(m_textEdit, SIGNAL(copyAvailable(bool)), this, SLOT(enableCut(bool))); // Reuse copy signal for cut m_highlighter = new Highlighter(m_textEdit); QFrame * footerFrame = createFooter(); editLayout->addWidget(footerFrame,0,0); QSplitter * splitter = new QSplitter; splitter->setObjectName("splitter"); splitter->setOrientation(Qt::Vertical); editLayout->addWidget(splitter, 1, 0); splitter->addWidget(m_textEdit); m_console = new QTextEdit(); m_console->setLineWrapMode(QTextEdit::NoWrap); m_console->setObjectName("console"); m_console->setReadOnly(true); splitter->addWidget(m_console); splitter->setStretchFactor(0, 8); splitter->setStretchFactor(1, 2); }
static int createCode(struct JsonNode *code) { int id = -1; int unit = -1; int state = -1; int all = 0; int dimlevel = -1; int learn = -1; int max = 15; int min = 0; double itmp = -1; if(json_find_number(code, "dimlevel-maximum", &itmp) == 0) max = (int)round(itmp); if(json_find_number(code, "dimlevel-minimum", &itmp) == 0) min = (int)round(itmp); if(json_find_number(code, "id", &itmp) == 0) id = (int)round(itmp); if(json_find_number(code, "unit", &itmp) == 0) unit = (int)round(itmp); if(json_find_number(code, "dimlevel", &itmp) == 0) dimlevel = (int)round(itmp); if(json_find_number(code, "all", &itmp) == 0) all = (int)round(itmp); if(json_find_number(code, "learn", &itmp) == 0) learn = 1; if(json_find_number(code, "off", &itmp) == 0) state=0; else if(json_find_number(code, "on", &itmp) == 0) state=1; if(all > 0 && learn > -1) { logprintf(LOG_ERR, "arctech_dimmer: all and learn cannot be combined"); return EXIT_FAILURE; } else if(id == -1 || (unit == -1 && all == 0) || (dimlevel == -1 && state == -1)) { logprintf(LOG_ERR, "arctech_dimmer: insufficient number of arguments"); return EXIT_FAILURE; } else if(id > 67108863 || id < 1) { logprintf(LOG_ERR, "arctech_dimmer: invalid id range"); return EXIT_FAILURE; } else if((unit > 15 || unit < 0) && all == 0) { logprintf(LOG_ERR, "arctech_dimmer: invalid unit range"); return EXIT_FAILURE; } else if(dimlevel != -1 && (dimlevel > max || dimlevel < min) ) { logprintf(LOG_ERR, "arctech_dimmer: invalid dimlevel range"); return EXIT_FAILURE; } else if(dimlevel >= 0 && state == 0) { logprintf(LOG_ERR, "arctech_dimmer: dimlevel and off state cannot be combined"); return EXIT_FAILURE; } else { if(unit == -1 && all == 1) { unit = 0; } if(dimlevel >= 0) { state = -1; } createMessage(id, unit, state, all, dimlevel, learn); createStart(); clearCode(); createId(id); createAll(all); createState(state); createUnit(unit); if(dimlevel > -1) { createDimlevel(dimlevel); } createFooter(); arctech_dimmer->rawlen = RAW_LENGTH; } return EXIT_SUCCESS; }
void Reports::createReport() { m_wcHeaders = new WContainerWidget(this); switch(m_iReportType) { case Mutual: new WText(tr("reports.mutual.header"),m_wcHeaders); createUi(); break; case DeptStucture: new WText(tr("reports.deptstructure.header"),m_wcHeaders); //new WLabel("____________________________________________________________________________________", m_wcHeaders ); //printDiv = new WContainerWidget(this); break; case Orders: new WText(tr("reports.orders.header"),m_wcHeaders); //printDiv = new WContainerWidget(this); createUi(); break; case GoodsSales: new WText(tr("reports.goodssales.header"),m_wcHeaders); //printDiv = new WContainerWidget(this); createUi(); break; case OrderDetail: { char number[50]; if(dbo::ptr<db::OrdersHeader> ord = ((Portal *)WApplication::instance())->getSession()->getCurrentOrder()) { sprintf(number,"%010d",ord->orderId); }else if(dbo::ptr<db::OrdersHeader> ord = ((Portal *)WApplication::instance())->getSession()->setCurrentOrder()) { sprintf(number,"%010d",ord->orderId); }else{ sprintf(number,"%010d",0); } new WText(WString(tr("reports.orderdetails.header")).arg(number),m_wcHeaders); //printDiv = new WContainerWidget(this); break; } case OrderJournal: new WText(tr("reports.orderjournal.header"),m_wcHeaders); //printDiv = new WContainerWidget(this); createUi(); break; } //WContainerWidget *printDiv = 0; //printDiv = new WContainerWidget(m_wcHeaders); //printDiv->setMargin(-20,Top); //WResource *r = new PdfResource(this); // serializes to a PDF file. //a = new WAnchor(r, "PDF version", this); //a->setTarget(TargetNewWindow); //printDiv->setStyleClass("print"); m_printAnc = new WAnchor("#", tr("print"),m_wcHeaders); m_printAnc->setStyleClass("print"); //m_printAnc->setId("print"); m_printAnc->setImage(new WImage("/css/printer.jpg")); m_printAnc->setTarget(TargetNewWindow); m_reportContent = new WContainerWidget(this); prepareReport(); createFooter(); }