void SetDir(Widget widget, XEvent *event, String *params, Cardinal *num_params) { char *ndir; /* get the string from the widget */ FirstArg(XtNstring, &ndir); if (browse_up) { GetValues(browse_dir); strcpy(cur_browse_dir,ndir); /* save in global var */ } else if (file_up) { GetValues(file_dir); strcpy(cur_file_dir,ndir); /* save in global var */ strcpy(cur_export_dir,ndir); /* set export directory to file directory */ } else if (export_up) { GetValues(exp_dir); strcpy(cur_export_dir,ndir); /* save in global var */ } /* if there is a ~ in the directory, parse the username */ if (ndir[0]=='~') { char longdir[PATH_MAX]; parseuserpath(ndir,longdir); ndir=longdir; } DoChangeDir(ndir); }
void got_browse(Widget w, XButtonEvent *ev) { char *fval, *dval, *path; if (browse_popup) { FirstArg(XtNstring, &dval); GetValues(browse_dir); FirstArg(XtNstring, &fval); GetValues(browse_selfile); /* check the ascii widget for a filename */ if (emptyname(fval)) { fval = browse_filename; /* Filename widget empty, use current filename */ } strcpy(file_viewed, fval); /* indicate name as viewed */ if (emptyname_msg(fval, "Apply")) return; path = new_string( strlen(dval) + 1 + strlen(fval) + 1); if ( path ) { strcpy( path,dval ); strcat( path, "/"); strcat( path, fval ); panel_set_value( pic_name_panel, path ); free(path); } push_apply_button(); /* slightly iffy - assumes called from edit picture */ } }
/////////////////////////////////////////////////////////////////////////////// // // Open // /////////////////////////////////////////////////////////////////////////////// int TTransFile::Open() { typestr aLine; char* InChar; char* OutChar; typestr InListe; typestr OutListe; int Line; typestr aSpec; // Ouverture du fichier if (TFile::Open()) return 1; // Lecture de chaque ligne du fichier while (NextLine(&aLine, false, &aSpec, &Line) == 0) { // Si la ligne n'est pas vide, la traiter if (*aLine.str()) { // Decoupage sur le | InChar=OutChar=aLine.str(); while(*OutChar && *OutChar!='|') ++OutChar; if (*OutChar) ++OutChar; // Test de la valeur par defaut if (memcmp(InChar,"#DEFAULT",8)==0) { if (strstr(OutChar, "COPY")) { itsDefaultCopy = true; } else { GetValues(OutChar,&OutListe); itsDefaultValue = OutListe; itsDefaultValueValid = true; } } else { // Affectation des valeurs GetValues(InChar,&InListe); GetValues(OutChar,&OutListe); // Creation de l'arbre lexicographique if (*InListe.str()) insere((unsigned char*) InListe.str(), (unsigned char*)l_strdup(OutListe.str())); } } } // On referme le fichier TFile::Close(); return 0; }
void XtGetValues( register Widget w, register ArgList args, register Cardinal num_args) { WidgetClass wc; int targ; XtAppContext app = XtWidgetToApplicationContext(w); if (num_args == 0) return; if ((args == NULL) && (num_args != 0)) { XtAppErrorMsg(app, "invalidArgCount","xtGetValues",XtCXtToolkitError, "Argument count > 0 on NULL argument list in XtGetValues", (String *)NULL, (Cardinal *)NULL); } LOCK_APP(app); wc = XtClass(w); LOCK_PROCESS; /* Get widget values */ targ = GetValues((char*)w, (XrmResourceList *) wc->core_class.resources, wc->core_class.num_resources, args, num_args); UNLOCK_PROCESS; if (targ != -1 && XtIsWidget(w)) { XtTranslations translations = _XtGetTranslationValue(w); _XtCopyToArg((char*)&translations, &args[targ].value, sizeof(XtTranslations)); } /* Get constraint values if necessary */ /* constraints may be NULL if constraint_size==0 */ if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)) && w->core.constraints) { ConstraintWidgetClass cwc = (ConstraintWidgetClass) XtClass(XtParent(w)); LOCK_PROCESS; GetValues((char*)w->core.constraints, (XrmResourceList *)(cwc->constraint_class.resources), cwc->constraint_class.num_resources, args, num_args); UNLOCK_PROCESS; } /* Notify any class procedures that we have performed get_values */ CallGetValuesHook(wc, w, args, num_args); /* Notify constraint get_values if necessary */ if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w))) CallConstraintGetValuesHook(XtClass(XtParent(w)), w, args,num_args); UNLOCK_APP(app); } /* XtGetValues */
TEST(MockSensorTest, Pause) { const auto pollInterval = std::chrono::milliseconds(5); const ISensor::SubscriptionId subId = 1; auto listener = std::make_shared<RecordingListener>(); auto& values = listener->GetValues(); { auto poller = std::make_unique<SensorPoller>(pollInterval); auto s = poller->CreateSensor<MockSensor>("mock", MockSensor::ValuesVec{ 35.0 }); s->AddNotification(subId, std::make_shared<OnChangeSubscription>(listener, 0.5)); poller->Start(); std::this_thread::sleep_for(pollInterval * 2); EXPECT_EQ(1, values.size()); s->SetValues({ 36.0 }); std::this_thread::sleep_for(pollInterval * 2); EXPECT_EQ(2, values.size()); s->Pause(1); EXPECT_EQ(Subscription::Status::PAUSED, s->GetStatus(1)); s->SetValues({ 37.0 }); std::this_thread::sleep_for(pollInterval * 2); EXPECT_EQ(2, values.size()); s->Unpause(1); EXPECT_EQ(Subscription::Status::ACTIVE, s->GetStatus(1)); std::this_thread::sleep_for(pollInterval * 2); EXPECT_EQ(3, values.size()); } }
TEST(MockSensorTest, MultiValue) { const auto pollInterval = std::chrono::milliseconds(10); const auto sleepTime = pollInterval * 5.9; const ISensor::SubscriptionId subId = 1; const auto startTime = std::chrono::system_clock::now(); auto listener = std::make_shared<RecordingListener>(); { auto poller = std::make_unique<SensorPoller>(pollInterval); auto s = poller->CreateSensor<MockSensor>("mock", MockSensor::ValuesVec{ 1, 2, 3 }); s->AddNotification(subId, std::make_shared<IntervalSubscription>(listener, pollInterval)); poller->Start(); std::this_thread::sleep_for(sleepTime); } MockSensor::ValuesVec expectedValues{ 1, 2, 3, 1, 2 }; auto& actualValues = listener->GetValues(); EXPECT_LE(5, actualValues.size()); auto lastTime = startTime; for (size_t idx = 0; idx < std::min(size_t{5}, actualValues.size()); ++idx) { EXPECT_FLOAT_EQ(expectedValues[idx], actualValues[idx].second); EXPECT_LT(lastTime, actualValues[idx].first); lastTime = actualValues[idx].first; } }
TEST(MockSensorTest, Interval) { const auto pollInterval = std::chrono::milliseconds(10); const auto sleepTime = pollInterval * 5.9; const ISensor::SubscriptionId subId = 1; const auto startTime = std::chrono::system_clock::now(); auto listener = std::make_shared<RecordingListener>(); { auto poller = std::make_unique<SensorPoller>(pollInterval); auto s = poller->CreateSensor<MockSensor>("mock", MockSensor::ValuesVec{ 35.0 }); s->AddNotification(subId, std::make_shared<IntervalSubscription>(listener, pollInterval)); poller->Start(); std::this_thread::sleep_for(sleepTime); } auto& values = listener->GetValues(); EXPECT_LE(5, values.size()); auto lastTime = startTime; for (auto value : values) { EXPECT_FLOAT_EQ(35.0, value.second); EXPECT_LT(lastTime, value.first); lastTime = value.first; } }
void FbAuthorModifyDlg::DoModify() { AuthorItem author(m_id); GetValues(author); author.Save(m_database); FbCollection::ResetAuth(m_id); }
// Accessors double Envelope::GetValue(double t) const { double temp; GetValues(&temp, 1, t, 1.0); return temp; }
CConfigValue *CConfigDB::GetValue(EConfigNamespace ns, const CStr& name) { CConfigValueSet* values = GetValues(ns, name); if (!values) return NULL; return &((*values)[0]); }
bool dlgWaypointEditShowModal(Waypoint &way_point) { global_wpt = &way_point; wf = LoadDialog(nullptr, UIGlobals::GetMainWindow(), Layout::landscape ? _T("IDR_XML_WAYPOINTEDIT_L") : _T("IDR_XML_WAYPOINTEDIT")); assert(wf != NULL); SetUnits(); SetValues(); if (CommonInterface::GetUISettings().coordinate_format == CoordinateFormat::UTM) { ShowMessageBox( _("Sorry, the waypoint editor is not yet available for the UTM coordinate format."), _("Waypoint Editor"), MB_OK); return false; } wf->SetModalResult(mrCancel); bool retval = false; if (wf->ShowModal() == mrOK) { GetValues(); retval = true; } delete wf; return retval; }
bool dlgWaypointEditShowModal(Waypoint &way_point) { global_wpt = &way_point; wf = LoadDialog(CallBackTable, XCSoarInterface::main_window, Layout::landscape ? _T("IDR_XML_WAYPOINTEDIT_L") : _T("IDR_XML_WAYPOINTEDIT")); assert(wf != NULL); buttonName = ((WndButton *)wf->FindByName(_T("cmdName"))); assert(buttonName != NULL); buttonName->SetOnClickNotify(OnNameClicked); buttonComment = ((WndButton *)wf->FindByName(_T("cmdComment"))); assert(buttonComment != NULL); buttonComment->SetOnClickNotify(OnCommentClicked); UpdateButtons(); SetUnits(); SetValues(); wf->SetModalResult(mrCancel); bool retval = false; if (wf->ShowModal() == mrOK) { GetValues(); retval = true; } delete wf; return retval; }
static void spell_correct_word(Widget widget, XtPointer closure, XtPointer call_data) { char *corrected_word; /* get the correct word from the ascii widget */ FirstArg(XtNstring, &corrected_word); GetValues(correct_word); replace_text_in_compound(&objects, selected_word, corrected_word); redisplay_canvas(); }
NetworkMuninNodePlugin::NetworkMuninNodePlugin() { m_LastUdpPacketInCount = 0; m_LastUdpPacketOutCount = 0; m_LastTcpPacketInCount = 0; m_LastTcpPacketOutCount = 0; // Get the initial packet counts char buffer[65] = {0}; GetValues(buffer, 64); }
void dlgWaypointEditShowModal(WAYPOINT *wpt) { if (!wpt) { return; } global_wpt = wpt; if (!ScreenLandscape) { char filename[MAX_PATH]; LocalPathS(filename, TEXT("dlgWaypointEdit_L.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_WAYPOINTEDIT_L")); } else { char filename[MAX_PATH]; LocalPathS(filename, TEXT("dlgWaypointEdit.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_WAYPOINTEDIT")); } if (wf) { buttonName = ((WndButton *)wf->FindByName(TEXT("cmdName"))); if (buttonName) { buttonName->SetOnClickNotify(OnNameClicked); } buttonComment = ((WndButton *)wf->FindByName(TEXT("cmdComment"))); if (buttonComment) { buttonComment->SetOnClickNotify(OnCommentClicked); } UpdateButtons(); SetUnits(); SetValues(); wf->SetModalResult(mrCancle); if (wf->ShowModal()==mrOK) { //// GetValues(); } delete wf; } wf = NULL; }
BOOL CParser::ParseTable(DWORD dwUserData) /***********************************************************************/ { BOOL fRet = TRUE; LPSTR lpString, lpEntryString, lpKey, lpValues; int nIndex, nValues; HPTR lpData; LPSTR lpStringBuf, lpEntryStringBuf; if (!InitTable(dwUserData)) return(FALSE); lpStringBuf = (LPSTR)Alloc(BUFFER_SIZE); lpEntryStringBuf = (LPSTR)Alloc(BUFFER_SIZE); if (!lpStringBuf || !lpEntryStringBuf) { if (lpStringBuf) FreeUp(lpStringBuf); if (lpEntryStringBuf) FreeUp(lpEntryStringBuf); return(FALSE); } nIndex = 0; lpData = m_lpTableData; while ( GetEntryString( &lpData, lpEntryStringBuf, BUFFER_SIZE ) ) { // Keep a copy of the Entry string for error messages lpString = lpStringBuf; lpEntryString = lpEntryStringBuf; lstrcpy(lpString, lpEntryString); // get key while (lpKey = GetKey( &lpEntryString )) { // get value if (lpValues = GetValues( &lpEntryString, &nValues )) { // handle this entry if (!HandleKey(lpString, lpKey, lpValues, nValues, nIndex, dwUserData)) { fRet = FALSE; break; } } } // process next entry ++nIndex; } FreeUp(lpStringBuf); FreeUp(lpEntryStringBuf); return(fRet); }
void XtGetSubvalues( XtPointer base, /* Base address to fetch values from */ XtResourceList resources, /* The current resource values. */ Cardinal num_resources, /* number of items in resources */ ArgList args, /* The resource values requested */ Cardinal num_args) /* number of items in arg list */ { XrmResourceList* xrmres; xrmres = _XtCreateIndirectionTable(resources, num_resources); GetValues((char*)base, xrmres, num_resources, args, num_args); XtFree((char *)xrmres); }
VmbErrorType EnumFeature::GetEntries( EnumEntry *pEntries, VmbUint32_t &rnSize ) { VmbErrorType res = GetValues( (const char**)NULL, rnSize ); if ( 0 < m_EnumStringValues.size() && VmbErrorSuccess == res ) { m_EnumEntries.clear(); for ( StringVector::iterator iter = m_EnumStringValues.begin(); m_EnumStringValues.end() != iter; ++iter ) { EnumEntry entry; res = GetEntry( entry, (*iter).c_str() ); if ( VmbErrorSuccess == res ) { m_EnumEntries.push_back( entry ); } else { m_EnumEntries.clear(); break; } } if ( VmbErrorSuccess == res ) { if ( NULL == pEntries ) { rnSize = (VmbUint32_t)m_EnumEntries.size(); } else if ( m_EnumEntries.size() <= rnSize ) { VmbUint32_t i = 0; for ( EnumEntryVector::iterator iter = m_EnumEntries.begin(); m_EnumEntries.end() != iter; ++iter, ++i ) { pEntries[i] = (*iter); } rnSize = (VmbUint32_t)m_EnumIntValues.size(); } else { res = VmbErrorMoreData; } } } return res; }
static XtCallbackProc switch_bound(Widget w, XtPointer closure, XtPointer call_data) { Boolean state; /* check state of the toggle and set/remove checkmark */ FirstArg(XtNstate, &state); GetValues(w); if (state ) { FirstArg(XtNbitmap, sm_check_pm); } else { FirstArg(XtNbitmap, sm_null_check_pm); } SetValues(w); /* set global */ bound_active_layers = state; update_figure_size(); }
bool JankyTargeting::ProcessOneImage(void) { PIDTurret.Enable(); numValidBogies = 0; if (GetImage()==true) { numImagesProcessed++; smarty->PutInt("Images Processed", numImagesProcessed); if (DoImageProcessing()==true) if (GetParticles()==true) { for (int i=0 ; i<vPAR->size() && i<3 ; i++) { par = &(*vPAR)[i]; if (par->particleArea < MIN_PARAREA) break; GetValues(); if (rect_score > MIN_SCORE) { bogies[numValidBogies].BogeyBRCX=BRcenterx; bogies[numValidBogies].BogeyBRCY=BRcentery; bogies[numValidBogies].BogeyTop=par->boundingRect.top; bogies[numValidBogies].BogeyLeft=par->boundingRect.left; bogies[numValidBogies].BogeyVD=visualdistance; bogies[numValidBogies].BogeyPMCX=par->center_mass_x; bogies[numValidBogies].BogeyPMCY=par->center_mass_y; bogies[numValidBogies].BogeySCORE=rect_score; //bogies[numValidBogies].BogeyRATIO=aspect_ratio; numValidBogies ++; } } PrintBogey(); } } else return false; delete vPAR; delete samwise; }
int32 parseExp(FILE* fp, int32 currExp, sParams* PB, int32* tabVal) { char str[MAX_STR]; int32 numExp; char varName [MAX_STR]; char varValue [MAX_SIZE_PARAM]; char valueList [MAX_STR]; int32 nbVal = 0; int32 n; rewind(fp); numExp = 0; // Exp 0 does not exists while ((numExp != currExp) && (fgets(str, MAX_STR,fp) != NULL)) numExp = atoi(str); // Find the experiment to parse if (numExp != currExp) HandleError("parseExp", "bug !", 0, ERR_ABORT); numExp = 0; while ((numExp == 0) && (fgets(str, MAX_STR,fp) != NULL)) { str[strlen(str) -1] = (char)0; // remove newline numExp = atoi(str); if (numExp == 0) { // a line to parse ! uint32 pos = 0; int32 i=0; while ((pos < strlen(str)) && ((str[pos] == (char)32) || (str[pos] == (char)9))) pos++; //ignore tabs and spaces while ((pos < strlen(str)) && ((str[pos] != (char)32) && (str[pos] != (char)9))) varName[i++] = str[pos++]; //Param Name if ((i != 0) && (varName[0] != '=')) { // There is a new parameter ! varName[i] = (char)0; i = 0; while ((pos < strlen(str)) && ((str[pos] == (char)32) || (str[pos] == (char)9))) pos++; //ignore tabs and spaces while ((pos < strlen(str)) && ((str[pos] != (char)32) && (str[pos] != (char)9))) varValue[i++] = str[pos++]; //Param Value varValue[i] = (char)0; i = 0; while (pos < strlen(str)) valueList[i++] = str[pos++]; //Rest of the line valueList[i] = (char)0; n = GetValues(varName, varValue, PB, valueList, tabVal); if (n != 0) nbVal = n; } } } return (nbVal); }
static XtCallbackProc switch_print_layers(Widget w, XtPointer closure, XtPointer call_data) { Boolean state; int which; /* check state of the toggle and set/remove checkmark */ FirstArg(XtNstate, &state); GetValues(w); if (state ) { FirstArg(XtNbitmap, sm_check_pm); } else { FirstArg(XtNbitmap, sm_null_check_pm); } SetValues(w); /* set the sensitivity of the toggle button to the opposite of its state so that the user must press the other one now */ XtSetSensitive(w, !state); /* and make the *other* button the opposite state */ if (w == printalltoggle) { XtSetSensitive(printactivetoggle, state); } else { XtSetSensitive(printalltoggle, state); } /* which button */ which = (int) XawToggleGetCurrent(w); if (which == 0) /* no buttons on, in transition so return now */ return; if (which == 2) /* "blank" button, invert state */ state = !state; /* set global state */ print_all_layers = state; update_figure_size(); return; }
void LocationDlg::OnTreeSelChanged( wxTreeEvent &event ) { int previous = m_iAnim; m_current = event.GetItem(); wxTreeItemId selid = m_current; if (selid.IsOk()) { // If they click on a subitem (point), look at its parent wxTreeItemId parent = GetAnimTree()->GetItemParent(selid); if (parent != m_root) selid = parent; // Look through the tree to find the index wxTreeItemIdValue cookie; wxTreeItemId id; int count = 0; for (id = GetAnimTree()->GetFirstChild(m_root, cookie); id.IsOk(); id = GetAnimTree()->GetNextChild(m_root, cookie)) { if (id == selid) m_iAnim = count; count++; } } else m_iAnim = -1; if (previous != m_iAnim) { UpdateEnabling(); GetValues(); UpdateSlider(); ValuesToSliders(); TransferToWindow(); } }
void MaterialPropertyBlock_Imp::AddValuesTo(NativeShader_Imp* shader, std::vector<ShaderConstantValue>& dst) { for (auto& v : GetValues()) { auto v_ = v.second; auto str = ToUtf8String(v.first.c_str()); if (v.second.ValueType == ShaderVariableType::Texture2D) { v_.ID = shader->GetTextureID(str.c_str()); } else if (v.second.ValueType == ShaderVariableType::CubemapTexture) { v_.ID = shader->GetTextureID(str.c_str()); } else { v_.ID = shader->GetConstantBufferID(str.c_str()); } dst.push_back(v_); } }
void Rescan(Widget widget, XEvent *event, String *params, Cardinal *num_params) { char *dir; /* * get the mask string from the File or Export mask widget and put in * dirmask */ if (browse_up) { FirstArg(XtNstring, &dirmask); GetValues(browse_mask); FirstArg(XtNstring, &dir); GetValues(browse_dir); if (change_directory(dir)) /* make sure we are there */ return; strcpy(cur_browse_dir,dir); /* save in global var */ (void) MakeFileList(dir, dirmask, &dir_list, &file_list); NewList(browse_flist, file_list); NewList(browse_dlist, dir_list); } else if (file_up) { FirstArg(XtNstring, &dirmask); GetValues(file_mask); FirstArg(XtNstring, &dir); GetValues(file_dir); if (change_directory(dir)) /* make sure we are there */ return; strcpy(cur_file_dir,dir); /* save in global var */ strcpy(cur_export_dir,dir); /* set export directory to file directory */ (void) MakeFileList(dir, dirmask, &dir_list, &file_list); NewList(file_flist,file_list); NewList(file_dlist,dir_list); } else if (export_up) { FirstArg(XtNstring, &dirmask); GetValues(exp_mask); FirstArg(XtNstring, &dir); GetValues(exp_dir); if (change_directory(dir)) /* make sure we are there */ return; strcpy(cur_export_dir,dir); /* save in global var */ (void) MakeFileList(dir, dirmask, &dir_list, &file_list); NewList(exp_flist, file_list); NewList(exp_dlist, dir_list); } }
// ======================================== TAG NEEDS UPDATING ================================================== bool TtextEditForm::NeedCommit() { string_definition original; int ii; GetValues(); // get the definition from the tag if( !read_string_definition( &original, fEntry ) ) return TRUE; // happy fun text formatting for( ii = 0; ii < original.string_length; ii++ ) { if( original.string_buffer[ii] == '\r' ) original.string_buffer[ii] = '\n'; } if( original.string_length == def.string_length ) return memcmp( original.string_buffer, def.string_buffer, original.string_length ); return TRUE; }
static void background_select(Widget w, XtPointer closure, XtPointer call_data) { Pixel bgcolor, fgcolor; /* get the colors from the color button just pressed */ FirstArg(XtNbackground, &bgcolor); NextArg(XtNforeground, &fgcolor); GetValues(w); /* get the colorname from the color button and put it and the colors in the menu button */ FirstArg(XtNlabel, XtName(w)); NextArg(XtNbackground, bgcolor); NextArg(XtNforeground, fgcolor); SetValues(print_background_panel); /* update the export panel too if it exists */ if (export_background_panel) SetValues(export_background_panel); export_background_color = (int)closure; XtPopdown(background_menu); }
ECode IccServiceTable::ToString( /* [out] */ String* result) { VALIDATE_NOT_NULL(result); AutoPtr<ArrayOf<IInterface*> > values = GetValues(); Int32 numBytes = mServiceTable->GetLength(); StringBuilder builder(GetTag()); builder.Append('['); builder.Append(numBytes * 8); builder.Append(String("]={ ")); Boolean addComma = FALSE; for (Int32 i = 0; i < numBytes; i++) { Byte currentByte = (*mServiceTable)[i]; for (Int32 bit = 0; bit < 8; bit++) { if ((currentByte & (1 << bit)) != 0) { if (addComma) { builder.Append(", "); } else { addComma = TRUE; } Int32 ordinal = (i * 8) + bit; if (ordinal < values->GetLength()) { builder.Append((*values)[ordinal]); } else { builder.Append('#'); builder.Append(ordinal + 1); // service number (one-based) } } } } builder.Append(" }"); builder.ToString(result); return NOERROR; }
QVector<Bit> AVRStudioXMLParser::GetBits(QDomNode node) { QVector<Bit> bits(0); while(!node.isNull()) { QDomNamedNodeMap attributes = node.attributes(); Bit bit; for(int i = 0; i < attributes.size(); i++) { QDomNode attribute = attributes.item(i); if(bit.GetMappingMap()[attribute.nodeName()]) *bit.GetMappingMap()[attribute.nodeName()] = attribute.nodeValue(); } bit.SetValues(GetValues(node.childNodes())); bits.append(bit); node = node.nextSibling(); } return bits; }
// ======================================== SAVE TO TAG ================================================== void TtextEditForm::CommitToTag() { GetValues(); save_string_definition( &def, fEntry ); }