BOOL LoginDialog::onInitDialog()
{
  setControlById(m_server, IDC_CSERVER);
  setControlById(m_listening, IDC_LISTENING);
  setControlById(m_ok, IDOK);
  updateHistory();
  SetForegroundWindow(getControl()->getWindow());
  m_server.setFocus();
  if (m_isListening) {
    m_listening.setEnabled(false);
  }
  return TRUE;
}
Beispiel #2
0
void LLControlGroup::setLLSD(const std::string& name, const LLSD& val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_LLSD))
	{
		setValue(name, val);
	}
	else
	{
		CONTROL_ERRS << "Invalid LLSD control " << name << llendl;
	}
}
Beispiel #3
0
void LLControlGroup::setColor4(const std::string& name, const LLColor4 &val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_COL4))
	{
		control->set(val.getValue());
	}
	else
	{
		CONTROL_ERRS << "Invalid LLColor4 control " << name << llendl;
	}
}
void LLControlGroup::setS32(const std::string& name, S32 val)
{
    LLControlVariable* control = getControl(name);

    if (control && control->isType(TYPE_S32))
    {
        control->set(val);
    }
    else
    {
        CONTROL_ERRS << "Invalid control " << name << llendl;
    }
}
int ofxGuiContainer::getControlIndex(ofxGuiElement* element) {

    for(int i = 0; i < (int)getControls().size(); i++) {
        ofxGuiElement *e = getControl(i);
        if(e) {
            if(e == element) {
                return i;
            }
        }
    }
    return -1;

}
Beispiel #6
0
void QtBaseWidget::resizeEvent(QResizeEvent* ev) {
	if(handleResize) return; // avoid infinite recursion
	handleResize = true;
	
	QWidget::resizeEvent(ev);
	
	PyScopedGIL gil;
	PyQtGuiObject* control = getControl();
	if(control) control->layout();
	Py_XDECREF(control);
	
	handleResize = false;
}
Beispiel #7
0
Controller::Button	Controller::Peripheral::retJoyBut()
{
  register SDL_GameController *getJoy = getControl();

  if (!getJoy)
    return (retJoyButton());
  for (register int i = static_cast<int>(BUTTON_MAX); i >= 0 ; i--)
    {
      if (SDL_GameControllerGetButton(getJoy, static_cast<SDL_GameControllerButton>(i)))
	return (static_cast<Controller::Button>(getValToBut
						(static_cast<Controller::Button>(i))));
    }
  return (BUTTON_INVALID);
}
Beispiel #8
0
void turnOff() {
	DBG("Turn Off\n");

	Control* control = getControl();
	control->mode = MODE_OFF;
	lockSteps();
	for (int csIndex = 0; csIndex < getControlStepCount() && csIndex < MAX_STEP_COUNT; csIndex++) {
		ControlStep * cs = getControlStep(csIndex);
		for (int cpIndex = 0; cpIndex < cs->controlPointCount && cpIndex < MAX_CP_COUNT; cpIndex++) {
			//cs->controlPoints[cpIndex].duty = 0;
			setHeatOn(&cs->controlPoints[cpIndex].dutyController, false);
		}
	}
	unlockSteps();
}
Beispiel #9
0
void LLControlGroup::setBOOL(const std::string& name, BOOL val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_BOOLEAN))
	{
		control->set(val);
		if(mChangeCallback)
			mChangeCallback(name,(val) ? "1" : "0");
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
Beispiel #10
0
void LLControlGroup::setString(const std::string& name, const std::string &val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_STRING))
	{
		control->set(val);
		if(mChangeCallback)
			mChangeCallback(name,val);
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
Beispiel #11
0
void QtBaseWidget::updateContent() {	
	PyScopedGIL gil;
	
	PyObject* control = (PyObject*) getControl();
	if(!control) return;
	
	PyObject* s = PyString_FromString("updateContent");
	PyObject* func = s ? PyObject_GenericGetAttr(control, s) : NULL;
	PyObject* res = func ? PyObject_CallFunction(func, NULL) : NULL;
	if(!res && PyErr_Occurred()) PyErr_Print();
	Py_XDECREF(s);
	Py_XDECREF(func);
	Py_XDECREF(res);
	Py_DECREF(control);
}
Beispiel #12
0
void LLControlGroup::setRect(const std::string& name, const LLRect &val)
{
	LLControlVariable* control = getControl(name);

	if (control && control->isType(TYPE_RECT))
	{
		control->set(val.getValue());
		if(mChangeCallback)
			mChangeCallback(name,llformat("[%f,%f,%f,%f]",val.mBottom,val.mLeft,val.mRight,val.mTop));
	}
	else
	{
		CONTROL_ERRS << "Invalid rect control " << name << llendl;
	}
}
Beispiel #13
0
shared_ptr<HtmlAttribute> HtmlAttributes::set(const String &name, const String &value)
{
	shared_ptr<HtmlAttribute> attribute = get(name);
	if(attribute != nullptr)
	{
		attribute->setValue(value);
	}
	else
	{
		attribute.reset(OS_NEW HtmlAttribute(getControl(), name, value));
		m_attributes.push_back(attribute);
	}

	return attribute;
}
Beispiel #14
0
void LLControlGroup::setU32(const std::string& name, U32 val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_U32))
	{
		control->set((LLSD::Integer) val);
		if(mChangeCallback)
			mChangeCallback(name,llformat("%d",val));
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
Beispiel #15
0
void LLControlGroup::setColor4(const std::string& name, const LLColor4 &val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_COL4))
	{
		control->set(val.getValue());
		if(mChangeCallback)
			mChangeCallback(name,llformat("<%f,%f,%f,%f>",val.mV[VX],val.mV[VY],val.mV[VZ],val.mV[VW]));
	}
	else
	{
		CONTROL_ERRS << "Invalid LLColor4 control " << name << llendl;
	}
}
Beispiel #16
0
void Simulator::mainLoop (void) {
    // TODO: change duration so it limits to 100 updates a second, but allows
    // for slower times if the client really has to think about things.
    std::cout << "Mainloop running" << std::endl;
    while (running) {
        sendSensors();
        nextControl = getControl();
        entities->rocket->applyControl(nextControl);
        stepSimulation(1./100);

        // Rate limit the simulation
        std::chrono::milliseconds dura(10);
        std::this_thread::sleep_for(dura);
    }
    std::cout << "Mainloop not running" << std::endl;
}
Beispiel #17
0
void QtActionWidget::onClick() {
	PyScopedGIL gil;
	PyQtGuiObject* control = getControl();
	if(!control) return;

	control->updateSubjectObject();
	if(control->subjectObject) {
		PyObject* ret = PyObject_CallFunction(control->subjectObject, NULL);
		if(!ret) {
			if(PyErr_Occurred()) PyErr_Print();			
		}
		Py_XDECREF(ret);
	}
	
	Py_DECREF(control);
}
Beispiel #18
0
bool Block::getLoop(const Block *&head, const Block *&tail, const Block *&next) const {
	head = tail = next = 0;

	const ControlStructure *c = 0;
	for (size_t i = (size_t)kControlTypeDoWhileHead; i <= (size_t)kControlTypeWhileNext; i++)
		if ((c = getControl((ControlType)i)))
			break;

	if (!c)
		return false;

	head = c->loopHead;
	tail = c->loopTail;
	next = c->loopNext;
	return true;
}
Beispiel #19
0
/*
 * Updates the set duty vi the PID
 *
 */
