/** * Provide the probe values to be reported that correspond to the probe labels. */ SimTK::Vector Probe::getProbeOutputs(const State& s) const { if (isDisabled()) { stringstream errorMessage; errorMessage << getConcreteClassName() << ": Cannot get the output from Probe '" << getName() << "' because it has been disabled." << endl; throw (Exception(errorMessage.str())); } // For now, this is scalarized, i.e. compile the result of the separate // Measure for each scalar element of the probe input into a SimTK::Vector // of outputs. SimTK::Vector output(getNumProbeInputs()); for (int i=0; i<getNumProbeInputs(); ++i) { if (getOperation() == "integrate") output[i] = getGain() * (afterOperationValues[i].getValue(s) + getInitialConditions()(i)); else output[i] = getGain() * afterOperationValues[i].getValue(s); } return output; //return afterOperationValueVector.getValue(s); // save for when we can directly operate on Vector SimTK::Measures }
AudioSource* AudioSource::clone(NodeCloneContext &context) const { GP_ASSERT(_buffer); ALuint alSource = 0; AL_CHECK( alGenSources(1, &alSource) ); if (AL_LAST_ERROR()) { GP_ERROR("Error generating audio source."); return NULL; } AudioSource* audioClone = new AudioSource(_buffer, alSource); _buffer->addRef(); audioClone->setLooped(isLooped()); audioClone->setGain(getGain()); audioClone->setPitch(getPitch()); audioClone->setVelocity(getVelocity()); if (Node* node = getNode()) { Node* clonedNode = context.findClonedNode(node); if (clonedNode) { audioClone->setNode(clonedNode); } } return audioClone; }
int getMaxGain(int parent, int S, int values[LENGTH][LENGTH], int nvalues, int nattributes, att * test) { float max=0; int maxAtt; int i; float gain; for(i=-1; i>-nattributes; i--) { if(isUsed(i, test)==0) { gain=getGain(parent, S, i, values, nvalues, nattributes, test); printf("Gain of %d and %d is %lf\n", S, i, gain); if(gain>max) { max=gain; maxAtt=i; } } } if (max==0) { int pos=positiveValues(0, S, values, nvalues, nattributes, test); int neg=negativeValues(0, S, values, nvalues, nattributes, test); if (pos>neg) { maxAtt=100; } else { maxAtt=101; } } return maxAtt; }
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) { setGain(getGain()); if (demodulatorPreThread) { std::string currentDemodType = demodulatorPreThread->getDemodType(); if ((currentDemodType != "") && (currentDemodType != demod_type_in)) { lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings(); lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth(); } #if ENABLE_DIGITAL_LAB if (activeOutput) { activeOutput->Hide(); } #endif demodulatorPreThread->setDemodType(demod_type_in); int lastbw = 0; if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) { lastbw = lastModemBandwidth[demod_type_in]; } if (!lastbw) { lastbw = Modem::getModemDefaultSampleRate(demod_type_in); } if (lastbw) { setBandwidth(lastbw); } } }
void AtemAudioGainCommand::writeProperties(QXmlStreamWriter* writer) { AbstractCommand::writeProperties(writer); writer->writeTextElement("audiogaininput", getInput()); writer->writeTextElement("gain", QString::number(getGain())); writer->writeTextElement("triggeronnext", (getTriggerOnNext() == true) ? "true" : "false"); }
void SoundEmitter::updateSource() { InternalMessage("Sound","SoundEmitter::updateSource entering") ; handleSourceState() ; bool active(isActive()) ; if (active) { InternalMessage("Sound","SoundEmitter::updateSource updating sound") ; /// @todo If parameters are never changed move them to init alSourcef(getSource(), AL_GAIN, getGain()) ; InternalMessage("Sound","SoundEmitter::updateSource setting gain=" + Kernel::toString(getGain())) ; alSourcef(getSource(), AL_REFERENCE_DISTANCE, getRefDistance()); alSourcef(getSource(), AL_MAX_DISTANCE, getMaxDistance()); alSourcef(getSource(), AL_ROLLOFF_FACTOR, getRolloffFactor()); Ogre::Vector3 position = getPosition().Meter() ; InternalMessage("Sound","SoundEmitter::updateSource position=" + ::Ogre::StringConverter::toString(position)) ; alSource3f(getSource(),AL_POSITION,(float)position.x,(float)position.y,(float)position.z) ; Ogre::Vector3 speed = getSpeed().MeterPerSecond(); InternalMessage("Sound","SoundEmitter::updateSource speed=" + ::Ogre::StringConverter::toString(position)) ; alSource3f(getSource(),AL_VELOCITY,(float)speed.x,(float)speed.y,(float)speed.z) ; // update Environment Effect Model::SoundEnvironnement* env = getObject()->getParent<Model::SoundEnvironnement>() ; if (env) { SoundEnvironnement* envView = env->getView<SoundEnvironnement>(m_viewpoint) ; if (envView) { ALuint auxEffectSlot = envView->getAuxEffectSlot() ; //SoundEnvironnement has changed if (auxEffectSlot != m_auxEffectSlot) { m_auxEffectSlot = auxEffectSlot; EFX::applyEffectToSource(getSource(), m_auxEffectSlot) ; InformationMessage("Sound", "update add reverb") ; } } else { InformationMessage("Sound", "no envView") ; } } else { InformationMessage("Sound", "no env") ; } } }
bool FastConvexFitting::getEvaluation(Geometry & geometry) { QVector<int> edgeid; QVector<int> startid; QVector<int> endid; if(getBeamRange(geometry,edgeid,startid,endid)) { geometry.score=1; int j,m=edgeid.size(); for(j=0;j<m;j++) { if(startid[j]>endid[j]) { endid[j]+=beamsnum; } Eigen::Matrix2d A; A.block(0,0,2,1)=orientation*(geometry.edges[edgeid[j]].startcorner-geometry.edges[edgeid[j]].endcorner); Eigen::Vector2d B; B=position+orientation*(geometry.edges[edgeid[j]].startcorner); int k; int count=0; double score=1; for(k=startid[j];k<=endid[j];k++) { int tmpid=k; if(tmpid>=beamsnum) { tmpid-=beamsnum; } if(beams[tmpid]<=MINIMUMDISTANCE) { continue; } A.block(0,1,2,1)=points[tmpid]; Eigen::Vector2d x=A.inverse()*B; score*=getGain(x(0),x(1),beams[tmpid]); count++; } if(count>0) { geometry.score*=pow(score,1.0/double(count)); } else { geometry.score=0; return 0; } } return 1; } else { geometry.score=0; return 0; } }
void PoseTask::getDerivError(const Eigen::VectorXd& q, Eigen::VectorXd& de) { Eigen::VectorXd xsensed, xdes, error; getDesiredValue(xdes); getSensedValue(q, xsensed); //de = -gain_*(xsensed-xdes); error = xsensed-xdes; de = -getGain(error.norm())*error; }
bool QCamVesta::updateFrame() { static int tmp; if (skippedFrame_ < multiplicateur_-1) { if (skippedFrame_ >= multiplicateur_ -3) { stopAccumulation(); } if (QCamV4L2::dropFrame()) { skippedFrame_++; exposureTimeLeft_->setValue(skippedFrame_); tmp=0; } return false; } else { if (QCamV4L2::updateFrame()) { skippedFrame_=0; if (multiplicateur_ > 1) { startAccumulation(); if (guiBuild()) exposureTimeLeft_->reset(); } int tmpVal; setProperty("Gain",tmpVal=getGain(),false); emit gainChange(tmpVal); //emit exposureChange(getExposure()); //setProperty("Gama",tmpVal=getGama()); //emit gamaChange(tmpVal); //emit compressionChange(getCompression()); /* setProperty("NoiseRemoval",tmpVal=getNoiseRemoval()); emit noiseRemovalChange(tmpVal); setProperty("Sharpness",tmpVal=getSharpness()); emit sharpnessChange(tmpVal); */ setProperty("FrameRateSecond",(tmpVal=getFrameRate())/(double)multiplicateur_); emit frameRateChange(tmpVal); if (liveWhiteBalance_ || refreshGui_) { getWhiteBalance(); } if (SCmodCtrl_) { setProperty("ExposureTime",multiplicateur_/(double)getFrameRate()); emit frameRateMultiplicateurChange(multiplicateur_); emit exposureTime(multiplicateur_/(double)getFrameRate()); } else { setProperty("ExposureTime",1/(double)getFrameRate()); } refreshGui_=false; return true; } else { refreshGui_=false; return false; } } }
QCamVesta::QCamVesta(const char * devpath): QCamV4L2(devpath,(ioNoBlock|ioUseSelect|haveBrightness|haveContrast|haveColor)) { SCmodCtrl_=NULL; exposureTimeLeft_=NULL; whiteBalanceMode_=-1; { /* sanity check */ bool IsPhilips = false; struct pwc_probe probe; if (sscanf((char*)v4l2_cap_.card, "Philips %d webcam", &type_) == 1) { /* original phillips */ IsPhilips = true; } else if (ioctl(device_, VIDIOCPWCPROBE, &probe) == 0) { /* an OEM clone ? */ if (!strcmp((char*)v4l2_cap_.card,probe.name)) { IsPhilips = true; type_=probe.type; } } if (!IsPhilips) { QMessageBox::information(0,"Qastrocam-g2","QCamVesta::QCamVesta() called on a non Philips Webcam.\ndid you use QCamV4L::openBestDevice() to open your device?"); cout << "QCamVesta::QCamVesta() called on a non Philips Webcam.\n" << "did you use QCamV4L::openBestDevice() to open your device?" << endl; exit(1); } } //initRemoteControl(remoteCTRL_); multiplicateur_=1; if (exposureTimeLeft_) exposureTimeLeft_->hide(); skippedFrame_=0; liveWhiteBalance_=false /* set to true to show dynamicaly white balance setting (slow) */; refreshGui_=true; haveLeds_= (type_ >= 730); setLed(0,255); setWhiteBalanceMode(PWC_WB_AUTO); getWhiteBalance(); lastGain_=getGain(); // read the window_ values // generic V4L don't do it anymore if(ioctl(device_,VIDIOCGWIN, &window_)) perror("ioctl (VIDIOCGWIN)"); }
void QCamVesta::refreshPictureSettings() { QCamV4L2::refreshPictureSettings(); QCamV4L2::refreshPictureSettings(); // second call needed. if not some value are not properly restored. int tmp; emit(sharpnessChange(getSharpness())); emit(noiseRemovalChange(getNoiseRemoval())); emit(gainChange(getGain())); setProperty("CompressionWished",tmp=getCompression()); emit(compressionChange(tmp)); setProperty("Gama",tmp=getGama()); emit gamaChange(tmp); getWhiteBalance(); }
void SoundListener::updateListener() { Ogre::Vector3 position = this->getPosition().Meter() ; alListener3f(AL_POSITION, (float)position.x, (float)position.y, (float)position.z); Ogre::Quaternion orientation = this->getOrientation().getQuaternion(); ALfloat openal_orientation[6] ; openal_orientation[0] = orientation.zAxis().x ; openal_orientation[1] = orientation.zAxis().y ; openal_orientation[2] = orientation.zAxis().z ; openal_orientation[3] = orientation.yAxis().x ; openal_orientation[4] = orientation.yAxis().y ; openal_orientation[5] = orientation.yAxis().z ; alListenerfv(AL_ORIENTATION, openal_orientation) ; Ogre::Vector3 speed = this->getSpeed().MeterPerSecond(); alListener3f(AL_VELOCITY, (float)speed.x, (float)speed.y, (float)speed.z) ; alListenerf(AL_GAIN,getGain()) ; }
//------------------------------------------------------------------------------ // serialize //------------------------------------------------------------------------------ std::ostream& AnalogInput::serialize(std::ostream& sout, const int i, const bool slotsOnly) const { int j = 0; if ( !slotsOnly ) { sout << "( " << getFactoryName() << std::endl; j = 4; } indent(sout,i+j); sout << "ai: " << getLocation() << std::endl; indent(sout,i+j); sout << "channel: " << getChannel() << std::endl; indent(sout,i+j); sout << "value: " << getValue() << std::endl; indent(sout,i+j); sout << "deadband: " << getDeadband() << std::endl; indent(sout,i+j); sout << "offset: " << getOffset() << std::endl; indent(sout,i+j); sout << "gain: " << getGain() << std::endl; if (table != nullptr) { indent(sout,i+j); sout << "table: "; table->serialize(sout,(i+j+4)); } BaseClass::serialize(sout,i+j,true); if ( !slotsOnly ) { indent(sout,i); sout << ")" << std::endl; } return sout; }
static VOID SliderHookFunc( struct Hook *hook, Object *obj, ULONG** arg ) { if(obj == MUIFreq) { state.FreqSelected = (LONG) (*arg); set(MUILFreq,MUIA_Text_Contents, (ULONG) getFreq()); } else if(obj == MUIChannels ) { state.ChannelsSelected = (LONG) (*arg); set(MUILChannels,MUIA_Text_Contents, (ULONG) getChannels()); } else if(obj == MUIOutvol ) { state.OutVolSelected = (LONG) (*arg); set(MUILOutvol,MUIA_Text_Contents, (ULONG) getOutVol()); } else if(obj == MUIMonvol ) { state.MonVolSelected = (LONG) (*arg); set(MUILMonvol,MUIA_Text_Contents, (ULONG) getMonVol()); } else if(obj == MUIGain ) { state.GainSelected = (LONG) (*arg); set(MUILGain,MUIA_Text_Contents, (ULONG) getGain()); } else if(obj == MUIInput ) { state.InputSelected = (LONG) (*arg); set(MUILInput,MUIA_Text_Contents, (ULONG) getInput()); } else if(obj == MUIOutput ) { state.OutputSelected = (ULONG) (*arg); set(MUILOutput,MUIA_Text_Contents, (ULONG) getOutput()); } }
XmlElement* CDPlayer::saveToXml(const File& /*projectDirectory*/, MyMultiDocumentPanel::LayoutMode layoutMode) const { XmlElement* element = new XmlElement("CDPlayer"); element->setAttribute("gain", getGain()); element->setAttribute("mute", m_mute); element->setAttribute("solo", m_solo); element->setAttribute("color", m_color.toString()); switch (layoutMode) { case MyMultiDocumentPanel::FloatingWindows: { Rectangle<int> parentBounds = getParentComponent()->getBounds(); XmlElement* boundsXml = new XmlElement("Bounds"); boundsXml->setAttribute("x", parentBounds.getX()); boundsXml->setAttribute("y", parentBounds.getY()); boundsXml->setAttribute("width", parentBounds.getWidth()); boundsXml->setAttribute("height", parentBounds.getHeight()); element->addChildElement(boundsXml); } break; case MyMultiDocumentPanel::MaximisedWindowsWithTabs: { XmlElement* mdiDocumentPosXml = new XmlElement("MdiDocumentPos"); mdiDocumentPosXml->addTextElement(getProperties()["mdiDocumentPos_"]); element->addChildElement(mdiDocumentPosXml); } break; } XmlElement* nameXml = new XmlElement("Name"); nameXml->addTextElement(Component::getName()); element->addChildElement(nameXml); XmlElement* driveXml = new XmlElement("Drive"); driveXml->addTextElement(m_availableCDsComboBox.getText()); element->addChildElement(driveXml); return element; }
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) { setGain(getGain()); if (demodulatorPreThread) { std::string currentDemodType = demodulatorPreThread->getDemodType(); if ((currentDemodType != "") && (currentDemodType != demod_type_in)) { lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings(); lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth(); } #if ENABLE_DIGITAL_LAB if (activeOutput) { activeOutput->Hide(); } #endif demodulatorPreThread->setDemodType(demod_type_in); int lastbw = 0; if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) { lastbw = lastModemBandwidth[demod_type_in]; } if (!lastbw) { lastbw = Modem::getModemDefaultSampleRate(demod_type_in); } if (lastbw) { setBandwidth(lastbw); } #if ENABLE_DIGITAL_LAB if (isModemInitialized() && getModemType() == "digital") { ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput(); outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency())); } #endif } wxGetApp().getBookmarkMgr().updateActiveList(); }
BOOL BuildGUI(char *screenname) { Object **ar = Window_Objs; struct Screen *screen; BOOL OptionFrame = FALSE; LONG indicatorwidth = 100; Object *l1, *l2, *l3, *l4, *l5, *l6, *l7; UpdateStrings(); if (ButtonBase == NULL) { /* force it open */ Printf((char *) msgTextNoOpen, "button.gadget", __classactversion); Printf("\n"); return FALSE; } /* Dynamic */ unitlist = ChooserLabelsA( (STRPTR *) Units); modelist = BrowserNodesA( (STRPTR *) Modes); infolist = BrowserNodes2(infotexts, infoargs); /* Static */ pagelist = ClickTabs( (char *) msgPageMode, (char *) msgPageAdvanced, NULL); debuglist = ChooserLabels( (char *) msgDebugNone, (char *) msgDebugLow, (char *) msgDebugHigh, (char *) msgDebugFull, NULL); echolist = ChooserLabels( (char *) msgEchoEnabled, (char *) msgEchoFast, (char *) msgEchoDisabled, NULL); surroundlist = ChooserLabels( (char *) msgSurroundEnabled, (char *) msgSurroundDisabled, NULL); clipMVlist = ChooserLabels( (char *) msgMVNoClip, (char *) msgMVClip, NULL); screen = LockPubScreen(screenname); vi = GetVisualInfoA(screen, NULL); Menu = CreateMenusA(NewMenus, NULL); if(vi == NULL || Menu == NULL) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } if(!LayoutMenus(Menu, vi, GTMN_NewLookMenus, TRUE, TAG_DONE)) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } indicatorwidth = max(indicatorwidth, 16 * screen->RastPort.Font->tf_XSize); if(screen->Height > 240) { OptionFrame = TRUE; } ar[ACTID_PAGE] = PageObject, PAGE_Current, 0, /* PAGE 1 */ PAGE_Add, HLayoutObject, LAYOUT_VertAlignment, LALIGN_CENTER, LAYOUT_AddChild, VLayoutObject, LAYOUT_AddChild, ar[ACTID_UNIT] = PopUpObject, CHOOSER_Labels, unitlist, CHOOSER_Active, state.UnitSelected, ChooserEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, ar[ACTID_MODE] = ListBrowserObject, LISTBROWSER_Labels, modelist, LISTBROWSER_MakeVisible,state.ModeSelected, LISTBROWSER_Selected, state.ModeSelected, LISTBROWSER_ShowSelected,TRUE, ListBrowserEnd, LAYOUT_AddChild, ar[SHOWID_MODE] = ListBrowserObject, LISTBROWSER_Labels, infolist, LISTBROWSER_ColumnInfo, (ULONG)&ci, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_VertSeparators, FALSE, GA_ReadOnly, TRUE, ListBrowserEnd, CHILD_MaxHeight, screen->RastPort.Font->tf_YSize * 6 + 6, // UHH!! LayoutEnd, LAYOUT_AddChild, HLayoutObject, (OptionFrame ? LAYOUT_SpaceOuter : TAG_IGNORE), TRUE, (OptionFrame ? LAYOUT_RightSpacing : TAG_IGNORE), 0, (OptionFrame ? LAYOUT_BevelStyle : TAG_IGNORE), BVS_GROUP, (OptionFrame ? LAYOUT_Label : TAG_IGNORE), (char *) msgOptions, LAYOUT_AddChild, VLayoutObject, LAYOUT_AddChild, l1 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_FREQ] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Frequencies, SLIDER_Level, state.FreqSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptFrequency, LabelEnd, LAYOUT_AddChild, ar[SHOWID_FREQ] = ButtonObject, GA_Text, getFreq(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l2 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_CHANNELS] = SliderObject, SLIDER_Min, 1, SLIDER_Max, state.Channels, SLIDER_Level, state.ChannelsSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptChannels, LabelEnd, LAYOUT_AddChild, ar[SHOWID_CHANNELS] = ButtonObject, GA_Text, getChannels(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l3 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_OUTVOL] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.OutVols, SLIDER_Level, state.OutVolSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptVolume, LabelEnd, LAYOUT_AddChild, ar[SHOWID_OUTVOL] = ButtonObject, GA_Text, getOutVol(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l4 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_MONVOL] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.MonVols, SLIDER_Level, state.MonVolSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptMonitor, LabelEnd, LAYOUT_AddChild, ar[SHOWID_MONVOL] = ButtonObject, GA_Text, getMonVol(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l5 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_GAIN] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Gains, SLIDER_Level, state.GainSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptGain, LabelEnd, LAYOUT_AddChild, ar[SHOWID_GAIN] = ButtonObject, GA_Text, getGain(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l6 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_INPUT] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Inputs, SLIDER_Level, state.InputSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptInput, LabelEnd, LAYOUT_AddChild, ar[SHOWID_INPUT] = ButtonObject, GA_Text, getInput(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l7 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_OUTPUT] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Outputs, SLIDER_Level, state.OutputSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptOutput, LabelEnd, LAYOUT_AddChild, ar[SHOWID_OUTPUT] = ButtonObject, GA_Text, getOutput(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LayoutEnd, LayoutEnd, CHILD_WeightedHeight, 0, LayoutEnd, /* PAGE 2 */ PAGE_Add, HLayoutObject, LAYOUT_VertAlignment, LALIGN_CENTER, LAYOUT_HorizAlignment, LALIGN_CENTER, LAYOUT_AddChild, VLayoutObject, LAYOUT_SpaceOuter, TRUE, LAYOUT_BevelStyle, BVS_GROUP, LAYOUT_Label, (char *) msgGlobalOptions, LAYOUT_VertAlignment, LALIGN_BOTTOM, LAYOUT_AddChild, ar[ACTID_DEBUG] = PopUpObject, CHOOSER_Labels, debuglist, CHOOSER_Active, globalprefs.ahigp_DebugLevel, ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptDebugLevel, LabelEnd, LAYOUT_AddChild, ar[ACTID_ECHO] = PopUpObject, CHOOSER_Labels, echolist, CHOOSER_Active, (globalprefs.ahigp_DisableEcho ? 2 : 0) | (globalprefs.ahigp_FastEcho ? 1 : 0), ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptEcho, LabelEnd, LAYOUT_AddChild, ar[ACTID_SURROUND] = PopUpObject, CHOOSER_Labels, surroundlist, CHOOSER_Active, globalprefs.ahigp_DisableSurround, ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptSurround, LabelEnd, LAYOUT_AddChild, ar[ACTID_CLIPMV] = PopUpObject, CHOOSER_Labels, clipMVlist, CHOOSER_Active, globalprefs.ahigp_ClipMasterVolume, ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptMasterVol, LabelEnd, LAYOUT_AddChild, ar[ACTID_CPULIMIT] = IntegerObject, INTEGER_MaxChars, 3, INTEGER_MinVisible, 3, INTEGER_Minimum, 0, INTEGER_Maximum, 100, INTEGER_Number, (globalprefs.ahigp_MaxCPU * 100 + 32768) >> 16, INTEGER_Arrows, TRUE, IntegerEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptCPULimit, LabelEnd, LayoutEnd, CHILD_WeightedHeight, 0, CHILD_WeightedWidth, 0, LayoutEnd, PageEnd; if(ar[ACTID_PAGE] != NULL) { SetAttrs( l1, LAYOUT_AlignLabels, l2, TAG_DONE); SetAttrs( l2, LAYOUT_AlignLabels, l3, TAG_DONE); SetAttrs( l3, LAYOUT_AlignLabels, l4, TAG_DONE); SetAttrs( l4, LAYOUT_AlignLabels, l5, TAG_DONE); SetAttrs( l5, LAYOUT_AlignLabels, l6, TAG_DONE); SetAttrs( l6, LAYOUT_AlignLabels, l7, TAG_DONE); SetAttrs( l7, LAYOUT_AlignLabels, l1, TAG_DONE); } WO_Window = WindowObject, WA_PubScreen, screen, WA_Title, (char *) msgTextProgramName, WA_CloseGadget, TRUE, WA_DepthGadget, TRUE, WA_DragBar, TRUE, WA_Activate, TRUE, WA_SizeGadget, TRUE, WA_SizeBBottom, TRUE, WA_NewLookMenus, TRUE, WA_InnerWidth, 800, WA_InnerHeight, 400, WINDOW_MenuStrip, Menu, WINDOW_Position, WPOS_CENTERSCREEN, WINDOW_GadgetUserData, WGUD_HOOK, WINDOW_IDCMPHook, &IDCMPhook, WINDOW_IDCMPHookBits, IDCMP_RAWKEY, WINDOW_Layout, VLayoutObject, LAYOUT_SpaceOuter, TRUE, LAYOUT_DeferLayout, TRUE, /* TABS */ LAYOUT_AddChild, ar[LAYOUT_PAGE] = VLayoutObject, LAYOUT_AddChild, ar[ACTID_TABS] = ClickTabObject, CLICKTAB_Labels, pagelist, CLICKTAB_Current, 0L, ICA_TARGET, ar[ACTID_PAGE], ICA_MAP, MapTab2Page, ClickTabEnd, LAYOUT_AddChild, ar[ACTID_PAGE], LayoutEnd, /* BUTTONS */ LAYOUT_AddChild, HLayoutObject, LAYOUT_EvenSize, TRUE, LAYOUT_AddChild, ar[ACTID_SAVE] = ButtonObject, GA_Text, (char *) msgButtonSave, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, ar[ACTID_USE] = ButtonObject, GA_Text, (char *) msgButtonUse, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, ar[ACTID_QUIT] = ButtonObject, GA_Text, (char *) msgButtonCancel, ButtonEnd, CHILD_WeightedHeight, 0, LayoutEnd, CHILD_WeightedHeight, 0, LayoutEnd, WindowEnd; if(WO_Window) { int i; for(i = 0; i < ACTID_COUNT; i++) { if(Window_Objs[i] != NULL) { SetAttrs(Window_Objs[i], GA_ID, i, GA_RelVerify, TRUE, TAG_END); } } Window = (struct Window *) CA_OpenWindow(WO_Window); } if(screen) { UnlockPubScreen(NULL, screen); } if(Window == NULL) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } openreq = GetFileObject, GETFILE_RejectIcons, TRUE, GETFILE_Drawer, "SYS:Prefs/Presets", EndObject; savereq = GetFileObject, GETFILE_RejectIcons, TRUE, GETFILE_Drawer, "SYS:Prefs/Presets", GETFILE_DoSaveMode, TRUE, EndObject; if((openreq == NULL) || (savereq == NULL)) { Printf((char *) msgTextNoFileRequester); Printf("\n"); return FALSE; } // Update the checkmark for "Create Icons?" { struct Menu *menu; struct MenuItem *item; menu = Menu; ClearMenuStrip(Window); item = FindMenuItem(ACTID_ICONS); if(item) { if(SaveIcons) item->Flags |= CHECKED; else item->Flags &= ~CHECKED; } ResetMenuStrip(Window, menu); } GUINewUnit(); return TRUE; }
static void GUINewMode(void) { int Max, Sel; sprintf(modetext,"0x%08lx", getAudioMode()); infoargs[0] = modetext; infoargs[1] = getRecord(); infoargs[2] = getAuthor(); infoargs[3] = getCopyright(); sprintf(drivertext, "Devs:AHI/%s.audio", getDriver()); infoargs[4] = drivertext; infoargs[5] = getVersion(); MySetGadgetAttrs(Window_Objs[SHOWID_MODE], LISTBROWSER_Labels, ~0, TAG_DONE); if(infolist) FreeBrowserNodes2(infolist); infolist = BrowserNodes2(infotexts, infoargs); MySetGadgetAttrs(Window_Objs[SHOWID_MODE], LISTBROWSER_Labels, infolist, TAG_DONE); Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); MySetGadgetAttrs(Window_Objs[ACTID_FREQ], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Channels, 1); Sel = min(Max, state.ChannelsSelected); MySetGadgetAttrs(Window_Objs[ACTID_CHANNELS], SLIDER_Min, 1, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 1) || state.ChannelsDisabled, TAG_DONE ); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); MySetGadgetAttrs(Window_Objs[ACTID_OUTVOL], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); MySetGadgetAttrs(Window_Objs[ACTID_MONVOL], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); MySetGadgetAttrs(Window_Objs[ACTID_GAIN], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); MySetGadgetAttrs(Window_Objs[ACTID_INPUT], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); MySetGadgetAttrs(Window_Objs[ACTID_OUTPUT], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); // Update indicators.. MySetGadgetAttrs(Window_Objs[SHOWID_FREQ], GA_Text, getFreq(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_CHANNELS], GA_Text, getChannels(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_OUTVOL], GA_Text, getOutVol(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_MONVOL], GA_Text, getMonVol(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_GAIN], GA_Text, getGain(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_INPUT], GA_Text, getInput(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_OUTPUT], GA_Text, getOutput(), TAG_DONE ); }
//-------------------------------------------------------------- void ofApp::setup(){ kinect.open(); kinect.initDepthSource(); kinect.initColorSource(); kinect.initInfraredSource(); kinect.initBodyIndexSource(); kinect.initBodySource(); gui.init(); //setup a gui panel for the 3D view auto worldView = gui.addWorld("World"); worldView->onDrawWorld += [this](ofCamera &) { this->kinect.drawWorld(); }; //setup a gui panel for every kinect source auto sources = kinect.getSources(); for(auto source : sources) { auto sourceWithTexture = dynamic_pointer_cast<ofBaseHasTexture>(source); if (sourceWithTexture) { auto panel = gui.add(sourceWithTexture->getTexture(), source->getTypeName()); //if it's the colour panel, let's do something special by writing some info on top auto colorSource = dynamic_pointer_cast<ofxKFW2::Source::Color>(source); if (colorSource) { panel->onDraw += [colorSource] (ofxCvGui::DrawArguments &) { stringstream message; message << "Exposure : " << colorSource->getExposure() << "us" << endl; message << "FrameInterval : " << colorSource->getFrameInterval() << "us" << endl; message << "Gain : " << colorSource->getGain() << endl; message << "Gamma : " << colorSource->getGamma() << endl; ofxCvGui::Utils::drawText(message.str(), 20, 60); }; } //if it's the depth panel, set some scaling auto depthSource = dynamic_pointer_cast<ofxKFW2::Source::Depth>(source); if (depthSource) { auto style = make_shared<ofxCvGui::Panels::Texture::Style>(); style->rangeMaximum = 0.25f; panel->setStyle(style); } //if it's the body index panel, let's draw the joints on top auto bodyIndexSource = dynamic_pointer_cast<ofxKFW2::Source::BodyIndex>(source); if(bodyIndexSource) { panel->onDrawImage += [this](ofxCvGui::DrawImageArguments & args) { auto bodySource = this->kinect.getBodySource(); const auto & bodies = bodySource->getBodies(); ofPushStyle(); { ofColor color(200, 100, 100); int index = 0; for (const auto & body : bodies) { color.setHueAngle((index * 50) % 360); ofSetColor(color); for (const auto & joint : body.joints) { ofDrawCircle(joint.second.getPositionInDepthMap(), 5); } index++; } } ofPopStyle(); }; } } } //if we press the 'c' key on the World panel, then toggle the camera's cursor. This works best when you fullscreen that panel worldView->onKeyboard += [this, worldView] (ofxCvGui::KeyboardArguments & args) { if (args.action == ofxCvGui::KeyboardArguments::Action::Pressed && args.key =='c') { worldView->getCamera().toggleCursorDrawEnabled(); } }; }
//------------------------------------------------------------------------------ // onRfEmissionEventAntenna() -- process events for RF Emission not sent by us. // // 1) Build a list of emission packets from the queue and compute the // Line-Of-Sight (LOS) vectors back to the transmitter. // // 2) Transform LOS vectors to antenna coordinates // // 3) Compute antenna gains in the direction of the transmitter // // 4) Compute Antenna Effective Gains // // 5) Compute Antenna Effective Area and Polarization Gains // // 6) Compute total receiving antenaa gain and send the emission to our sensor //------------------------------------------------------------------------------ bool Antenna::onRfEmissionEvent(Emission* const em) { // Is this emission from a player of interest? if (fromPlayerOfInterest(em)) { Player* ownship = getOwnship(); RfSystem* sys1 = getSystem(); if (ownship != 0 && sys1 != 0) { sys1->ref(); // Line-Of-Sight (LOS) vectors back to the transmitter. osg::Vec3d xlos = em->getTgtLosVec(); osg::Vec4d los0( xlos.x(), xlos.y(), xlos.z(), 0.0); // 2) Transform local NED LOS vectors to antenna coordinates osg::Matrixd mm = getRotMat(); mm *= ownship->getRotMat(); osg::Vec4d losA = mm * los0; // --- // Compute antenna gains in the direction of the transmitter // --- double rGainDb = 0.0f; if (gainPattern != 0) { Basic::Func1* gainFunc1 = dynamic_cast<Basic::Func1*>(gainPattern); Basic::Func2* gainFunc2 = dynamic_cast<Basic::Func2*>(gainPattern); if (gainFunc2 != 0) { // --- // 3-a) Antenna pattern: 2D table (az & el off antenna boresight) // --- // Get component arrays and ground range squared double xa = losA.x(); double ya = losA.y(); double za = -losA.z(); double ra2 = xa*xa + ya*ya; // Compute range along antenna x-y plane double ra = sqrt(ra2); // Compute azimuth off boresight double aazr = atan2(ya,xa); // Compute elevation off boresight double aelr = atan2(za,ra); // Lookup gain in 2D table and convert from dB if (gainPatternDeg) rGainDb = gainFunc2->f( aazr * Basic::Angle::R2DCC, aelr * Basic::Angle::R2DCC ); else rGainDb = gainFunc2->f( aazr, aelr ); } else if (gainFunc1 != 0) { // --- // 3-b) Antenna Pattern: 1D table (off antenna boresight only // --- // Compute angle off antenna boresight double aar = acos(losA.x()); // Lookup gain in 1D table and convert from dB if (gainPatternDeg) rGainDb = gainFunc1->f( aar * Basic::Angle::R2DCC ); else rGainDb = gainFunc1->f(aar); } } // Compute off-boresight gain double rGain = pow(10.0,rGainDb/10.0); // Compute Antenna Effective Gain double aeGain = rGain * getGain(); double lambda = em->getWavelength(); double aea = getEffectiveArea(aeGain, lambda); double pGain = getPolarizationGain(em->getPolarization()); double raGain = aea * pGain; sys1->rfReceivedEmission(em, this, LCreal(raGain)); sys1->unref(); } } return BaseClass::onRfEmissionEvent(em); }
//-------------------------------------------------------------- void ofApp::setup() { kinect.open(); kinect.initDepth(); kinect.initColor(); kinect.initInfrared(); kinect.initBodyIndex(); gui.init(); //setup a gui panel for every kinect source auto sources = kinect.getSources(); for(auto source : sources) { auto drawingSource = dynamic_pointer_cast<ofBaseDraws>(source); ofxCvGui::PanelPtr panel; if (drawingSource) { panel = gui.add(*drawingSource, source->getTypeName()); auto colorSource = dynamic_pointer_cast<ofxKFW2::Source::Color>(source); if (colorSource) { panel->onDraw += [colorSource] (ofxCvGui::DrawArguments &) { stringstream message; message << "Exposure : " << colorSource->getExposure() << "us" << endl; message << "FrameInterval : " << colorSource->getFrameInterval() << "us" << endl; message << "Gain : " << colorSource->getGain() << endl; message << "Gamma : " << colorSource->getGamma() << endl; ofxCvGui::Utils::drawText(message.str(), 20, 60); }; } } } auto worldView = gui.addWorld("World"); worldView->onDrawWorld += [this] (ofCamera &) { //setup some point cloud properties for kicks glPushAttrib(GL_POINT_BIT); glPointSize(5.0f); glEnable(GL_POINT_SMOOTH); ofPushStyle(); //bind kinect color camera texture and draw mesh from depth (which has texture coordinates) this->kinect.getColor()->getTextureReference().bind(); //draw point cloud this->mesh.drawVertices(); //draw triangles ofSetColor(255, 150); this->mesh.drawWireframe(); //draw fills faded ofSetColor(255, 50); this->mesh.drawFaces(); //unbind colour camera this->kinect.getColor()->getTextureReference().unbind(); ofPopStyle(); //clear the point cloud drawing attributes glPopAttrib(); //draw the view cones of depth and colour cameras ofPushStyle(); ofNoFill(); ofSetLineWidth(2.0f); ofSetColor(100, 200, 100); this->kinect.getDepth()->drawFrustum(); ofSetColor(200, 100, 100); this->kinect.getColor()->drawFrustum(); ofPopStyle(); }; //if we press the 'c' key on the World panel, then toggle the camera's cursor. This works best when you fullscreen that panel worldView->onKeyboard += [this, worldView] (ofxCvGui::KeyboardArguments & args) { if (args.action == ofxCvGui::KeyboardArguments::Action::Pressed && args.key =='c') { worldView->getCamera().toggleCursorDraw(); } }; }
void LLStreamingAudio_FMOD::update() { // Kill dead internet streams, if possible std::list<LLAudioStreamManagerFMOD *>::iterator iter; for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) { LLAudioStreamManagerFMOD *streamp = *iter; if (streamp->stopStream()) { llinfos << "Closed dead stream" << llendl; delete streamp; mDeadStreams.erase(iter++); } else { iter++; } } // Don't do anything if there are no streams playing if (!mCurrentInternetStreamp) { return; } int open_state = mCurrentInternetStreamp->getOpenState(); if (!open_state) { // Stream is live // start the stream if it's ready if (mFMODInternetStreamChannel < 0) { mFMODInternetStreamChannel = mCurrentInternetStreamp->startStream(); if (mFMODInternetStreamChannel != -1) { // Reset volume to previously set volume setGain(getGain()); FSOUND_SetPaused(mFMODInternetStreamChannel, false); } } } switch(open_state) { default: case 0: // success break; case -1: // stream handle is invalid llwarns << "InternetStream - invalid handle" << llendl; stop(); return; case -2: // opening break; case -3: // failed to open, file not found, perhaps llwarns << "InternetStream - failed to open" << llendl; stop(); return; case -4: // connecting break; case -5: // buffering break; } }
static void GUINewMode(void) { int Max, Sel; infoargs[0] = (char *) getAudioMode(); infoargs[1] = getRecord(); infoargs[2] = getAuthor(); infoargs[3] = getCopyright(); infoargs[4] = getDriver(); infoargs[5] = getVersion(); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_MODE], window, NULL, INFO_TextFormat, (ULONG) "0x%08lx\n" "%s\n" "%s\n" "%s\n" "Devs:AHI/%s.audio\n" "%s", INFO_Args, (ULONG) &infoargs, TAG_DONE ); Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_FREQ], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Channels, 0); Sel = min(Max, state.ChannelsSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_CHANNELS], window, NULL, SLIDER_Min, 1, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 1) || state.ChannelsDisabled, TAG_DONE ); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_OUTVOL], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_MONVOL], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_GAIN], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_INPUT], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_OUTPUT], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); // Update indicators.. SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_FREQ], window, NULL, INFO_TextFormat, (ULONG) getFreq(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_CHANNELS], window, NULL, INFO_TextFormat, (ULONG) getChannels(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_OUTVOL], window, NULL, INFO_TextFormat, (ULONG) getOutVol(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_MONVOL], window, NULL, INFO_TextFormat, (ULONG) getMonVol(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_GAIN], window, NULL, INFO_TextFormat, (ULONG) getGain(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_INPUT], window, NULL, INFO_TextFormat, (ULONG) getInput(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_OUTPUT], window, NULL, INFO_TextFormat, (ULONG) getOutput(), TAG_DONE ); }
BOOL BuildGUI(char *screenname) { Object *MUISave, *MUIUse, *MUICancel; Object *page1,*page2; Object *MUITFreq,*MUITChannels,*MUITOutvol,*MUITMonvol,*MUITGain,*MUITInput,*MUITOutput,*MUITDebug,*MUITEcho,*MUITSurround,*MUITClipvol,*MUITCpu,*MUITACTime,*MUITScalemode; UpdateStrings(); MUIMasterBase = (void *)OpenLibrary("muimaster.library", MUIMASTER_VLATEST); if(MUIMasterBase == NULL) { Printf((char *) msgTextNoOpen, (ULONG) "muimaster.library", MUIMASTER_VLATEST); Printf("\n"); return FALSE; } page1 = HGroup, Child, VGroup, Child, MUIUnit = CycleObject, MUIA_CycleChain, 1, MUIA_Cycle_Entries, Units, MUIA_Cycle_Active, state.UnitSelected, End, Child, ListviewObject, MUIA_CycleChain, 1, MUIA_Listview_List, MUIList = ListObject, InputListFrame, MUIA_List_AutoVisible, TRUE, End, End, Child, HGroup, ReadListFrame, MUIA_Background, MUII_TextBack, Child, TextObject, MUIA_Text_Contents, msgProperties, MUIA_Text_SetMax, TRUE, End, Child, MUIInfos = TextObject, MUIA_Text_Contents, "\n\n\n\n\n\n", MUIA_Text_SetMin, FALSE, End, End, End, Child, BalanceObject, End, Child, VGroup, Child, HVSpace, Child, ColGroup(3), GroupFrameT(msgOptions), Child, MUITFreq = SpecialButton((STRPTR)msgOptFrequency), Child, MUIFreq = SpecialSlider(0,max(state.Frequencies-1,0),state.FreqSelected), Child, MUILFreq = SpecialLabel(getFreq()), Child, MUITChannels = SpecialButton((STRPTR)msgOptChannels), Child, MUIChannels = SpecialSlider(1,state.Channels,state.ChannelsSelected), Child, MUILChannels = SpecialLabel(getChannels()), Child, MUITOutvol = SpecialButton((STRPTR)msgOptVolume), Child, MUIOutvol = SpecialSlider(0,max(state.OutVols-1,0),state.OutVolSelected), Child, MUILOutvol = SpecialLabel(getOutVol()), Child, MUITMonvol = SpecialButton((STRPTR)msgOptMonitor), Child, MUIMonvol = SpecialSlider(0,max(state.MonVols-1,1),state.MonVolSelected), Child, MUILMonvol = SpecialLabel(getMonVol()), Child, MUITGain = SpecialButton((STRPTR)msgOptGain), Child, MUIGain = SpecialSlider(0,max(state.Gains-1,0),state.GainSelected), Child, MUILGain = SpecialLabel(getGain()), Child, MUITInput = SpecialButton((STRPTR)msgOptInput), Child, MUIInput = SpecialSlider(0,max(state.Inputs-1,0),state.InputSelected), Child, MUILInput = SpecialLabel(getInput()), Child, MUITOutput = SpecialButton((STRPTR)msgOptOutput), Child, MUIOutput = SpecialSlider(0,max(state.Outputs-1,0),state.OutputSelected), Child, MUILOutput = SpecialLabel(getOutput()), End, Child, MUIPlay = SimpleButton(msgButtonPlay), Child, HVSpace, End, End; page2 = VGroup, Child, HVSpace, Child, HGroup, Child, HVSpace, Child, ColGroup(2), GroupFrameT(msgGlobalOptions), Child, MUITDebug = SpecialButton((STRPTR)msgGlobOptDebugLevel), Child, MUIDebug = CycleObject, MUIA_CycleChain, 1, MUIA_Cycle_Entries, DebugLabels, MUIA_Cycle_Active, globalprefs.ahigp_DebugLevel, End, Child, MUITEcho = SpecialButton((STRPTR)msgGlobOptEcho), Child, MUIEcho = CycleObject, MUIA_CycleChain, 1, MUIA_Cycle_Entries, EchoLabels, MUIA_Cycle_Active, (globalprefs.ahigp_DisableEcho ? 2 : 0) | (globalprefs.ahigp_FastEcho ? 1 : 0), MUIA_Disabled, AHIBase->lib_Version >= 5, End, Child, MUITSurround = SpecialButton((STRPTR)msgGlobOptSurround), Child, MUISurround = CycleObject, MUIA_CycleChain, 1, MUIA_Cycle_Entries, SurroundLabels, MUIA_Cycle_Active, globalprefs.ahigp_DisableSurround, MUIA_Disabled, AHIBase->lib_Version >= 5, End, Child, MUITClipvol = SpecialButton((STRPTR)msgGlobOptMasterVol), Child, MUIClipvol = CycleObject, MUIA_CycleChain, 1, MUIA_Cycle_Entries, ClipMVLabels, MUIA_Cycle_Active, globalprefs.ahigp_ClipMasterVolume, MUIA_Disabled, AHIBase->lib_Version >= 5, End, Child, MUITCpu = SpecialButton((STRPTR)msgGlobOptCPULimit), Child, MUICpu = SliderObject, MUIA_CycleChain, 1, MUIA_Slider_Horiz, TRUE, MUIA_Numeric_Min, 0, MUIA_Numeric_Max, 100, MUIA_Numeric_Value,(globalprefs.ahigp_MaxCPU * 100 + 32768) / 65536, MUIA_Numeric_Format,"%ld%%", End, Child, MUITACTime = SpecialButton((STRPTR)msgGlobOptACTime), Child, MUIACTime = SliderObject, MUIA_CycleChain, 1, MUIA_Slider_Horiz, TRUE, MUIA_Numeric_Min, 0, MUIA_Numeric_Max, 100, MUIA_Numeric_Value,(globalprefs.ahigp_AntiClickTime * 1000 + 32768) >> 16, MUIA_Numeric_Format,"%ld ms", MUIA_Disabled, AHIBase->lib_Version <= 4, End, Child, MUITScalemode = SpecialButton((STRPTR)msgOptScalemode), Child, MUIScalemode = CycleObject, MUIA_CycleChain, 1, MUIA_Cycle_Entries, ScaleLabels, MUIA_Cycle_Active, globalprefs.ahigp_ScaleMode, MUIA_Disabled, AHIBase->lib_Version <= 4, End, End, Child, HVSpace, End, Child, HVSpace, End; MUIApp = ApplicationObject, MUIA_Application_Title, (char *) msgTextProgramName, MUIA_Application_Version, Version, MUIA_Application_Copyright, "©1996-2004 Martin Blom", MUIA_Application_Author, "Stéphane Barbaray/Martin Blom", MUIA_Application_Base, "AHI", MUIA_Application_HelpFile, HELPFILE, MUIA_Application_Menustrip, MUIMenu = MUI_MakeObject(MUIO_MenustripNM,Menus,0), MUIA_Application_SingleTask, TRUE, SubWindow, MUIWindow = WindowObject, MUIA_Window_Title, (char *) msgTextProgramName, MUIA_Window_ID , MAKE_ID('M','A','I','N'), MUIA_HelpNode, "AHI", WindowContents, VGroup, Child, RegisterGroup(PageNames), MUIA_CycleChain, 1, Child, page1, Child, page2, End, Child, HGroup, Child, MUISave = SimpleButton(msgButtonSave), Child, MUIUse = SimpleButton(msgButtonUse), Child, MUICancel = SimpleButton(msgButtonCancel), End, End, End, End; if( MUIApp != NULL ) { APTR item = (APTR)DoMethod(MUIMenu,MUIM_FindUData,ACTID_ICONS); if(item) { set(item, MUIA_Menuitem_Checked, SaveIcons); } DoMethod(MUIWindow, MUIM_MultiSet, MUIA_Text_PreParse,"\033l",MUILFreq,MUILChannels,MUILOutvol,MUILMonvol,MUILGain,MUILInput,MUILOutput,NULL); DoMethod(MUIWindow, MUIM_MultiSet, MUIA_CycleChain, 1, MUISave,MUIUse,MUICancel,NULL); DoMethod(MUITFreq, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIFreq); DoMethod(MUITChannels, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIChannels); DoMethod(MUITOutvol, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIOutvol); DoMethod(MUITMonvol, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIMonvol); DoMethod(MUITGain, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIGain); DoMethod(MUITInput, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIInput); DoMethod(MUITOutput, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIOutput); DoMethod(MUIPlay, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, ACTID_PLAY); DoMethod(MUITDebug, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIDebug); DoMethod(MUITEcho, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIEcho); DoMethod(MUITSurround, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUISurround); DoMethod(MUITClipvol, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIClipvol); DoMethod(MUITCpu, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUICpu); DoMethod(MUITACTime, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIACTime); DoMethod(MUITScalemode, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIScalemode); DoMethod(MUIWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIApp, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); DoMethod(MUISave, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, ACTID_SAVE); DoMethod(MUIUse, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, ACTID_USE); DoMethod(MUICancel, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); DoMethod(MUIUnit, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_UNIT); DoMethod(MUIList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_MODE); DoMethod(MUIDebug, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_DEBUG); DoMethod(MUISurround, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_SURROUND); DoMethod(MUIEcho, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_ECHO); DoMethod(MUICpu, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_CPULIMIT); DoMethod(MUIClipvol, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_CLIPMV); DoMethod(MUIACTime, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_ACTIME); DoMethod(MUIScalemode, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_SCALEMODE); DoMethod(MUIFreq, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue); DoMethod(MUIChannels, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue); DoMethod(MUIOutvol, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue); DoMethod(MUIMonvol, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue); DoMethod(MUIGain, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue); DoMethod(MUIInput, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue); DoMethod(MUIOutput, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue); set(MUIWindow, MUIA_Window_Open, TRUE); GUINewUnit(); return TRUE; } return FALSE; }
static void GUINewMode(void) { int Max, Sel, Dis; char* buffer; char* arg1 = getRecord(); char* arg2 = getAuthor(); char* arg3 = getCopyright(); char* arg4 = getDriver(); char* arg5 = getVersion(); char* arg6 = getAnnotation(); buffer = AllocVec( strlen( arg1 ) + strlen( arg2 ) + strlen( arg3 ) + strlen( arg4 ) + strlen( arg5 ) + strlen( arg6 ) + 128, MEMF_ANY); if( buffer != NULL ) { sprintf( buffer,"0x%08lx\n%s\n%s\n%s\nDevs:AHI/%s.audio\n%s\n%s", getAudioMode(), arg1, arg2, arg3, arg4, arg5, arg6 ); set(MUIInfos, MUIA_Text_Contents, (ULONG) buffer); FreeVec(buffer); } Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); Dis = Max==0; set(MUIFreq, MUIA_Disabled, Dis); if( !Dis ) { set(MUIFreq, MUIA_Numeric_Max, Max); set(MUIFreq, MUIA_Numeric_Value, Sel); } set(MUILFreq, MUIA_Text_Contents, (ULONG) getFreq()); Max = max(state.Channels, 0); Sel = min(Max, state.ChannelsSelected); Dis = (Max == 0 || Max == 1) || state.ChannelsDisabled; set(MUIChannels, MUIA_Disabled, Dis); if( !Dis ) { set(MUIChannels, MUIA_Numeric_Max, Max); set(MUIChannels, MUIA_Numeric_Value, Sel); } set(MUILChannels, MUIA_Text_Contents, (ULONG) getChannels()); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); Dis = Max==0; set(MUIOutvol, MUIA_Disabled, Dis); if( !Dis ) { set(MUIOutvol, MUIA_Numeric_Max, Max); set(MUIOutvol, MUIA_Numeric_Value, Sel); } set(MUILOutvol, MUIA_Text_Contents, (ULONG) getOutVol()); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); Dis = Max==0; set(MUIMonvol, MUIA_Disabled, Dis); if( !Dis ) { set(MUIMonvol, MUIA_Numeric_Max, Max); set(MUIMonvol, MUIA_Numeric_Value, Sel); } set(MUILMonvol, MUIA_Text_Contents, (ULONG) getMonVol()); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); Dis = Max==0; set(MUIGain, MUIA_Disabled, Dis); if( !Dis ) { set(MUIGain, MUIA_Numeric_Max, Max); set(MUIGain, MUIA_Numeric_Value, Sel); } set(MUILGain, MUIA_Text_Contents, (ULONG) getGain()); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); Dis = Max==0; set(MUIInput, MUIA_Disabled, Dis); if( !Dis ) { set(MUIInput, MUIA_Numeric_Max, Max); set(MUIInput, MUIA_Numeric_Value, Sel); } set(MUILInput, MUIA_Text_Contents, (ULONG) getInput()); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); Dis = Max==0; set(MUIOutput, MUIA_Disabled, Dis); if( !Dis ) { set(MUIOutput, MUIA_Numeric_Max, Max); set(MUIOutput, MUIA_Numeric_Value, Sel); } set(MUILOutput, MUIA_Text_Contents, (ULONG) getOutput()); set(MUIPlay, MUIA_Disabled, getAudioMode() == AHI_INVALID_ID); }
//------------------------------------------------------------------------------ // rfTransmit() -- Transmit a RF emission packet at all active players. //------------------------------------------------------------------------------ void Antenna::rfTransmit(Emission* const xmit) { // Need something to transmit and someone to send to Tdb* tdb = getCurrentTDB(); Player* ownship = getOwnship(); if (xmit == 0 || tdb == 0 || ownship == 0) { // Clean up and leave if (tdb != 0) tdb->unref(); return; } // --- // Compute gimbal boresight data for our targets // --- unsigned int ntgts = tdb->computeBoresightData(); if (ntgts > MAX_PLAYERS) ntgts = MAX_PLAYERS; // --- // If we have targets // --- const osg::Vec3d* losG = tdb->getGimbalLosVectors(); if (ntgts > 0 && losG != 0) { // --- // Lookup gain from antenna gain pattern, compute antenna // effective gain and effective radiated power. // --- bool haveGainTgt = false; double gainTgt[MAX_PLAYERS]; if (gainPattern != 0) { Basic::Func1* gainFunc1 = dynamic_cast<Basic::Func1*>(gainPattern); Basic::Func2* gainFunc2 = dynamic_cast<Basic::Func2*>(gainPattern); if (gainFunc2 != 0) { // --- // Antenna pattern: 2D table (az & el off antenna boresight) // --- // Compute azimuth off boresight (radians) const double* aazr = tdb->getBoresightAzimuthErrors(); // Compute elevation off boresight (radians) const double* aelr = tdb->getBoresightElevationErrors(); // Lookup gain in 2D table and convert from dB double gainTgt0[MAX_PLAYERS]; if (gainPatternDeg) { for (unsigned int i1 = 0; i1 < ntgts; i1++) { gainTgt0[i1] = gainFunc2->f( (aazr[i1] * Basic::Angle::R2DCC), (aelr[i1] * Basic::Angle::R2DCC) )/10.0; } } else { for (unsigned int i1 = 0; i1 < ntgts; i1++) { gainTgt0[i1] = gainFunc2->f( aazr[i1], aelr[i1] )/10.0f; } } pow10Array(gainTgt0, gainTgt, ntgts); haveGainTgt = true; } else if (gainFunc1 != 0) { // --- // Antenna Pattern: 1D table (off antenna boresight only // --- // Compute angles off antenna boresight (radians) const double* aar = tdb->getBoresightErrorAngles(); // Lookup gain in 1D table and convert from dB double gainTgt0[MAX_PLAYERS]; if (gainPatternDeg) { for (unsigned int i2 = 0; i2 < ntgts; i2++) { gainTgt0[i2] = gainFunc1->f( aar[i2]*Basic::Angle::R2DCC )/10.0; } } else { for (unsigned int i2 = 0; i2 < ntgts; i2++) { gainTgt0[i2] = gainFunc1->f( aar[i2] )/10.0f; } } pow10Array(gainTgt0, gainTgt, ntgts); haveGainTgt = true; } } if (!haveGainTgt) { // --- // No antenna pattern table // --- for (unsigned int i = 0; i < ntgts; i++) { gainTgt[i] = 1.0f; } } // Compute antenna effective gain double aeGain[MAX_PLAYERS]; multArrayConst(gainTgt, getGain(), aeGain, ntgts); // Compute Effective Radiated Power (watts) (Equation 2-1) double erp[MAX_PLAYERS]; multArrayConst(aeGain, xmit->getPower(), erp, ntgts); // Fetch the required data arrays from the TargetDataBlock const double* ranges = tdb->getTargetRanges(); const double* rngRates = tdb->getTargetRangeRates(); const osg::Vec3d* losO2T = tdb->getLosVectors(); const osg::Vec3d* losT2O = tdb->getTargetLosVectors(); Player** targets = tdb->getTargets(); // --- // Send emission packets to the targets // --- for (unsigned int i = 0; i < ntgts; i++) { // Only of power exceeds an optional threshold if (erp[i] > threshold) { // Get a free emission packet Emission* em(0); if (recycle) { lcLock(freeEmLock); em = freeEmStack.pop(); lcUnlock(freeEmLock); } bool cloned = false; if (em == 0) { // Otherwise, clone a new one em = xmit->clone(); cloned = true; } // Send the emission to the other player if (em != 0) { // a) Copy the template emission if (!cloned) *em = *xmit; // b) Set target unique data em->setGimbal(this); em->setOwnship(ownship); em->setRange( LCreal(ranges[i]) ); em->setLosVec(losO2T[i]); em->setTgtLosVec(losT2O[i]); em->setRangeRate( LCreal(rngRates[i]) ); em->setTarget(targets[i]); em->setGimbalAzimuth( LCreal(getAzimuth()) ); em->setGimbalElevation( LCreal(getElevation()) ); em->setPower( LCreal(erp[i]) ); em->setGain( LCreal(aeGain[i]) ); em->setPolarization(getPolarization()); em->setLocalPlayersOnly( isLocalPlayersOfInterestOnly() ); // c) Send the emission to the target targets[i]->event(RF_EMISSION, em); // d) Recycle the emission bool recycled = false; if (recycle) { lcLock(inUseEmLock); if (inUseEmQueue.isNotFull()) { // Store for future reference inUseEmQueue.put(em); recycled = true; } lcUnlock(inUseEmLock); } // or just forget it else { em->unref(); } } else { // When we couldn't get a free emission packet if (isMessageEnabled(MSG_ERROR)) { std::cerr << "Antenna: OUT OF EMISSIONS!" << std::endl; } } } } } // Unref() the TDB tdb->unref(); }
Gain(const AttribueContainer& value, const ResultContainer& result, ConditionnalFunctor& func) : attribue_per_result_(), attribue_value_total_(), result_value_yes_(), entropy_(0), log_2_(std::log(2.f)), size_total_(0) { getGain(value, result, func); }
BOOL BuildGUI(char *screenname) { Object **ar = Window_Objs; struct Screen *screen; BOOL OptionFrame = FALSE; LONG indicatorwidth = 100; UpdateStrings(); // Kludge for Piccaso 96/BGUI. if(FindTask("Picasso96")) { PopUpMenus = FALSE; } BGUIBase = (void *)OpenLibrary("bgui.library", 41); if(BGUIBase == NULL) { Printf((char *) msgTextNoOpen, (ULONG) "bgui.library", 41); Printf("\n"); return FALSE; } screen = LockPubScreen(screenname); indicatorwidth = max(indicatorwidth, 16 * screen->RastPort.Font->tf_XSize); if(screen->Height > 240) { OptionFrame = TRUE; } WO_Window = WindowObject, WINDOW_PubScreen, screen, WINDOW_Title, (char *) msgTextProgramName, WINDOW_CloseGadget, FALSE, WINDOW_MenuStrip, Menus, WINDOW_AutoAspect, TRUE, WINDOW_AutoKeyLabel, TRUE, WINDOW_ScaleWidth, 60, WINDOW_ScaleHeight, 20, WINDOW_HelpFile, HELPFILE, WINDOW_HelpNode, "AHI", WINDOW_IDCMPHook, &IDCMPhook, WINDOW_IDCMPHookBits, IDCMP_RAWKEY, WINDOW_MasterGroup, VGroupObject, NormalOffset, /* TABS */ StartMember, ar[ACTID_TABS] = MxObject, MX_Labels, PageNames, MX_TabsObject, TRUE, GA_ID, ACTID_TABS, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_PAGE] = PageObject, NormalSpacing, PAGE_NoBufferRP, TRUE, /* PAGE 1 */ PageMember, HGroupObject, NormalOffset, NormalSpacing, TabAboveFrame, StartMember, vgroup = VGroupObject, NormalSpacing, StartMember, ar[ACTID_UNIT] = CycleObject, CYC_Labels, Units, CYC_Active, state.UnitSelected, CYC_PopActive, PopUpMenus, CYC_Popup, PopUpMenus, GA_ID, ACTID_UNIT, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_MODE] = ListviewObject, // LISTV_EntryArray, Modes, // LISTV_Select, state.ModeSelected, PGA_NewLook, TRUE, GA_ID, ACTID_MODE, EndObject, EndMember, StartMember, HGroupObject, ButtonFrame, FRM_Flags, FRF_RECESSED, StartMember, InfoObject, INFO_TextFormat, (char *) msgProperties, INFO_FixTextWidth,TRUE, INFO_MinLines, 6, EndObject, FixMinWidth, EndMember, StartMember, ar[SHOWID_MODE] = InfoObject, INFO_MinLines, 6, EndObject, EndMember, EndObject, FixMinHeight, EndMember, EndObject /* vgroup */, EndMember, StartMember, VGroupObject, NormalSpacing, VarSpace(1), StartMember, VGroupObject, (OptionFrame ? GROUP_HorizOffset : TAG_IGNORE), GRSPACE_NORMAL, (OptionFrame ? GROUP_VertOffset : TAG_IGNORE), GRSPACE_NORMAL, (OptionFrame ? GROUP_Spacing : TAG_IGNORE), GRSPACE_NORMAL, (OptionFrame ? FRM_Type : TAG_IGNORE), FRTYPE_RIDGE, (OptionFrame ? FRM_Flags : TAG_IGNORE), FRF_RECESSED, (OptionFrame ? FRM_Title : TAG_IGNORE), (char *) msgOptions, StartMember, HGroupObject, StartMember, ar[ACTID_FREQ] = SliderObject, LAB_Label, (char *) msgOptFrequency, SLIDER_Min, 0, SLIDER_Max, state.Frequencies -1 , SLIDER_Level, state.FreqSelected, PGA_NewLook, TRUE, GA_ID, ACTID_FREQ, EndObject, EndMember, StartMember, ar[SHOWID_FREQ] = InfoObject, INFO_TextFormat, getFreq(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_CHANNELS] = SliderObject, LAB_Label, (char *) msgOptChannels, SLIDER_Min, 1, SLIDER_Max, state.Channels, SLIDER_Level, state.ChannelsSelected, PGA_NewLook, TRUE, GA_ID, ACTID_CHANNELS, EndObject, EndMember, StartMember, ar[SHOWID_CHANNELS] = InfoObject, INFO_TextFormat, getChannels(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_OUTVOL] = SliderObject, LAB_Label, (char *) msgOptVolume, SLIDER_Min, 0, SLIDER_Max, state.OutVols-1 , SLIDER_Level, state.OutVolSelected, PGA_NewLook, TRUE, GA_ID, ACTID_OUTVOL, EndObject, EndMember, StartMember, ar[SHOWID_OUTVOL] = InfoObject, INFO_TextFormat, getOutVol(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_MONVOL] = SliderObject, LAB_Label, (char *) msgOptMonitor, SLIDER_Min, 0, SLIDER_Max, state.MonVols-1 , SLIDER_Level, state.MonVolSelected, PGA_NewLook, TRUE, GA_ID, ACTID_MONVOL, EndObject, EndMember, StartMember, ar[SHOWID_MONVOL] = InfoObject, INFO_TextFormat, getMonVol(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_GAIN] = SliderObject, LAB_Label, (char *) msgOptGain, SLIDER_Min, 0, SLIDER_Max, state.Gains-1 , SLIDER_Level, state.GainSelected, PGA_NewLook, TRUE, GA_ID, ACTID_GAIN, EndObject, EndMember, StartMember, ar[SHOWID_GAIN] = InfoObject, INFO_TextFormat, getGain(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_INPUT] = SliderObject, LAB_Label, (char *) msgOptInput, SLIDER_Min, 0, SLIDER_Max, state.Inputs-1 , SLIDER_Level, state.InputSelected, PGA_NewLook, TRUE, GA_ID, ACTID_INPUT, EndObject, EndMember, StartMember, ar[SHOWID_INPUT] = InfoObject, INFO_TextFormat, getInput(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_OUTPUT] = SliderObject, LAB_Label, (char *) msgOptOutput, SLIDER_Min, 0, SLIDER_Max, state.Outputs-1 , SLIDER_Level, state.OutputSelected, PGA_NewLook, TRUE, GA_ID, ACTID_OUTPUT, EndObject, EndMember, StartMember, ar[SHOWID_OUTPUT] = InfoObject, INFO_TextFormat, getOutput(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, EndObject /* vgroup "Options" */, FixMinHeight, EndMember, VarSpace(1), EndObject /* vgroup */, EndMember, EndObject, /* (EndMember) page */ /* PAGE 2 */ PageMember, HGroupObject, NormalSpacing, TabAboveFrame, VarSpace(1), StartMember, VGroupObject, NormalSpacing, VarSpace(1), StartMember, VGroupObject, NormalOffset, NormalSpacing, RidgeFrame, FRM_Flags, FRF_RECESSED, FrameTitle((char *) msgGlobalOptions), StartMember, HGroupObject, NormalSpacing, StartMember, VGroupObject, NormalSpacing, StartMember, ar[ACTID_DEBUG] = CycleObject, LAB_Label, (char *) msgGlobOptDebugLevel, LAB_Place, PLACE_LEFT, CYC_Labels, DebugLabels, CYC_Active, globalprefs.ahigp_DebugLevel, CYC_PopActive, PopUpMenus, CYC_Popup, PopUpMenus, GA_ID, ACTID_DEBUG, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_ECHO] = CycleObject, LAB_Label, (char *) msgGlobOptEcho, LAB_Place, PLACE_LEFT, CYC_Labels, EchoLabels, CYC_Active, (globalprefs.ahigp_DisableEcho ? 2 : 0) | (globalprefs.ahigp_FastEcho ? 1 : 0), CYC_PopActive, PopUpMenus, CYC_Popup, PopUpMenus, GA_ID, ACTID_ECHO, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_SURROUND] = CycleObject, LAB_Label, (char *) msgGlobOptSurround, LAB_Place, PLACE_LEFT, CYC_Labels, SurroundLabels, CYC_Active, globalprefs.ahigp_DisableSurround, GA_ID, ACTID_SURROUND, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_CLIPMV] = CycleObject, LAB_Label, (char *) msgGlobOptMasterVol, LAB_Place, PLACE_LEFT, CYC_Labels, ClipMVLabels, CYC_Active, globalprefs.ahigp_ClipMasterVolume, GA_ID, ACTID_CLIPMV, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_CPULIMIT] = SliderObject, LAB_Label, (char *) msgGlobOptCPULimit, SLIDER_Min, 0, SLIDER_Max, 100, SLIDER_Level, (globalprefs.ahigp_MaxCPU * 100 + 32768) >> 16, PGA_NewLook, TRUE, GA_ID, ACTID_CPULIMIT, EndObject, EndMember, EndObject /* vgroup */, EndMember, StartMember, VGroupObject, NormalSpacing, VarSpace(1), StartMember, ar[SHOWID_CPULIMIT] = IndicatorObject,\ INDIC_Min, 0, INDIC_Max, 100, INDIC_Level, (globalprefs.ahigp_MaxCPU * 100 + 32768) / 65536, INDIC_Justification, IDJ_LEFT, INDIC_FormatString, "%ld%%", EndObject, FixMinWidth, FixMinHeight, EndMember, EndObject /* vgroup */, EndMember, EndObject /* hgroup */, EndMember, EndObject, FixMinWidth, FixMinHeight, EndMember, VarSpace(1), EndObject /* vgroup */ , FixMinWidth, EndMember, VarSpace(1), EndObject, /* (EndMember) page */ EndObject /* page */, EndMember, /* BUTTONS */ StartMember, HGroupObject, NormalSpacing, NormalVOffset, StartMember, ar[ACTID_SAVE] = ButtonObject, ButtonFrame, LAB_Label, (char *) msgButtonSave, GA_ID, ACTID_SAVE, EndObject, EndMember, StartMember, ar[ACTID_USE] = ButtonObject, ButtonFrame, LAB_Label, (char *) msgButtonUse, GA_ID, ACTID_USE, EndObject, EndMember, StartMember, ar[ACTID_QUIT] = ButtonObject, ButtonFrame, LAB_Label, (char *) msgButtonCancel, GA_ID, ACTID_QUIT, EndObject, EndMember, EndObject, FixMinHeight, EndMember, EndObject, EndObject; if(WO_Window) { AddMap( ar[ACTID_TABS], ar[ACTID_PAGE], pagemap ); DoMethod( ar[ACTID_FREQ], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_CHANNELS], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_OUTVOL], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_MONVOL], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_GAIN], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_INPUT], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_OUTPUT], BASE_ADDHOOK, &GadgetHook ); AddMap( ar[ACTID_CPULIMIT], ar[SHOWID_CPULIMIT], cpumap); window = WindowOpen(WO_Window); } if(screen) { UnlockPubScreen(NULL, screen); } if(window == NULL) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } openreq = FileReqObject, ASLFR_Window, window, ASLFR_SleepWindow, TRUE, ASLFR_RejectIcons, TRUE, ASLFR_InitialDrawer, "SYS:Prefs/Presets", EndObject; savereq = FileReqObject, ASLFR_Window, window, ASLFR_SleepWindow, TRUE, ASLFR_RejectIcons, TRUE, ASLFR_InitialDrawer, "SYS:Prefs/Presets", ASLFR_DoSaveMode, TRUE, EndObject; if((openreq == NULL) || (savereq == NULL)) { Printf((char *) msgTextNoFileRequester); Printf("\n"); return FALSE; } // Update the checkmark for "Create Icons?" { struct Menu *menu = NULL; struct MenuItem *item; GetAttr( WINDOW_MenuStrip, WO_Window, (ULONG *) &menu); ClearMenuStrip(window); item = FindMenuItem(ACTID_ICONS); if(item) { if(SaveIcons) item->Flags |= CHECKED; else item->Flags &= ~CHECKED; } ResetMenuStrip(window, menu); } GUINewUnit(); return TRUE; }
float operator()(const AttribueContainer& value, const ResultContainer& result) { return getGain(value, result); }
bool HMC5883L::calibrate(int8_t testGain) { // Keep the current status ... uint8_t previousGain = getGain(); // Set the gain if (testGain < 0) { testGain = gain; } setGain(testGain); // To check the HMC5883L for proper operation, a self test // feature in incorporated in which the sensor offset straps // are excited to create a nominal field strength (bias field) // to be measured. To implement self test, the least significant // bits (MS1 and MS0) of configuration register A are changed // from 00 to 01 (positive bias) or 10 (negetive bias) setMeasurementBias(HMC5883L_BIAS_POSITIVE); // Then, by placing the mode register into single-measurement mode ... setMode(HMC5883L_MODE_SINGLE); // Two data acquisition cycles will be made on each magnetic vector. // The first acquisition will be a set pulse followed shortly by // measurement data of the external field. The second acquisition // will have the offset strap excited (about 10 mA) in the positive // bias mode for X, Y, and Z axes to create about a ±1.1 gauss self // test field plus the external field. // The first acquisition values will be subtracted from the // second acquisition, and the net measurement will be placed into // the data output registers. int16_t x,y,z; getRawHeading(&x,&y,&z); // In the event the ADC reading overflows or underflows for the // given channel, or if there is a math overflow during the bias // measurement, this data register will contain the value -4096. // This register value will clear when after the next valid // measurement is made. if (min(x,min(y,z)) == -4096) { scaleFactors[testGain][0] = 1.0f; scaleFactors[testGain][1] = 1.0f; scaleFactors[testGain][2] = 1.0f; return false; } getRawHeading(&x,&y,&z); if (min(x,min(y,z)) == -4096) { scaleFactors[testGain][0] = 1.0f; scaleFactors[testGain][1] = 1.0f; scaleFactors[testGain][2] = 1.0f; return false; } // Since placing device in positive bias mode // (or alternatively negative bias mode) applies // a known artificial field on all three axes, // the resulting ADC measurements in data output // registers can be used to scale the sensors. float xExpectedSelfTestValue = HMC5883L_SELF_TEST_X_AXIS_ABSOLUTE_GAUSS * HMC5883L_LSB_PER_GAUS[testGain]; float yExpectedSelfTestValue = HMC5883L_SELF_TEST_Y_AXIS_ABSOLUTE_GAUSS * HMC5883L_LSB_PER_GAUS[testGain]; float zExpectedSelfTestValue = HMC5883L_SELF_TEST_Z_AXIS_ABSOLUTE_GAUSS * HMC5883L_LSB_PER_GAUS[testGain]; scaleFactors[testGain][0] = xExpectedSelfTestValue/x; scaleFactors[testGain][1] = yExpectedSelfTestValue/y; scaleFactors[testGain][2] = zExpectedSelfTestValue/z; setGain(previousGain); setMeasurementBias(HMC5883L_BIAS_NORMAL); return true; }