void MidiController::sendDeviceId(){ uint8_t buffer[15]; buffer[0] = SYSEX_DEVICE_ID; uint8_t* deviceId = getDeviceId(); data_to_sysex(deviceId, buffer+1, 3*4); sendSysEx(buffer, sizeof(buffer)); }
void SmartWifi::SetupWifi(){ EEPROM.begin(512); delay(10); printer->println(); printer->println(); printer->println("Startup"); // read eeprom for ssid and pass String* credentials = getWifiCredentials(); deviceId = getDeviceId()[0]; String esid = credentials[0]; String epass = credentials[1]; printer->println("returned from function"); printer->println("ssid "+ esid); printer->println("pass "+ epass); printer->println("deviceId "+ deviceId); if ( esid != "") { WiFi.mode(WIFI_STA); WiFi.disconnect(); WiFi.begin(esid.c_str(), epass.c_str()); if (testWifiConnection()) { //launchWeb(0); return; } } setupMode = true; setupAP(); }
void RecurrentLayerGroup::initSubNetwork( NeuralNetwork* rootNetwork, const ModelConfig& config, const std::vector<ParameterType>& parameterTypes, bool useGpu) { setNeedGradient(true); network_.reset(new RecurrentGradientMachine(config_.name(), rootNetwork)); ParamInitCallback cb = [this, rootNetwork](int paramId, Parameter* para) { para->enableSharedType( PARAMETER_VALUE, rootNetwork->getParameters()[paramId]->getBuf(PARAMETER_VALUE), rootNetwork->getParameters()[paramId]->getMat(PARAMETER_VALUE)); para->enableSharedType( PARAMETER_GRADIENT, rootNetwork->getParameters()[paramId]->getBuf(PARAMETER_GRADIENT), rootNetwork->getParameters()[paramId]->getMat(PARAMETER_GRADIENT)); }; network_->init(config, cb, parameterTypes, useGpu); for (auto paramId : network_->getParameterIds()) { ParameterPtr parameter = rootNetwork->getParameters()[paramId]; parameter->incShared(); CHECK_EQ(parameter->getDeviceId(), getDeviceId()); parameters_.push_back(parameter); } }
QJsonObject Device::serialize() { QJsonObject ret; ret.insert(KEY_DEVICE_TYPE,(int)type); ret.insert(KEY_DEV_ID,getDeviceId()); return ret; }
void Joystick::readCustomButton(Key key){ int button; if (Configuration::getCustomButton(key, getDeviceId(), getName(), button)){ customButton[button] = key; if (customAxis.find(key) != customAxis.end()){ customAxis.erase(key); } } }
void Joystick::setCustomButton(int button, Key key){ Configuration::setCustomButton(key, getDeviceId(), getName(), button); customButton[button] = key; /* Can only have one unique button/axis */ if (customAxis.find(key) != customAxis.end()){ customAxis.erase(key); } }
//---------------------------------------------------------------------------------------------------------------------- void FcmPushClient::setDeviceId(const String& deviceId) { CMethodResult result; setProperty("deviceId", deviceId, result); LOG(TRACE) + "creating client register"; rho::sync::RhoconnectClientManager::clientRegisterCreate(deviceId.c_str()); getDeviceId(m_deviceIdResult); m_deviceIdResult = CMethodResult(); }
void Joystick::setCustomAxis(Key key, int stick, int axis, double low, double high){ Configuration::setCustomAxis(key, getDeviceId(), getName(), stick, axis, low, high); Axis & use = customAxis[key]; use.stick = stick; use.axis = axis; use.low = low; use.high = high; use.on = false; /* Can only have one unique button/axis */ eraseCustomButton(key); }
void Joystick::readCustomAxis(Key key){ int stick, axis; double low, high; if (Configuration::getCustomAxis(key, getDeviceId(), getName(), stick, axis, low, high)){ Axis & use = customAxis[key]; use.stick = stick; use.axis = axis; use.low = low; use.high = high; use.on = false; eraseCustomButton(key); } }
int setup_stream_test(int argc, const char* argv[]) { int rv = 0; if (checkHelp(argc, argv)) { std::cout << "SetupStreamTest [-c collectionid] [-D testfilesfolder] [-d dumpfile [-M dumpCountMax]] [-f filterCategory 0|1|2|3]" << std::endl; std::cout << " collectionid = Collection ID. Default is \"streamtestcollection\"" << std::endl; std::cout << " testfilesfolder = Folder containing test files. Ignored on client." << std::endl; std::cout << " dumpfile = Dump URLs to this file." << std::endl; std::cout << " dumpCountMax = Dump at most this many files." << std::endl; std::cout << " filterCategory = 0 - All(Disabled) | 1 - Music | 2 - Photo | 3 - Music&Photo(Disabled) | 4 - Video | 5 - Music&Video(Disabled) | 6 - Photo&Video(Disabled). Default is 1 - dump music." << std::endl; return 0; } std::string collectionid; std::string testfilesfolder; std::string dumpfile; int dumpCountMax = -1; // meaning no limit bool downloadMusic = true; bool downloadPhoto = false; bool downloadVideo = false; media_metadata::CatalogType_t catType = media_metadata::MM_CATALOG_MUSIC; collectionid.assign("streamtestcollection"); // default collection ID setDebugLevel(LOG_LEVEL_INFO); for (int i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { case 'c': if (i + 1 < argc) { collectionid.assign(argv[++i]); } break; case 'D': if (i + 1 < argc) { testfilesfolder.assign(argv[++i]); } break; case 'd': if (i + 1 < argc) { dumpfile.assign(argv[++i]); } break; case 'M': if (i + 1 < argc) { dumpCountMax = atoi(argv[++i]); } break; case 'f': if(i + 1 < argc) { if(atoi(argv[i+1]) == 0) { downloadMusic = true; downloadPhoto = true; downloadVideo = true; LOG_ERROR("Not supported"); return -1; } else if(atoi(argv[i+1]) == 1) { downloadMusic = true; downloadPhoto = false; downloadVideo = false; catType = media_metadata::MM_CATALOG_MUSIC; } else if(atoi(argv[i+1]) == 2) { downloadMusic = false; downloadPhoto = true; downloadVideo = false; catType = media_metadata::MM_CATALOG_PHOTO; } else if(atoi(argv[i+1]) == 3) { downloadMusic = true; downloadPhoto = true; downloadVideo = false; LOG_ERROR("Not supported"); return -1; } else if(atoi(argv[i+1]) == 4) { downloadMusic = false; downloadPhoto = false; downloadVideo = true; catType = media_metadata::MM_CATALOG_VIDEO; } else if(atoi(argv[i+1]) == 5) { downloadMusic = true; downloadPhoto = false; downloadVideo = true; LOG_ERROR("Not supported"); return -1; } else { downloadMusic = false; downloadPhoto = true; downloadVideo = true; LOG_ERROR("Not supported"); return -1; } } break; default: LOG_ERROR("Unknown option %s", argv[i]); return -2; } } } u64 userId = 0; rv = getUserIdBasic(&userId); if (rv != 0) { LOG_ERROR("Failed to get user ID: %d", rv); return rv; } u64 deviceId = 0; rv = getDeviceId(&deviceId); if (rv != 0) { LOG_ERROR("Failed to get device ID: %d", rv); return rv; } if (!testfilesfolder.empty()) { if (isCloudpc(userId, deviceId)) { rv = setup_stream_test_create_metadata(userId, deviceId, catType, collectionid, testfilesfolder); } else { LOG_WARN("-D ignored on client PC"); } } if (!dumpfile.empty()) { rv = setup_stream_test_write_dumpfile(userId, deviceId, collectionid, dumpfile, downloadMusic, downloadPhoto, downloadVideo, dumpCountMax); } resetDebugLevel(); return rv; }
void MpidWinMM::processAudioInput(HWAVEIN hwi, UINT uMsg, void* dwParam1) { if (!mIsOpen) { assert(uMsg == WIM_OPEN); if (uMsg == WIM_OPEN) { // printf("received WIM_OPEN\n"); fflush(stdout); mIsOpen = TRUE; } } if (uMsg == WIM_DATA) { // printf("received WIM_DATA\n"); fflush(stdout); assert(mIsOpen); WAVEHDR* pWaveHdr = (WAVEHDR*)dwParam1; assert(pWaveHdr->dwBufferLength == (mSamplesPerFrame*sizeof(MpAudioSample))); assert(pWaveHdr->lpData != NULL); // Only process if we're enabled.. if(mIsEnabled) { #ifdef TEST_PRINT OsSysLog::add(FAC_MP, PRI_DEBUG, "MpidWinMM::processAudioInput got frame device: %d (%s)", getDeviceId(), getDeviceName().data()); #endif mpInputDeviceManager->pushFrame(mDeviceId, mSamplesPerFrame, (MpAudioSample*)pWaveHdr->lpData, mCurrentFrameTime); // Ok, we have received and pushed a frame to the manager, // Now we advance the frame time. mCurrentFrameTime += (mSamplesPerFrame*1000)/mSamplesPerSec; } else { OsSysLog::add(FAC_MP, PRI_DEBUG, "MpidWinMM::processAudioInput input device: %d (%s) disabled", getDeviceId(), getDeviceName().data()); } if(mIsEnabled) { // Put the wave header back in the pool.. MMRESULT res = MMSYSERR_NOERROR; res = waveInAddBuffer(mDevHandle, pWaveHdr, sizeof(WAVEHDR)); if (res != MMSYSERR_NOERROR) { showWaveError("waveInAddBuffer", res, -1, __LINE__); mnAddBufferFailures++; if(mnAddBufferFailures >= mNumInBuffers) { waveInClose(mDevHandle); mDevHandle = NULL; mWinMMDeviceId = -1; } } } } else if (uMsg == WIM_CLOSE) { // printf("received WIM_CLOSE\n"); fflush(stdout); mIsOpen = FALSE; } }
static int lua_msdk_getDeviceId(lua_State * L) { PUSHDELETESTRING(getDeviceId()); return 1; }
bool Device::deviceEqual(Device *other) { return other->getDeviceId() == getDeviceId(); }
int do_autotest_regression_streaming_transcode_negative(int argc, const char* argv[]) { int rv = VPL_OK; u32 retry = 0; u32 photoAlbumNum = 0; u32 photoNum = 0; u32 expectedPhotoNum = 0; std::string photosToStream = "-1"; // meaning no limit int cloudPCId = 1; int clientPCId = 2; std::string CloudPC_alias = "CloudPC"; std::string MD_alias = "MD"; std::string osVersion; const char* TEST_TRANSCODE2_STR = "SdkTranscodeStreamingPositive"; bool full = false; if (argc == 6 && (strcmp(argv[5], "-f") == 0 || strcmp(argv[5], "--fulltest") == 0) ) { full = true; } if (checkHelp(argc, argv) || (argc < 5) || (argc == 6 && !full)) { printf("AutoTest %s <username> <password> <expectedPhotoNum> [<fulltest>(-f/--fulltest)]\n", argv[0]); return 0; // No arguments needed } LOG_ALWAYS("AutoTest Transcode Streaming: Domain(%s) User(%s) Password(%s) ExpectedPhotoNum(%s)", argv[1], argv[2], argv[3], argv[4]); // Does a hard stop for all ccds { const char *testArg[] = { "StopCCD" }; stop_ccd_hard(ARRAY_ELEMENT_COUNT(testArg), testArg); } expectedPhotoNum = static_cast<u32>(atoi(argv[4])); VPLFile_Delete("dumpfile"); LOG_ALWAYS("\n\n==== Launching Cloud PC CCD (instanceId %d) ====", cloudPCId); SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, CloudPC_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(cloudPCId); } CHECK_LINK_REMOTE_AGENT(CloudPC_alias, TEST_TRANSCODE2_STR, rv); START_CCD(TEST_TRANSCODE2_STR, rv); START_CLOUDPC(argv[2], argv[3], TEST_TRANSCODE2_STR, true, rv); VPLThread_Sleep(VPLTIME_FROM_MILLISEC(1000)); LOG_ALWAYS("\n\n==== Launching MD CCD (instanceId %d) ====", clientPCId); SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, MD_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(clientPCId); } CHECK_LINK_REMOTE_AGENT(MD_alias, TEST_TRANSCODE2_STR, rv); QUERY_TARGET_OSVERSION(osVersion, TEST_TRANSCODE2_STR, rv); START_CCD(TEST_TRANSCODE2_STR, rv); UPDATE_APP_STATE(TEST_TRANSCODE2_STR, rv); START_CLIENT(argv[2], argv[3], TEST_TRANSCODE2_STR, true, rv); VPLThread_Sleep(VPLTIME_FROM_MILLISEC(1000)); // make sure both cloudpc/client has the device linked info updated LOG_ALWAYS("\n\n== Checking cloudpc and Client device link status =="); { std::vector<u64> deviceIds; u64 userId = 0; u64 cloudPCDeviceId = 0; u64 MDDeviceId = 0; const char *testCloudStr = "CheckCloudPCDeviceLinkStatus"; const char *testMDStr = "CheckMDDeviceLinkStatus"; SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, CloudPC_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(cloudPCId); } rv = getUserIdBasic(&userId); if (rv != 0) { LOG_ERROR("Fail to get user id:%d", rv); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, testCloudStr, rv); } rv = getDeviceId(&cloudPCDeviceId); if (rv != 0) { LOG_ERROR("Fail to get CloudPC device id:%d", rv); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, testCloudStr, rv); } SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, MD_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(cloudPCId); } rv = getDeviceId(&MDDeviceId); if (rv != 0) { LOG_ERROR("Fail to get MD device id:%d", rv); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, testMDStr, rv); } deviceIds.push_back(cloudPCDeviceId); LOG_ALWAYS("Add Device Id "FMTu64, cloudPCDeviceId); deviceIds.push_back(MDDeviceId); LOG_ALWAYS("Add Device Id "FMTu64, MDDeviceId); rv = wait_for_devices_to_be_online_by_alias(TEST_TRANSCODE2_STR, CloudPC_alias.c_str(), cloudPCId, userId, deviceIds, 20); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, testCloudStr, rv); rv = wait_for_devices_to_be_online_by_alias(TEST_TRANSCODE2_STR, MD_alias.c_str(), clientPCId, userId, deviceIds, 20); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, testMDStr, rv); SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, MD_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(clientPCId); } rv = wait_for_cloudpc_get_accesshandle(userId, cloudPCDeviceId, 20); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, "CheckCloudPCGetAccessHandle", rv); } LOG_ALWAYS("\n\n==== Testing ClearMetadata (CloudPC) ===="); SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, CloudPC_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(cloudPCId); } { const char *testStr = "ClearMetadata"; const char *testArg[] = { testStr }; rv = msa_delete_catalog(ARRAY_ELEMENT_COUNT(testArg), testArg); if(rv != 0) { LOG_ERROR("RegressionStreaming_ClearMetadata failed!"); } CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, testStr, rv); } #if defined(CLOUDNODE) LOG_ALWAYS("\n\n==== Testing CloudMedia CloudnodeAddPhoto (ClientPC) ===="); SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, MD_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(clientPCId); } { std::string dxroot; std::string photoSetPath; rv = getDxRootPath(dxroot); if (rv != VPL_OK) { LOG_ERROR("Fail to set %s root path", argv[0]); goto exit; } photoSetPath.assign(dxroot.c_str()); const char *testStr1 = "CloudMedia"; const char *testStr2 = "CloudnodeAddPhoto"; photoSetPath.append("/GoldenTest/image_transcode_negative_test_1"); const char *testArg4[] = { testStr1, testStr2, photoSetPath.c_str() }; rv = cloudmedia_commands(3, testArg4); if (rv != VPL_OK) { LOG_ERROR("SdkTranscodeStreaming2_CloudMedia_CloudnodeAddPhoto failed!"); } CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, "CloudMedia_CloudnodeAddPhoto", rv); } #endif // CLOUDNODE LOG_ALWAYS("\n\n==== Testing CloudMedia AddPhoto (CloudPC) ===="); SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, CloudPC_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(cloudPCId); } { std::string dxroot; std::string photoSetPath; rv = getDxRootPath(dxroot); if (rv != VPL_OK) { LOG_ERROR("Fail to set %s root path", argv[0]); goto exit; } photoSetPath.assign(dxroot.c_str()); const char *testStr1 = "CloudMedia"; const char *testStr2 = "AddPhoto"; photoSetPath.append("/GoldenTest/image_transcode_negative_test_1"); const char *testArg4[] = { testStr1, testStr2, photoSetPath.c_str() }; rv = cloudmedia_commands(3, testArg4); if (rv != VPL_OK) { LOG_ERROR("SdkTranscodeStreaming2_CloudMedia_AddPhoto failed!"); } CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, "CloudMedia_AddPhoto", rv); } // Verify if the metadata is synced retry = 0; SET_TARGET_MACHINE(TEST_TRANSCODE2_STR, MD_alias.c_str(), rv); if (rv < 0) { setCcdTestInstanceNum(clientPCId); } LOG_ALWAYS("\n\n==== List Metadata (ClientPC) ===="); { VPLTime_t startTime = VPLTime_GetTimeStamp(); while(1) { rv = mca_get_photo_object_num(photoAlbumNum, photoNum); if(rv != VPL_OK) { LOG_ERROR("Cannot get photo count from metadata"); } else if(photoNum == expectedPhotoNum) { u64 elapsedTime = VPLTIME_TO_SEC(VPLTime_GetTimeStamp() - startTime); LOG_ALWAYS("Retry (%d) times waited ("FMTu64") seconds for photo to be synced.", retry, elapsedTime); break; } if(retry++ > METADATA_SYNC_TIMEOUT) { u64 elapsedTime = VPLTIME_TO_SEC(VPLTime_GetTimeStamp() - startTime); LOG_ERROR("Timeout retry (%d) waiting for metadata to sync; waited for ("FMTu64") seconds.", retry, elapsedTime); rv = -1; break; } else { LOG_ALWAYS("Waiting (cnt %d) photoNum (%d) photoAlbumNum (%d)", retry, photoNum, photoAlbumNum); } VPLThread_Sleep(VPLTIME_FROM_SEC(1)); } LOG_ALWAYS("Photo added by CloudPC: %d; Expected photo: %d", photoNum, expectedPhotoNum); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, "Verify_Uploaded_Photo_Num1", rv); } LOG_ALWAYS("\n\n==== SetupStreamTest to generate dump file ===="); { const char *testStr = "SetupStreamTest"; const char *testArg[] = { testStr, "-d", "dumpfile", "-f", "2", "-M", photosToStream.c_str() }; rv = setup_stream_test(ARRAY_ELEMENT_COUNT(testArg), testArg); CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, "SetupStreamTest_dumpfile", rv); } // Negative Test - Scale an invalid photo to 800x800 LOG_ALWAYS("\n\n==== Negative Test, scale an invalid photo to 800x800 ===="); { const char *testStr = "TimeStreamDownload"; const char *testArg[] = { testStr, "-d", "dumpfile", "-R", "800,800", "-f", "JPG" }; rv = time_stream_download(ARRAY_ELEMENT_COUNT(testArg), testArg); if (rv == -1) { rv = 0; } else if (rv == 0) { if(osVersion == OS_LINUX) { rv = -1; CHECK_AND_PRINT_EXPECTED_TO_FAIL(TEST_TRANSCODE2_STR, "NegativeTest_InvalidImage", rv, "13344"); rv = 0; goto exit; } } else { LOG_ERROR("Expected -1, but got %d", rv); rv = -1; } CHECK_AND_PRINT_RESULT(TEST_TRANSCODE2_STR, "NegativeTest_InvalidImage", rv); } exit: LOG_ALWAYS("\n\n== Freeing Client =="); if(set_target_machine(MD_alias.c_str()) < 0) setCcdTestInstanceNum(clientPCId); { const char *testArg[] = { "StopClient" }; stop_client(ARRAY_ELEMENT_COUNT(testArg), testArg); } if (isWindows(osVersion) || osVersion.compare(OS_LINUX) == 0) { const char *testArg[] = { "StopCCD" }; stop_ccd_soft(ARRAY_ELEMENT_COUNT(testArg), testArg); } LOG_ALWAYS("\n\n== Freeing Cloud PC =="); if(set_target_machine(CloudPC_alias.c_str()) < 0) setCcdTestInstanceNum(cloudPCId); { const char *testArg[] = { "StopCloudPC" }; stop_cloudpc(ARRAY_ELEMENT_COUNT(testArg), testArg); } { const char *testArg[] = { "StopCCD" }; stop_ccd_soft(ARRAY_ELEMENT_COUNT(testArg), testArg); } return rv; }