void CommandLine::Process(wstring commandLine) { wchar_t* pch; pch = (wchar_t*) commandLine.c_str(); while (*pch != NULL) { if (_wcsnicmp(pch, NORUNNING_PARAMETER, NORUNNING_PARAMETER_LEN) == 0) { wstring version; m_bRunningCheck = false; pch += NORUNNING_PARAMETER_LEN; if (_readCommandLineParameter(&pch, version)) { _createCatalanitzadorUpdateAction(version); } } else if (_wcsnicmp(pch, USEAEROLOOK_PARAMETER, USEAEROLOOK_PARAMETER_LEN) == 0) { ConfigurationInstance::Get().SetAeroEnabled(true); pch += USEAEROLOOK_PARAMETER_LEN; } else if (_wcsnicmp(pch, USECLASSICLOOK_PARAMETER, USECLASSICLOOK_PARAMETER_LEN) == 0) { ConfigurationInstance::Get().SetAeroEnabled(false); pch += USECLASSICLOOK_PARAMETER_LEN; } else if (_wcsnicmp(pch, HELP_PARAMETER, HELP_PARAMETER_LEN) == 0) { wchar_t szCaption [MAX_LOADSTRING]; LoadString(GetModuleHandle(NULL), IDS_MSGBOX_CAPTION, szCaption, MAX_LOADSTRING); MessageBox(NULL, HELP_TEXT, szCaption, MB_OK | MB_ICONINFORMATION); exit(0); } else if (_wcsnicmp(pch, NOCONFIGURATIONDOWNLOAD_PARAMETER, NOCONFIGURATIONDOWNLOAD_PARAMETER_LEN) == 0) { ConfigurationInstance::Get().SetDownloadConfiguration(false); pch += NOCONFIGURATIONDOWNLOAD_PARAMETER_LEN; } else if (_wcsnicmp(pch, VERSION_PARAMETER, VERSION_PARAMETER_LEN) == 0) { wstring version; pch += VERSION_PARAMETER_LEN; if (_readCommandLineParameter(&pch, version)) { ConfigurationInstance::Get().SetVersion(ApplicationVersion(version)); } } else if (_wcsnicmp(pch, CONFIGURATIONDOWNLOADURL_PARAMETER, CONFIGURATIONDOWNLOADURL_PARAMETER_LEN) == 0) { wstring url; pch += CONFIGURATIONDOWNLOADURL_PARAMETER_LEN; if (_readCommandLineParameter(&pch, url)) { ConfigurationInstance::Get().SetDownloadConfigurationUrl(url); } } else pch++; } }
bool AdobeReaderAction::Download(ProgressStatus progress, void *data) { wstring filename; ConfigurationFileActionDownload downloadVersion; downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), ApplicationVersion(GetVersion())); GetTempPath(MAX_PATH, m_szFilename); wcscat_s(m_szFilename, downloadVersion.GetFilename().c_str()); return m_downloadManager->GetFile(downloadVersion, m_szFilename, progress, data); }
/*----------------------------------------------------------------------------- * process bus telegrams */ static void ProcessBus(uint8_t ret) { TBusMsgType msgType; uint8_t i; bool msgForMe = false; uint8_t state; uint8_t mask8; uint8_t action; TBusDevRespInfo *pInfo; TBusDevRespActualValue *pActVal; TClient *pClient; static TBusTelegram sTxMsg; static bool sTxRetry = false; bool flag; uint8_t val8; if (sTxRetry) { sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; return; } if (ret == BUS_MSG_OK) { msgType = spBusMsg->type; switch (msgType) { case eBusDevReqReboot: case eBusDevReqInfo: case eBusDevReqActualValue: case eBusDevReqSetValue: case eBusDevReqSwitchState: case eBusDevReqSetAddr: case eBusDevReqEepromRead: case eBusDevReqEepromWrite: case eBusDevReqSetClientAddr: case eBusDevReqGetClientAddr: case eBusDevRespActualValueEvent: if (spBusMsg->msg.devBus.receiverAddr == MY_ADDR) { msgForMe = true; } break; case eBusButtonPressed1: case eBusButtonPressed2: case eBusButtonPressed1_2: msgForMe = true; break; default: break; } } else if (ret == BUS_MSG_ERROR) { ButtonTimeStampRefresh(); } if (msgForMe == false) { return; } switch (msgType) { case eBusDevReqReboot: /* use watchdog to reboot */ /* set the watchdog timeout as short as possible (14 ms) */ cli(); wdt_enable(WDTO_15MS); /* wait for reset */ while (1); break; case eBusButtonPressed1: ButtonEvent(spBusMsg->senderAddr, 1); break; case eBusButtonPressed2: ButtonEvent(spBusMsg->senderAddr, 2); break; case eBusButtonPressed1_2: ButtonEvent(spBusMsg->senderAddr, 1); ButtonEvent(spBusMsg->senderAddr, 2); break; case eBusDevReqInfo: /* response packet */ pInfo = &sTxMsg.msg.devBus.x.devResp.info; sTxMsg.type = eBusDevRespInfo; sTxMsg.senderAddr = MY_ADDR; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; pInfo->devType = eBusDevTypePwm4; strncpy((char *)(pInfo->version), ApplicationVersion(), sizeof(pInfo->version)); pInfo->version[sizeof(pInfo->version) - 1] = '\0'; sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; case eBusDevReqActualValue: /* response packet */ pActVal = &sTxMsg.msg.devBus.x.devResp.actualValue; sTxMsg.type = eBusDevRespActualValue; sTxMsg.senderAddr = MY_ADDR; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; pActVal->devType = eBusDevTypePwm4; PwmGetAll(pActVal->actualValue.pwm4.pwm, sizeof(pActVal->actualValue.pwm4.pwm)); val8 = 0; for (i = 0; i < NUM_PWM_CHANNEL; i++) { PwmIsOn(i, &flag); val8 |= flag ? 1 << i: 0; } pActVal->actualValue.pwm4.state = val8; sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; case eBusDevReqSetValue: if (spBusMsg->msg.devBus.x.devReq.setValue.devType != eBusDevTypePwm4) { break; } mask8 = spBusMsg->msg.devBus.x.devReq.setValue.setValue.pwm4.set; for (i = 0; i < NUM_PWM_CHANNEL; i++) { action = (0x3 << (i * 2) & mask8) >> (i * 2); switch (action) { case 0x00: /* no action, ignore pwm[] from telegram */ break; case 0x01: /* set current pwm, ignore pwm[] from telegram */ PwmOn(i, true); break; case 0x02: /* set to pwm[] from telegram */ PwmSet(i, spBusMsg->msg.devBus.x.devReq.setValue.setValue.pwm4.pwm[i]); PwmOn(i, true); break; case 0x03: /* off, ignore pwm[] from telegram */ PwmOn(i, false); break; default: break; } } /* response packet */ sTxMsg.type = eBusDevRespSetValue; sTxMsg.senderAddr = MY_ADDR; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; case eBusDevReqSwitchState: state = spBusMsg->msg.devBus.x.devReq.switchState.switchState; if ((state & 0x01) != 0) { SwitchEvent(spBusMsg->senderAddr, 1, true); } else { SwitchEvent(spBusMsg->senderAddr, 1, false); } if ((state & 0x02) != 0) { SwitchEvent(spBusMsg->senderAddr, 2, true); } else { SwitchEvent(spBusMsg->senderAddr, 2, false); } /* response packet */ sTxMsg.type = eBusDevRespSwitchState; sTxMsg.senderAddr = MY_ADDR; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; sTxMsg.msg.devBus.x.devResp.switchState.switchState = state; sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; case eBusDevReqSetAddr: sTxMsg.senderAddr = MY_ADDR; sTxMsg.type = eBusDevRespSetAddr; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; eeprom_write_byte((uint8_t *)MODUL_ADDRESS, spBusMsg->msg.devBus.x.devReq.setAddr.addr); sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; case eBusDevReqEepromRead: sTxMsg.senderAddr = MY_ADDR; sTxMsg.type = eBusDevRespEepromRead; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; sTxMsg.msg.devBus.x.devResp.readEeprom.data = eeprom_read_byte((const uint8_t *)spBusMsg->msg.devBus.x.devReq.readEeprom.addr); sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; case eBusDevReqEepromWrite: sTxMsg.senderAddr = MY_ADDR; sTxMsg.type = eBusDevRespEepromWrite; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; eeprom_write_byte((uint8_t *)spBusMsg->msg.devBus.x.devReq.readEeprom.addr, spBusMsg->msg.devBus.x.devReq.writeEeprom.data); sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; case eBusDevRespActualValueEvent: pClient = sClient; for (i = 0; i < sNumClients; i++) { if ((pClient->address == spBusMsg->senderAddr) && (pClient->state == eEventWaitForConfirmation)) { TBusDevActualValuePwm4 *p; uint16_t buf[NUM_PWM_CHANNEL]; PwmGetAll(buf, sizeof(buf)); val8 = 0; for (i = 0; i < NUM_PWM_CHANNEL; i++) { PwmIsOn(i, &flag); val8 |= flag ? 1 << i: 0; } p = &spBusMsg->msg.devBus.x.devResp.actualValueEvent.actualValue.pwm4; if ((memcmp(p->pwm, buf, sizeof(buf)) == 0) && (p->state == val8)) { pClient->state = eEventConfirmationOK; } break; } pClient++; } break; case eBusDevReqSetClientAddr: sTxMsg.senderAddr = MY_ADDR; sTxMsg.type = eBusDevRespSetClientAddr; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; for (i = 0; i < BUS_MAX_CLIENT_NUM; i++) { uint8_t *p = &spBusMsg->msg.devBus.x.devReq.setClientAddr.clientAddr[i]; eeprom_write_byte((uint8_t *)(CLIENT_ADDRESS_BASE + i), *p); } sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; GetClientListFromEeprom(); break; case eBusDevReqGetClientAddr: sTxMsg.senderAddr = MY_ADDR; sTxMsg.type = eBusDevRespGetClientAddr; sTxMsg.msg.devBus.receiverAddr = spBusMsg->senderAddr; for (i = 0; i < BUS_MAX_CLIENT_NUM; i++) { uint8_t *p = &sTxMsg.msg.devBus.x.devResp.getClientAddr.clientAddr[i]; *p = eeprom_read_byte((const uint8_t *)(CLIENT_ADDRESS_BASE + i)); } sTxRetry = BusSend(&sTxMsg) != BUS_SEND_OK; break; default: break; } }
bool Action::_doesDownloadExist() { ConfigurationFileActionDownload downloadVersion; downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), ApplicationVersion(GetVersion())); return downloadVersion.IsUsable(); }