void updateDuty() {
//	DBG("updateDuty Start\n");
	Control* control = getControl();
	if (control->mode == MODE_ON) {

//DBG("updateDuty lockSteps\n");
		lockSteps();
//DBG("updateDuty lockSteps OK\n");

		if (stepCount > 0) {
			ControlStep * step = &controlSteps[0];
			int controlPointCount = step->controlPointCount;
			for (int cpIndex = 0; cpIndex < controlPointCount; cpIndex++) {
				ControlPoint *cp = &step->controlPoints[cpIndex];
				cp->dutyController.on = true;
				if (cp->automaticControl) {
					TempSensor* sensor = getSensorByAddress(cp->tempSensorAddressPtr);

					if (sensor != NULL) {
						lockSensor(sensor, "CTRL updateDuty");
						if (hasVaildTemp(sensor)) {
							if (cp->hasDuty) {
								cp->duty = getDutyFromAdjuster(&cp->pid, cp->targetTemp, sensor->lastTemp);
							} else {
								//TODO MIN TOGGLE TIME!!!!
								if (sensor->lastTemp < cp->targetTemp) {
									cp->duty = 100;
								} else {
									cp->duty = 0;
								}
							}
						} else {
							cp->duty = 0;
						}
						unlockSensor(sensor);

					} else {
						DBG("Failed to find sensor\n");
					}
				}
			}
		}
		unlockSteps();
	}

	//DBG("updateDuty END\n");
}
BOOL LoginDialog::onOptions()
{
  OptionsDialog dialog;
  dialog.setConnectionConfig(&m_connectionConfig);
  dialog.setParent(getControl());
  if (dialog.showModal() == 1) {
    StringStorage server;
    m_server.getText(&server);
    if (server.isEmpty()) {
      ConnectionConfigSM ccsm(RegistryPaths::VIEWER_PATH,
                              server.getString());
      m_connectionConfig.saveToStorage(&ccsm);
    }
    return FALSE;
  }
  return TRUE;
}
Beispiel #21
0
int	Controller::Peripheral::checkButtons()
{
  register SDL_GameController *getJoy = getControl();

  _but = Controller::BUTTON_INVALID;
  if (!getJoy)
    return (checkJoyButton());
  for (register int i = static_cast<int>(BUTTON_MAX); i >= 0 ; i--)
    {
      if (SDL_GameControllerGetButton(getJoy, static_cast<SDL_GameControllerButton>(i)))
	{
	  _but = static_cast<Controller::Button>(getValToBut(static_cast<Controller::Button>(i)));
	  break ;
	}
    }
  return (-1);
}
Beispiel #22
0
OSStatus
OPL_LoginDialog::handleCommandEvent(UInt32 commandID)
{
    UInt32 idx;
    CFStringRef str;
    char *dsn;
    char tmp_path[1024];

    switch (commandID) {
    case 'SDIR':
        ControlRef f_select;
        CFStringRef menuText;
        MenuRef menu;

        getControl(kLoginDIR, &f_select);
        menu = GetControlPopupMenuHandle(f_select);
        idx = GetControlValue (f_select);
        CopyMenuItemTextAsCFString(menu, idx, &menuText);
        CFStringGetCString(menuText, tmp_path, sizeof(tmp_path), kCFStringEncodingUTF8);
        CFRelease(menuText);

        loadFDSNList(tmp_path);
        return noErr;

    case 'SFDS':
        idx = fdsnlist->getSelectedItem();
        if (idx && !fdsnlist->getItemType(idx))
        {   // set DSN
            dsn = OPL_CFString_to_char(fdsnlist->getItem(idx));
            str = OPL_CFString_asprintf("%s/%s", cur_dir, dsn);
            setEditText(kLoginDSN, str);
            free(dsn);
        }
        return noErr;

    case 'SDS ':
        idx = dsnlist->getSelectedItem();
        if (idx)
            setEditText(kLoginDSN, CFStringCreateCopy(NULL, dsnlist->getItem(idx)));
        return noErr;

    default:
        return OPL_Dialog::handleCommandEvent(commandID);
    }
}
Beispiel #23
0
void LLControlGroup::setValue(const LLString& name, const LLSD& val)
{
	if (name.empty())
	{
		return;
	}

	LLControlBase* control = getControl(name);
	
	if (control)
	{
		control->set(val);
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
Beispiel #24
0
WWindow *WDialog::switchChild( WWindow *win, bool forward ) {
/***********************************************************/

    unsigned    control;

    if( GUIGetFocus( handle(), &control ) ) {
        // control has the focus
        WWindow* child = getControl( control );
        return( WWindow::switchChild( child, forward ) );
    } else if( this == win->parent() ) {
        // window inside a dialog has the focus
        // GUI won't generate a "losing focus" message so WCLASS
        // has to simulate one
        win->losingFocus( NULL );
        return( WWindow::switchChild( win, forward ) );
    }
    return( NULL );
}
Beispiel #25
0
void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val)
{
	if (name.empty())
	{
		return;
	}

	LLControlVariable* control = getControl(name);
	
	if (control)
	{
		control->setValue(val);
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << LL_ENDL;
	}
}
Beispiel #26
0
void ListBoxItem::performLayout() {
	// Without a parent we cannot build geometry.
	if(getParent() == NULL) {
		return;
	}

	Label* label = dynamic_cast<Label*>(getControl());
	if(label != NULL) {
		label->setText(m_Text);
	}

	// Make sure that all our child controls onInit() is called.
	SingleControlContainer::performLayout();
	
	ControlGeometryBuilder geometryBuilder;
	osg::ref_ptr<osg::Group> item = geometryBuilder.buildListBoxItem(this);
	getNode()->addChild(item.get());	
}
Beispiel #27
0
void
OPL_LoginDialog::fill_dir_menu(char *path)
{
    char *tmp_dir, *prov, *dir;
    MenuRef items_m;
    int i = -1;
    ControlRef f_select;

    getControl(kLoginDIR, &f_select);

    if (!path || !(prov = strdup (path)))
        return;

    if (prov[strlen(prov) - 1] == '/' && strlen(prov) > 1)
        prov[strlen(prov) - 1] = 0;

    items_m = GetControlPopupMenuHandle (f_select);
    DeleteMenuItems (items_m, 1, CountMenuItems (items_m));

    /* Add the root directory */
    AppendMenuItemTextWithCFString(items_m, CFSTR("/"), 0, 0, NULL);

    for (tmp_dir = prov, dir = NULL; tmp_dir;
            tmp_dir = strchr (tmp_dir + 1, '/'))
    {
        if (strchr (tmp_dir + 1, '/'))
        {
            dir = strchr (tmp_dir + 1, '/');
            *dir = 0;
        }

        AppendMenuItemTextWithCFString(items_m, OPL_char_to_CFString(prov), 0, 0, NULL);

        if (dir)
            *dir = '/';
    }
    i = CountMenuItems (items_m);
    SetControlMaximum (f_select, i);
    SetControlValue (f_select, i);
    if (cur_dir)
        free(cur_dir);
    cur_dir = prov;
}
Beispiel #28
0
//show 'disabled' frame (0) or default active frame (last)
bool Controls::enableControl(bool bEnable, int id)
{
    Control *pc = getControl(id);
    if (pc)
    {
        Sprite *ps = pc->getSprite();
        if (!ps) return false;  //fail!
        if (bEnable)
        {
            ps->setTouchable(true);
            pc->setIdleFrame();
            ps->setVisible(true);   //must be visible if enabled
        }
        else
        {
            ps->setTouchable(false);
            ps->setFrame(0);
        }
        return true;
    }
    return false;   //id not found
}
Beispiel #29
0
/*
 * Toggles the control PIN so we get the correct on/off times for the set duty
 * Also makes sure we don't every exceed our max amps
 *
 */
void updatePinsForSetDuty() {
	Control* control = getControl();
	if (control->mode != MODE_OFF) {

		int currentAmps = 0;
		lockSteps();
		if (stepCount > 0) {
			ControlStep * step = &controlSteps[0];
			int controlPointCount = step->controlPointCount;
			for (int cpIndex = 0; cpIndex < controlPointCount; cpIndex++) {
				ControlPoint *cp = &step->controlPoints[cpIndex];
				setupControlPoint(cp);
				int duty = cp->duty;
				int maxAmps = 0;

				Configuration* configuration = getConfiguration();
				if (configuration != NULL && configuration->brewLayout != NULL) {
					maxAmps = configuration->brewLayout->maxAmps;
				}

				if (currentAmps + cp->fullOnAmps > maxAmps) {
					updateForOverAmps(&cp->dutyController);
				} else if (cp->hasDuty) {
					//DBG("  Pin: %d Duty: %d\n",cp->controlIo, cp->duty);
					setHeatDuty(&cp->dutyController, duty);
					updateIoForStateAndDuty(&cp->dutyController);
				} else {
					updateForPinState(&cp->dutyController, duty > 0);
				}

				if (cp->dutyController.ioState) {
					currentAmps += cp->fullOnAmps;
				}
			}
		}
		unlockSteps();
	}
	//DBG("***********  updatePinsForSetDuty - END *************** \n");
}
Eigen::VectorXd TargetTrackingController::getControlTopo(const EKF *ekf, const MultiAgentMotionModel *motionModel, std::vector<const SensorModel*> &sensorModel) {
  std::vector<Topology> neighbors = topo.getNeighbors();
  neighbors.push_back(topo);
  std::vector<Eigen::VectorXd> controls(neighbors.size());
  std::vector<double> cost(neighbors.size());
  int min_idx = 0;
  double min_cost = DBL_MAX;
#ifndef DEBUG
#pragma omp parallel for
#endif
  for (unsigned int i=0; i<neighbors.size(); ++i) {
    controls[i] = getControl(ekf, motionModel, neighbors[i].getSensorModels(), &cost[i]);
  }
  for (unsigned int i=0; i<neighbors.size(); ++i) {
    if (cost[i] < min_cost) {
      min_idx = i;
      min_cost = cost[i];
    }
  }
  topo = neighbors[min_idx];
  sensorModel = topo.getSensorModels();
  return controls[min_idx];
}