Beispiel #1
0
/*
================
idUsercmdGenLocal::AdjustAngles

Moves the local angle positions
================
*/
void idUsercmdGenLocal::AdjustAngles( void ) {
	float	speed;
	
	if ( toggled_run.on ^ ( in_alwaysRun.GetBool() && idAsyncNetwork::IsActive() ) ) {
		speed = idMath::M_MS2SEC * USERCMD_MSEC * in_angleSpeedKey.GetFloat();
	} else {
		speed = idMath::M_MS2SEC * USERCMD_MSEC;
	}

	if ( !ButtonState( UB_STRAFE ) ) {
		viewangles[YAW] -= speed * in_yawSpeed.GetFloat() * ButtonState( UB_RIGHT );
		viewangles[YAW] += speed * in_yawSpeed.GetFloat() * ButtonState( UB_LEFT );
	}

	viewangles[PITCH] -= speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKUP );
	viewangles[PITCH] += speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKDOWN );
}
Beispiel #2
0
void SampleCfg::DoSelChange ()
{
	IT_IT("SampleCfg::DoSelChange");

	QString cmd = "select * from SAMPLE where NAME='"+Name->text()+"';";
	GetConfigureDb ()->DoExec (this, cmd, tItem);	// lock the db and action the request
	ButtonState (false);
};
Beispiel #3
0
void UserCfgDlg::DoSelChange ()
{
	IT_IT("UUserCfgDlg::DoSelChange");	
	
	QString cmd =
	"select * from USERS where NAME ='" + Name->currentText () + "';";	// retrive the record
	GetConfigureDb ()->DoExec (this,cmd,tItem);
	ButtonState (false);
};
Beispiel #4
0
void SerialCfg::Apply ()
{
	Build ();
	QString cmd =
	GetConfigureDb ()->Update ("SERIAL", "NAME", Name->currentText ());	// generate the update record
	GetConfigureDb ()->DoExec (this, cmd,tApply);	// lock the db and action the request
	ButtonState (false);
	DOAUDIT(tr("Apply:") + Name->currentText());
}
Beispiel #5
0
DeviceTile::DeviceTile(int x, int y, int device_id, DeviceTileType type,
                       const MidiCommDescriptionList &device_list,
                       Tga *button_graphics, Tga *frame_graphics) :
  m_x(x),
  m_y(y),
  m_preview_on(false),
  m_device_id(device_id),
  m_device_list(device_list),
  m_tile_type(type),
  m_button_graphics(button_graphics),
  m_frame_graphics(frame_graphics) {

  // Initialize the size and position of each button
  whole_tile = ButtonState(0, 0, DeviceTileWidth, DeviceTileHeight);
  button_mode_left  = ButtonState(  6, 38, GraphicWidth, GraphicHeight);
  button_mode_right = ButtonState(428, 38, GraphicWidth, GraphicHeight);
  button_preview    = ButtonState(469, 38, GraphicWidth, GraphicHeight);
}
Beispiel #6
0
void UserCfgDlg::Apply ()
{
	Build ();
	GetConfigureDb()->AddToRecord("UPDTIME",DATETIME_NOW,false); // set the update time
	QString cmd =
	GetConfigureDb ()->Update ("USERS", "NAME", Name->currentText ());	// generate the update record
	GetConfigureDb ()->DoExec (this, cmd, tApply);	// lock the db and action the request
	ButtonState (false);
	DOAUDIT(tr("Apply:") + Name->currentText());
}
/*
==============
idUsercmdGenLocal::CmdButtons
==============
*/
void idUsercmdGenLocal::CmdButtons(void)
{
	int		i;

	cmd.buttons = 0;

	// figure button bits
	for (i = 0 ; i <= 7 ; i++) {
		if (ButtonState((usercmdButton_t)(UB_BUTTON0 + i))) {
			cmd.buttons |= 1 << i;
		}
	}

	// check the attack button
	if (ButtonState(UB_ATTACK)) {
		cmd.buttons |= BUTTON_ATTACK;
	}

	// check the run button
	if (toggled_run.on ^(in_alwaysRun.GetBool() && idAsyncNetwork::IsActive())) {
		cmd.buttons |= BUTTON_RUN;
	}

	// check the zoom button
	if (toggled_zoom.on) {
		cmd.buttons |= BUTTON_ZOOM;
	}

	// check the scoreboard button
	if (ButtonState(UB_SHOWSCORES) || ButtonState(UB_IMPULSE19)) {
		// the button is toggled in SP mode as well but without effect
		cmd.buttons |= BUTTON_SCORES;
	}

	// check the mouse look button
	if (ButtonState(UB_MLOOK) ^ in_freeLook.GetInteger()) {
		cmd.buttons |= BUTTON_MLOOK;
	}
}
Beispiel #8
0
void UnitCfg::Apply ()
{
	Build ();
	QString cmd =
	GetConfigureDb ()->Update ("UNITS", "NAME", Name->currentText ());	// generate the update record
	GetConfigureDb ()->DoExec (this,  cmd, tApply);	// 
	ButtonState (false);
	//
	if(fNew)
	{
		Configure();
	};
	//
	DOAUDIT(tr("Apply:") + Name->currentText());
}
Beispiel #9
0
void SampleCfg::Apply ()
{
	IT_IT("SampleCfg::Apply");
	
	Build ();
	//
	tmp_type = Type->currentText();
	//
	if(pConfig)
	{
		// save the configuration
		emit SaveConfig (Name->text ());
	};
	//
	QString cmd =
	GetConfigureDb()->Update ("SAMPLE", "NAME", Name->text ());	// generate the update record
	GetConfigureDb()->DoExec (this, cmd,tApply);	
	ButtonState (false);
	//
	// Make sure the tag list is correct
	// query for the current tag list
	// make sure the tags and current tags are all upto date
	// 
	GetConfigureDb()->DoExec(this,"select * from TAGS where NAME='"+Name->text()+"';",tTagList); // get the current tag list
	//  
	if(tmp_ip_index != InputIndex->currentText())
	{
		// the input index changed - update the type list
		int id = CurrentTypeList.findIndex(InputIndex->currentText()); // remove the now used index          
		if(id != -1)
		{
			CurrentTypeList.remove(CurrentTypeList.at(id)); // delete it 
		};
		CurrentTypeList << tmp_ip_index; // add the old (now free) index
		tmp_ip_index = InputIndex->currentText(); // save the current index
	};
	//
	// Update the comment field - for the current item
	// 
	if(List->currentItem())
	{
		(List->currentItem())->setText(1,Comment->text());
	};
	// 
	DOAUDIT(tr("Apply:") + Name->text());
	//
}
Beispiel #10
0
AlarmGroupCfg::AlarmGroupCfg
(QWidget * parent, const char *name):Inherited (parent, name),pTimer(new QTimer(this))
{
	setCaption (tr("Alarm Group Configuration"));
	connect (GetConfigureDb (),
	SIGNAL (TransactionDone (QObject *, const QString &, int, QObject*)), this,
	SLOT (QueryResponse (QObject *, const QString &, int, QObject*)));	// connect to the databas
	//
	GetConfigureDb()->DoExec(this,"select NAME from ALARMGROUP order by NAME asc;",tList); // get the report namesd 
	GetConfigureDb ()->DoExec (this, "select NAME from SAMPLE;",tListSPs); // get the sample point list
	//
	connect (pTimer, SIGNAL (timeout ()), this, SLOT (DoSelChange ()));	// wire up the item selection timer
	ButtonState(false);
	//
	Comment->setMaxLength(MAX_LENGHT_OF_STRING);
	
}
Beispiel #11
0
static void ManageLoop(void)
{
  static uint16_t adc_value = kAdcPending;
  // button handling
  if (ButtonSwitch(&button_small))
  {
    if (ButtonState(&button_small) == 1)
    {
      //AdcStart(0, &adc_value);
      LedToggle(&led_green);
    }
  }

  if (adc_value != kAdcPending)
  {
    UartTransmitNumber(adc_value);
    adc_value = kAdcPending;
  }
}
Beispiel #12
0
/*
=================
idUsercmdGenLocal::JoystickMove
=================
*/
void idUsercmdGenLocal::JoystickMove( void ) {
	float	anglespeed;

	if ( toggled_run.on ^ ( in_alwaysRun.GetBool() && idAsyncNetwork::IsActive() ) ) {
		anglespeed = idMath::M_MS2SEC * USERCMD_MSEC * in_angleSpeedKey.GetFloat();
	} else {
		anglespeed = idMath::M_MS2SEC * USERCMD_MSEC;
	}

	if ( !ButtonState( UB_STRAFE ) ) {
		viewangles[YAW] += anglespeed * in_yawSpeed.GetFloat() * joystickAxis[AXIS_SIDE];
		viewangles[PITCH] += anglespeed * in_pitchSpeed.GetFloat() * joystickAxis[AXIS_FORWARD];
	} else {
		cmd.rightmove = idMath::ClampChar( cmd.rightmove + joystickAxis[AXIS_SIDE] );
		cmd.forwardmove = idMath::ClampChar( cmd.forwardmove + joystickAxis[AXIS_FORWARD] );
	}

	cmd.upmove = idMath::ClampChar( cmd.upmove + joystickAxis[AXIS_UP] );
}
Beispiel #13
0
SerialCfg::SerialCfg
(QWidget * parent,
const char *name):Inherited (parent, name), pTimer (new QTimer (this))
{
	setCaption (tr ("Serial Port Configuration"));
	connect (GetConfigureDb (),
	SIGNAL (TransactionDone (QObject *, const QString &, int, QObject*)), this,
	SLOT (QueryResponse (QObject *, const QString &, int, QObject*)));	// connect to the databas
	GetConfigureDb()->DoExec(this,"select NAME from SERIAL order by NAME asc;",tList);
	ButtonState (false);
	connect (pTimer, SIGNAL (timeout ()), this, SLOT (DoSelChange ()));	// wire up the item selection timer
	//
	Comment->setMaxLength(MAX_LENGHT_OF_STRING);
	//set the tab order
	// 
	QWidget *pL[] = {
		Name, Enabled, Comment, DataBits, StopBits, Parity, BaudRate, 0
	};
	SetTabOrder (this, pL);
}
Beispiel #14
0
void UnitCfg::New ()
{
	NewDlg dlg (Name, this);
	if (dlg.exec ())
	{
		//
		Comment->setText (tr(NONE_STR));
		Name->insertItem (dlg.GetName ());	// add to the list box
		Enabled->setChecked (0);
		SetComboItem (Name, dlg.GetName ());	// make it the selected item 
		//
		Build ();		// build the record 
		GetConfigureDb ()->AddToRecord ("NAME", Name->currentText ());
		QString cmd = GetConfigureDb ()->Insert ("UNITS");	// generate the update record
		GetConfigureDb ()->DoExec (this, cmd,tNew);	// lock the db and action the request
		//
		ButtonState (false);
		fNew = true;
		DOAUDIT(tr("New:") + dlg.GetName());
	};
}
Beispiel #15
0
bool Gamepad::GetEvent(Event &event) {
    // button IDs are 1-indexed
    for (size_t button = 1; button <= button_state.size(); ++button) {
        bool state = ButtonState(button);
        if (button_state[button - 1] != state) {
            button_state[button - 1] = state;
            event.type = Event::BUTTON_EVENT;
            event.id = button;
            event.state = state;
            event.value = 0;
            event.angle = 0;
            return true;
        }
    }
    for (size_t axis = 0; axis < axis_state.size(); ++axis) {
        float value = joystick.GetRawAxis(axis);
        if (std::fabs(value - axis_state[axis]) > AXIS_THRESHOLD) {
            axis_state[axis] = value;
            event.type = Event::AXIS_EVENT;
            event.id = axis;
            event.state = (value > AXIS_THRESHOLD);
            event.value = value;
            event.angle = 0;
            return true;
        }
    }
    for (size_t pov = 0; pov < pov_state.size(); ++pov) {
        int angle = joystick.GetPOV(pov);
        if (angle != pov_state[pov]) {
            pov_state[pov] = angle;
            event.type = Event::POV_EVENT;
            event.id = pov;
            event.state = (angle >= 0);  // angle is -1 if not pressed
            event.value = 0;
            event.angle = angle;
            return true;
        }
    }
    return false;
}
Beispiel #16
0
void UserCfgDlg::New ()
{
	// Get the new name
	NewDlg dlg (Name, this);
	if (dlg.exec ())
	{
		// 
		ReportsPriviledge->setChecked (0);
		AlarmAckPriv->setChecked (0);
		ReportsPriv->setChecked (0);
		ReportsPriviledge->setEnabled (true);
		AlarmAckPriv->setEnabled (true);
		ReportsPriv->setEnabled (true);
		ExitApp->setEnabled(0); // need this priviledge to close the user interface
		AllPriv->setChecked (0);
		AgePassword->setChecked(true); // default to needing to change passwords
		AgeDays->setValue(0); // require password to change on next login
		FactoryAdministrator->setChecked(false); // default no Factory Administrator
		//
		Comment->setText (tr(NONE_STR));
		Password->setText (tr(NONE_STR));
		//
		// leave the language - so it defaults to current
		// 
		Name->insertItem (dlg.GetName ());	// add to the list box
		SetComboItem (Name, dlg.GetName ());	// make it the selected item 
		//
		Build ();		// build the record 
		GetConfigureDb ()->AddToRecord ("PSSWORD", tr(NONE_STR)); // force user toe choose password on startup
		//
		GetConfigureDb ()->AddToRecord ("NAME", Name->currentText ());
		QString cmd = GetConfigureDb ()->Insert ("USERS");	// generate the update record
		GetConfigureDb ()->DoExec (this, cmd,tNew);	// lock the db and action the request
		//
		ButtonState (false);
		//
		DOAUDIT(tr("New:") + dlg.GetName());
		//
	};
}
Beispiel #17
0
void SampleCfg::New ()
{
	IT_IT("SampleCfg::New");
	
	//
	// Save any existing configuration for any existing point
	//
	//
	NewDlg dlg (List, this);
	dlg.setCaption (tr ("New Sample Points"));
	if (dlg.exec ())
	{
		// delete the config widget
		RemoveConfig();
		// 
		SetComboItem (Unit, tr(NONE_STR));
		InputIndex->clear ();
		InputIndex->insertItem(tr(NONE_STR));
		InputIndex->setCurrentItem (0);
		// 
		Comment->setText (tr(NONE_STR));
		(void) new QListViewItem(List,dlg.GetName (),tr(NONE_STR));	// add to the list box
		Enabled->setChecked (0);
		Fileable->setChecked (0);
		Retrigger->setChecked(0);
		AlarmThreshold->setValue(0);
		//
		SetListViewItem (List, dlg.GetName ());	// make it the selected item 
		Name->setText (dlg.GetName ());
		//
		Build ();		// build the record 
		GetConfigureDb ()->AddToRecord ("NAME", Name->text ());
		QString cmd = GetConfigureDb ()->Insert ("SAMPLE");	// generate the update record
		GetConfigureDb ()->DoExec (this, cmd, tNew);	// lock the db and action the request
		//
		ButtonState (false);
		DOAUDIT(tr("New:") + dlg.GetName());
	}
}
Beispiel #18
0
/*
================
idUsercmdGenLocal::KeyMove

Sets the usercmd_t based on key states
================
*/
void idUsercmdGenLocal::KeyMove( void ) {
	int		forward, side, up;

	forward = 0;
	side = 0;
	up = 0;
	if ( ButtonState( UB_STRAFE ) ) {
		side += KEY_MOVESPEED * ButtonState( UB_RIGHT );
		side -= KEY_MOVESPEED * ButtonState( UB_LEFT );
	}

	side += KEY_MOVESPEED * ButtonState( UB_MOVERIGHT );
	side -= KEY_MOVESPEED * ButtonState( UB_MOVELEFT );

	up -= KEY_MOVESPEED * toggled_crouch.on;
	up += KEY_MOVESPEED * ButtonState( UB_UP );

	forward += KEY_MOVESPEED * ButtonState( UB_FORWARD );
	forward -= KEY_MOVESPEED * ButtonState( UB_BACK );

	cmd.forwardmove = idMath::ClampChar( forward );
	cmd.rightmove = idMath::ClampChar( side );
	cmd.upmove = idMath::ClampChar( up );
}
Beispiel #19
0
SampleCfg::SampleCfg
(QWidget * parent,
const char *name):Inherited (parent, name),
pTimer (new QTimer (this)),pConfig (0),
pCfgDriver(0)
{
	IT_IT("SampleCfg::SampleCfg");
	
	setCaption (tr ("Sample Point Configuration"));
	unit_type = tr(NONE_STR);
	//
	connect (GetConfigureDb(),
	SIGNAL (TransactionDone (QObject *, const QString &, int, QObject*)), this,
	SLOT (QueryResponse (QObject *, const QString &, int, QObject*)));	// connect to the database
	connect (GetResultDb(),
	SIGNAL (TransactionDone (QObject *, const QString &, int, QObject*)), this,
	SLOT (QueryResponse (QObject *, const QString &, int, QObject*)));	// connect to the database
	//
	GetConfigureDb()->DoExec(this,"select NAME,COMMENT from SAMPLE order by NAME asc;",tList);
	GetConfigureDb()->DoExec(this,"select NAME from UNITS order by NAME asc;",tUnitList);
	ButtonState (false);
	//
	connect (pTimer, SIGNAL (timeout ()), this, SLOT (DoSelChange ()));	// wire up the item selection timer
		
	InputIndex->insertItem(tr(NONE_STR));
			
	Type->insertItem (tr(NONE_STR));
	//
	Comment->setMaxLength(MAX_LENGHT_OF_STRING);
	//set the tab order
	// 
	QWidget *pL[] =
	{
		List, Comment, Unit, Type, InputIndex, Units,
		Enabled, Fileable,LogMode,Retrigger,AlarmThreshold, 0
	};
	SetTabOrder (this, pL);
}
Beispiel #20
0
void AlarmGroupCfg::Apply ()
{
	Build ();
	//
	QString cmd =
	GetConfigureDb ()->Update ("ALARMGROUP", "NAME", Name->currentText ());	// generate the update record
	GetConfigureDb ()->DoExec (this, cmd, tApply);	// lock the db and action the request
	//
	ButtonState (false);
	//
	cmd = "delete from ALM_GRP_STATE where NAME ='" + Name->currentText() + "';"; 
	GetCurrentDb()->DoExec(0,cmd,0);
	if (GroupList->count () > 0)
	{
		for(unsigned i = 0; i < GroupList->count(); i++)
		{
			cmd = "insert into ALM_GRP_STATE values ('"+ Name->currentText() + "','" + GroupList->text (i) + "',0,0," + DATETIME_NOW + ",0);";

			GetCurrentDb()->DoExec(0,cmd,0);
		}
	}
	DOAUDIT(tr("Apply:") + Name->currentText());
}
Beispiel #21
0
UnitCfg::UnitCfg  (QWidget * parent,
const char *name):Inherited (parent, name), pTimer (new QTimer (this)),fNew(0)
{
	setCaption (tr ("Unit Configuration"));
	connect (GetConfigureDb (),
	SIGNAL (TransactionDone (QObject *, const QString &, int, QObject*)), this,
	SLOT (QueryResponse (QObject *, const QString &, int, QObject*)));	// connect to the databas
	GetConfigureDb()->DoExec(this,"select NAME from UNITS order by NAME asc;",tList);
	ButtonState (false);
	connect (pTimer, SIGNAL (timeout ()), this, SLOT (DoSelChange ()));	// wire up the item selection timer
	//
	// Fill the unit type list
	QDir d (QSDRIVER_DIR, "*" DLL_EXT, QDir::Name, QDir::Files);	// get the directory listing
	// 
	if (d.count ())
	{
		const QFileInfoList *pD = d.entryInfoList ();
		QFileInfoListIterator it (*pD);
		QFileInfo *fi;
		//
		while ((fi = it.current ()))
		{
			UnitType->insertItem (fi->baseName ());
			++it;
		};
	};
	//
	Comment->setMaxLength(MAX_LENGHT_OF_STRING);
	//set the tab order
	// 
	QWidget *pL[] = 
	{
		Name, Comment, UnitType, Enabled, ApplyButton, NewButton,
		DeleteButton,0
	};
	SetTabOrder (this, pL);
}
Beispiel #22
0
/*
=================
idUsercmdGenLocal::MouseMove
=================
*/
void idUsercmdGenLocal::MouseMove( void ) {
	float		mx, my, strafeMx, strafeMy;
	static int	history[8][2];
	static int	historyCounter;
	int			i;

	history[historyCounter&7][0] = mouseDx;
	history[historyCounter&7][1] = mouseDy;
	
	// allow mouse movement to be smoothed together
	int smooth = m_smooth.GetInteger();
	if ( smooth < 1 ) {
		smooth = 1;
	}
	if ( smooth > 8 ) {
		smooth = 8;
	}
	mx = 0;
	my = 0;
	for ( i = 0 ; i < smooth ; i++ ) {
		mx += history[ ( historyCounter - i + 8 ) & 7 ][0];
		my += history[ ( historyCounter - i + 8 ) & 7 ][1];
	}
	mx /= smooth;
	my /= smooth;

	// use a larger smoothing for strafing
	smooth = m_strafeSmooth.GetInteger();
	if ( smooth < 1 ) {
		smooth = 1;
	}
	if ( smooth > 8 ) {
		smooth = 8;
	}
	strafeMx = 0;
	strafeMy = 0;
	for ( i = 0 ; i < smooth ; i++ ) {
		strafeMx += history[ ( historyCounter - i + 8 ) & 7 ][0];
		strafeMy += history[ ( historyCounter - i + 8 ) & 7 ][1];
	}
	strafeMx /= smooth;
	strafeMy /= smooth;

	historyCounter++;

	if ( idMath::Fabs( mx ) > 1000 || idMath::Fabs( my ) > 1000 ) {
		Sys_DebugPrintf( "idUsercmdGenLocal::MouseMove: Ignoring ridiculous mouse delta.\n" );
		mx = my = 0;
	}

	mx *= sensitivity.GetFloat();
	my *= sensitivity.GetFloat();

	if ( m_showMouseRate.GetBool() ) {
		Sys_DebugPrintf( "[%3i %3i  = %5.1f %5.1f = %5.1f %5.1f] ", mouseDx, mouseDy, mx, my, strafeMx, strafeMy );
	}

	mouseDx = 0;
	mouseDy = 0;

	if ( !strafeMx && !strafeMy ) {
		return;
	}

	if ( ButtonState( UB_STRAFE ) || !( cmd.buttons & BUTTON_MLOOK ) ) {
		// add mouse X/Y movement to cmd
		strafeMx *= m_strafeScale.GetFloat();
		strafeMy *= m_strafeScale.GetFloat();
		// clamp as a vector, instead of separate floats
		float len = sqrt( strafeMx * strafeMx + strafeMy * strafeMy );
		if ( len > 127 ) {
			strafeMx = strafeMx * 127 / len;
			strafeMy = strafeMy * 127 / len;
		}
	}

	if ( !ButtonState( UB_STRAFE ) ) {
		viewangles[YAW] -= m_yaw.GetFloat() * mx;
	} else {
		cmd.rightmove = idMath::ClampChar( (int)(cmd.rightmove + strafeMx) );
	}

	if ( !ButtonState( UB_STRAFE ) && ( cmd.buttons & BUTTON_MLOOK ) ) {
		viewangles[PITCH] += m_pitch.GetFloat() * my;
	} else {
		cmd.forwardmove = idMath::ClampChar( (int)(cmd.forwardmove - strafeMy) );
	}
}
void mtsMicroScribeDigitizer::Run(void)
{
    // timestamp of last reconnect trial in case of disconnection
    static double lastReconnectTryTime = 0;

    ProcessQueuedCommands();

    // If not connected, try reconnect at every 1 sec
    if (!DeviceConnected) {
        if (lastReconnectTryTime == 0) {
            lastReconnectTryTime = osaGetTime();
        } else if (lastReconnectTryTime + 1.0 * cmn_s < osaGetTime()) {
			CMN_LOG_CLASS_INIT_VERBOSE << "Run: Try reconnecting to digitizer..." << std::endl;
            if (ARM_SUCCESS == ArmReconnect()) {
                OnDeviceConnection();
			} else {
				CMN_LOG_CLASS_INIT_VERBOSE << "Run: Failed to reconnect to digitizer." << std::endl;
			}
        }
        return;
    }

    // read digitizer tip position
    if (ARM_NOT_CONNECTED == ArmGetTipPosition(&TipPositionVendor)) {
        // Disconnection detected
        OnDeviceDisconnection();
        return;
    }
    // read digitizer tip orientation 
    if (ARM_NOT_CONNECTED == ArmGetTipOrientation(&TipOrientationVendor)) {
        // Disconnection detected
        OnDeviceDisconnection();
        return;
    }
    // read digitizer tip orientation unit vector
    if (ARM_NOT_CONNECTED == ArmGetTipOrientationUnitVector(&TipOrientationUnitVectorVendor)) {
        // Disconnection detected
        OnDeviceDisconnection();
        return;
    }
    // read digitizer button states
    if (ARM_NOT_CONNECTED == ArmGetButtonsState(&ButtonStateVendor)) {
        // Disconnection detected
        OnDeviceDisconnection();
        return;
    }
    // read digitizer joint readings
    if (ARM_NOT_CONNECTED == ArmGetJointAngles(ARM_DEGREES, // or ARM_RADIANS
                                               JointReadingsVendor)) 
    {
        // Disconnection detected
        OnDeviceDisconnection();
        return;
    }

    // Convert vendor-defined container to cisst container
    // position
    TipPosition(X) = TipPositionVendor.x;
    TipPosition(Y) = TipPositionVendor.y;
    TipPosition(Z) = TipPositionVendor.z;
    // orientation
    TipOrientation(ROLL) = TipOrientationVendor.x;
    TipOrientation(PITCH) = TipOrientationVendor.y;
    TipOrientation(YAW) = TipOrientationVendor.z;
    // orientation unit vector
    TipOrientationUnitVector(ROLL) = TipOrientationUnitVectorVendor.x;
    TipOrientationUnitVector(PITCH) = TipOrientationUnitVectorVendor.y;
    TipOrientationUnitVector(YAW) = TipOrientationUnitVectorVendor.z;
    // button state
    static DWORD lastButtonStateVendor = 0;
    bool buttonStateChange = false;

    if (!(lastButtonStateVendor & ARM_BUTTON_1) && (ButtonStateVendor & ARM_BUTTON_1)) {
        EventButton1Down();
        ButtonState(BUTTON_1) = DOWN;
        buttonStateChange = true;
    } else if ((lastButtonStateVendor & ARM_BUTTON_1) && !(ButtonStateVendor & ARM_BUTTON_1)) {
        EventButton1Up();
        ButtonState(BUTTON_1) = UP;
        buttonStateChange = true;
    }

    if (!(lastButtonStateVendor & ARM_BUTTON_2) && (ButtonStateVendor & ARM_BUTTON_2)) {
        EventButton2Down();
        ButtonState(BUTTON_2) = DOWN;
        buttonStateChange = true;
    } else if ((lastButtonStateVendor & ARM_BUTTON_2) && !(ButtonStateVendor & ARM_BUTTON_2)) {
        EventButton2Up();
        ButtonState(BUTTON_2) = UP;
        buttonStateChange = true;
    }

    if (buttonStateChange) {
        lastButtonStateVendor = ButtonStateVendor;
    }

    // Joint readings
    for (size_t i = 0; i < NUM_DOF; ++i) {
        JointReadings(i) = JointReadingsVendor[i];
    }
}
Beispiel #24
0
int main(void)
{
unsigned char   temp1, temp2, temp3;
unsigned char   iloop, jloop;
char            CharChoice;
char            ADC_read;
char            Buttons;
char            ssid_size;
bool            flash, finish;

unsigned char   ChanSel, ChanTime;
unsigned char   Channel[7];
unsigned char   NewChannel[7];
unsigned char   charWiFlyMsgLen;
bool            MsgGood, MsgSame;


    InitializeSystem();
    AssociatedCheck = 0;
    initAllIndicators();

    for (jloop = 0; jloop <=6; jloop++)
      {
        Channel[jloop] = 0;
        NewChannel[jloop] = 1;
      }



    LED_D3 = 1;
  Delayms(1000);
    LED_D3 = 0;
    LED_D4 = 1;
  Delayms(1000);
    LED_D4 = 0;
    LED_D5 = 1;
  Delayms(1000);
    LED_D5 = 0;
    LED_D6 = 1;
  Delayms(1000);
    LED_D6 = 0;
    LED_D7 = 1;
  Delayms(1000);
    LED_D7 = 0;
    LED_D8 = 1;
  Delayms(1000);
    LED_D8 = 0;
    LED_D9 = 1;
  Delayms(1000);
    LED_D9 = 0;

    sprintf(OutString, "WiFly Pass_thru\nDemo");
    putsLCD(OutString);
    // JKW starts here
  Delayms(5000);
    sprintf(OutString,"$$$");
    putsWiFly(OutString);
    putsConsole(OutString);

    sprintf(OutString, "                \n                ");  // columns 41, 59
    setLCDC(0x00); // point to 1st line
  Delayms(200);
    putsLCD(&OutString[0]);
    jloop = 0;
    temp1 = 0;
    ssid_size = 0;

    Buttons = ButtonState();

/* ****************************
    sprintf(OutString, "Select SSID from\nmenu:           ");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "Hogwarts        \n                ");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "Press S3 for YES\nor wait for NO  ");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "Zoltan          \n                ");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "Press S3 for YES\nor wait for NO  ");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "These are all I \nsee, to manually");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "enter your own  \ntext, press S3  ");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "You have chosen \nto enter SSID by");  // columns 41, 59
    LCD_and_Console_out(OutString);
    sprintf(OutString, "text wheel,press\nS3 for next char");  // columns 41, 59
    LCD_and_Console_out(OutString);
  **************************** */

    sprintf(OutString, "S6 to go back   \nS5 when done    ");  // columns 41, 59
    LCD_and_Console_out(OutString);

    temp2 = 0;
    CharChoice = 0xFF; // impossible value
    finish = 0;
    ssid_size = 8;
    SSID_text[0] = 'H';
    SSID_text[1] = 'o';
    SSID_text[2] = 'g';
    SSID_text[3] = 'w';
    SSID_text[4] = 'a';
    SSID_text[5] = 'r';
    SSID_text[6] = 't';
    SSID_text[7] = 's';


while(!finish)
{
    sprintf(OutString, "                \n                ");  // columns 41, 59
    ADC_read = ReadADC_char();
    if ( (ADC_read > CharChoice + 0x05) || (ADC_read < CharChoice - 0x05) )
    {   CharChoice = ADC_read - 0x05;
        temp2 = 0;    }
    else
    {   if (temp2>0)
        {   CharChoice++;
            temp2 = 0;   }
        temp2++;    }

    if (CharChoice <= 0x20) CharChoice = 0x20;
    if (CharChoice >= 0x7F) CharChoice = 0x7F;

    if (ssid_size > 0)  // characters previously entered
    {  for (iloop = 0; iloop < ssid_size; iloop++)
       { OutString[iloop] = SSID_text[iloop];   }  }

    OutString[ssid_size] = CharChoice;
    OutString[17] = '_';
    OutString[18] = '_';
    OutString[19] = '_';
    OutString[20] = '_';
    OutString[21] = 0x30;  //(ssid_size - ssid_size %10) + 0x30;
    OutString[22] = (ssid_size %10) + 0x30;

   // putsConsole(OutString);
   LCD_only_out(OutString);

flash = 0;
finish = 0;

for (iloop = 0; iloop <6; iloop++)
{
    if (!( flash || finish) )
       {Buttons = ButtonState(); }  // only allow one button push per
    else Buttons = 0x00;
}

    if (Buttons == 0x01)
    {   SSID_text[ssid_size] = CharChoice;
        ssid_size++;
        Buttons = 0x00;
        OutString[17] = '*';
        flash = 1;  //button action seen, flash the underscore;
    }

    if (Buttons == 0x02)
    {   if (ssid_size != 0) ssid_size = ssid_size - 0x01;
        Buttons = 0x00;
        OutString[18] = '*';
        flash = 1;
    }

if (Buttons == 0x04)
    {   finish = 1;
        if (ssid_size != 0) ssid_size = ssid_size - 0x01;
        Buttons = 0x00;
        OutString[19] = '*';
        iloop = 6;
    }

    if (flash == 1)
    {   if (iloop %2) OutString[ssid_size] = ' ';
        else OutString[ssid_size] = '_';   }

   LCD_only_out(OutString);

  // Wait for button release
  while (Buttons != 0x00)
  {  Buttons = ButtonState();
     Delayms(100);  }

  OutString[17] = '_';
  OutString[18] = '_';
  OutString[19] = '_';
  OutString[20] = '_';
  OutString[21] = 0x30;  //(ssid_size - ssid_size %10) + 0x30;
  OutString[22] = (ssid_size %10) + 0x30;

}  //end of my little text wheel exercise

    // Output Final Result
    sprintf(OutString, "                \n                ");  // columns 41, 59
    if (ssid_size > 0)  // characters previously entered
    {  for (iloop = 0; iloop <= ssid_size; iloop++)
       { OutString[iloop] = SSID_text[iloop];   }
    OutString[17] = '_';
    OutString[18] = '_';
    OutString[19] = '_';
    OutString[20] = '_';
    OutString[21] = (ssid_size - ssid_size %10) + 0x30;
    OutString[22] = (ssid_size %10) + 0x30;
    LCD_only_out(OutString);

 //   setLCDC(0x00); // point to 1st line
 // Delayms(200);
 //   putsLCD(OutString);    }
    }




  Delayms(5000);
    sprintf(OutString,"set ip proto 18\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set dns name 74.208.7.3\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set ip remote 80\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set comm remote 0\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set ip timer 1\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set ip a 192.168.1.115\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set ip host 74.208.7.3\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set ip gateway 192.168.1.1\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set dns a 68.105.28.12\r\n");
    WiFly_and_Console_out(OutString);
//    sprintf(OutString,"set comm remote GET$/users/102\r\n");
    sprintf(OutString,"set comm remote GET$/boardshortmessages/1");
//    sprintf(OutString,"set comm remote GET$/users/105\r\n");
//    sprintf(OutString,"set comm remote GET$/users/112\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"set wlan ssid                     \r\n"); //set wlan ssid Hogwarts\r\n");
    for (iloop = 0; iloop <= ssid_size; iloop++)
    {
        if (iloop <= ssid_size)  { OutString[iloop+14] = SSID_text[iloop];}
//        if (iloop == (ssid_size+1)) { OutString[iloop+14] = 0x5C; } // use 0x5V for '\'
//        if (iloop == (ssid_size+2)) { OutString[iloop+14] = 'r'; }
//        if (iloop == (ssid_size+3)) { OutString[iloop+14] = 0x5C; } // use 0x5V for '\'
//        if (iloop == (ssid_size+4)) { OutString[iloop+14] = 'n'; }
    }

    WiFly_and_Console_out(OutString);
    LCD_only_out(OutString);

  Delayms(2000);

    sprintf(OutString,"set wlan phrase pooKums496\r\n");
    WiFly_and_Console_out(OutString);
    sprintf(OutString,"save\r\n");
    WiFly_and_Console_out(OutString);
//    sprintf(OutString,"get everything\r\n");
//    WiFly_and_Console_out(OutString);
  Delayms(200);
    setLCDC(0x00); // point to 1st line
  Delayms(200);
    sprintf(OutString, "Sept22 5:48PM   \nsocket gets only");  // columns 41, 59
    putsConsole(OutString);
    putsLCD(OutString);
  Delayms(2000);

//    sprintf(OutString,"scan\r\n");
//    WiFly_and_Console_out(OutString);
//    sprintf(OutString,"join # 1\r\n");  // NOT GOOD SINCE THIS CAN CHANGE EVERY MINUTE!!!
    sprintf(OutString,"join                  \r\n"); //set wlan ssid Hogwarts\r\n");
    for (iloop = 0; iloop <= ssid_size; iloop++)
    {
        if (iloop <= ssid_size)  { OutString[iloop+5] = SSID_text[iloop];}
    }
    WiFly_and_Console_out(OutString);
    LCD_only_out(OutString);

  Delayms(5000);

  if (AssociatedCheck)
  {
    putsConsole(WiFlyMsg);
  Delayms(200);
    setLCDC(0x00); // point to 1st line
    sprintf(OutString, "                \n                ");  // columns 41, 59
    putsLCD(OutString);
  Delayms(200);
    setLCDC(0x00); // point to 1st line
    putsLCD(WiFlyMsg);
  }
  else
  {
    sprintf(OutString, "nope\r\n");
    putsConsole(OutString);
  Delayms(200);
    setLCDC(0x00); // point to 1st line
    sprintf(OutString, "nope            \n                ");  // columns 41, 59
  Delayms(200);
    putsLCD(OutString);
  }

  Delayms(2000);

    for (iloop = 0; iloop <=25; iloop++)
    {
    AssociatedCheck = 1;
    MessageCheck = 0;
    MessageCnt = 0;

    sprintf(OutString,"open\r\n");
    putsConsole(OutString);
    putsWiFly(OutString);
  Delayms(1000);
    sprintf(OutString,"!");
    putsConsole(OutString);
    putsWiFly(OutString);
  Delayms(10000);
    sprintf(OutString,"$$$");
    putsConsole(OutString);
    putsWiFly(OutString);

  Delayms(200);
    setLCDC(0x00); // point to 1st line
  Delayms(200);
    sprintf(OutString, "iloop =         \nLoop to 25      ");
    OutString[9] = (char) (0x30 + iloop %10);
    OutString[8] = '0';
    if ((iloop >= 10) && (iloop <= 19)) OutString[8] = '1';
    if ((iloop >= 20) && (iloop <= 29)) OutString[8] = '2';
    putsLCD(OutString);
  Delayms(200);

  if (MessageCheck)
  {
    putsConsole(WiFlyMsg);
    
    sprintf(OutString, "                \n                ");  // 41, 59
//    if (charWiFlyMsgLen > 0)  LED_D5 = 1;
//    if (charWiFlyMsgLen > 5)  LED_D6 = 1;
//    if (charWiFlyMsgLen > 10) LED_D7 = 1;
//    if (charWiFlyMsgLen > 20) LED_D8 = 1;
//    if (charWiFlyMsgLen > 30) LED_D9 = 1;
    temp2 = ( (char) WiFlyMsgLen) %10;
    temp3 = (char) ((char)WiFlyMsgLen - temp2) /10;
    charWiFlyMsgLen = temp3*10+temp2;
    OutString[1] = temp3 + 0x30;
    OutString[2] = temp2 + 0x30;
    LCD_only_out(OutString);
  Delayms(2000);

    if (charWiFlyMsgLen <= 15)
    {
      for (jloop = 0; jloop<=charWiFlyMsgLen; jloop++)
      {  OutString[jloop] = WiFlyMsg[jloop]; }

    }
    else if (charWiFlyMsgLen >= 31 )
    {
      for (jloop = 0; jloop<=15; jloop++)
      {  OutString[jloop] = WiFlyMsg[jloop]; }

      for (jloop = 16; jloop<=31; jloop++)
      {  OutString[jloop+1] = WiFlyMsg[jloop]; }

    }
    else
    {
//      OutString[16] = 0x5C; // '\'
//      OutString[17] = 'n';
      for (jloop = 0; jloop<=15; jloop++)
      {  OutString[jloop] = WiFlyMsg[jloop]; }

      for (jloop = 16; jloop<=charWiFlyMsgLen; jloop++)
      {  OutString[jloop+1] = WiFlyMsg[jloop]; }
    }
    LCD_only_out(OutString);

  }
  else
  {
    sprintf(OutString, "nope\r\n");
    putsConsole(OutString);
  Delayms(200);
    setLCDC(0x00); // point to 1st line
    sprintf(OutString, "nope            \n                ");  // columns 41, 59
  Delayms(200);
    putsLCD(OutString);
  }



  // ***************************************************
  // processing WiFlyMsg quality, and channels and times
  // ***************************************************
  MsgGood = 1;
  MsgSame = 1;
  for (jloop = 12; jloop <=25; jloop++)
  {
      if ( (WiFlyMsg[jloop] >=0x30) && (WiFlyMsg[jloop] <=0x39) )
        {
          if (jloop == 8) LED_D3 = 1;
          if (jloop == 9) LED_D4 = 1;
          if (jloop == 10) LED_D5 = 1;
          if (jloop == 11) LED_D6 = 1;
          if (jloop == 12) LED_D7 = 1;
          if (jloop == 13) LED_D8 = 1;
          if (jloop == 14) LED_D9 = 1;
          if (jloop %2 == 0)
            { temp1 = WiFlyMsg[jloop] - 0x30; }
          else
            { NewChannel[(jloop-1)/2 - 6] = 10*temp1 + WiFlyMsg[jloop] - 0x30; }
        }
      else
        {
          MsgGood = 0;
        }
  }

  if (MsgGood == 1)
  {
    for (jloop = 0; jloop <=6; jloop++)
      {
      if ( NewChannel[jloop] != Channel[jloop] )
        { MsgSame = 0; }
      }
   }

  sprintf(OutString, "\r\n");
  putsConsole(OutString);

  sprintf(OutString, "                        \r\n");
  for (jloop = 0; jloop <=6; jloop++)
  {
  temp2 = NewChannel[jloop] %10;
  temp3 = (char) ((NewChannel[jloop] - temp2) /10);
  OutString[jloop*2] = temp3 + 0x30;
  OutString[jloop*2+1] = temp2 + 0x30;
  }
  putsConsole(OutString);


  if (1)   //MsgSame == 0)
  {
    for (jloop = 0; jloop <=6; jloop++)
      { Channel[jloop] = NewChannel[jloop]; }

    sprintf(OutString, "\r\n");
    putsConsole(OutString);
    sprintf(OutString, "                        \r\n");
    for (jloop = 0; jloop <=6; jloop++)
      {
        temp2 = Channel[jloop] %10;
        temp3 = (char) ((Channel[jloop] - temp2) /10);
        OutString[jloop*2] = temp3 + 0x30;
        OutString[jloop*2+1] = temp2 + 0x30;
      }
    putsConsole(OutString);
    
    ChanSel = 0;
    ChanTime = 0;
    for (jloop = 0; jloop <=6; jloop++)
      {
        sprintf(OutString, "\r\njloop=           ");
        OutString[8] = jloop + 0x30;
        putsConsole(OutString);
        ChanSel = jloop;
        ChanTime = 0;

        if (Channel[jloop] == 0)  // ignore this channel
        {
            sprintf(OutString, "ChanSel=      skip \r\n");
            OutString[12] = ChanSel + 0x31;  //start at 1 not 0
            putsConsole(OutString);
            ChanTime = 0;
        }
        else
        {
            sprintf(OutString, "ChanSel=     ");
            OutString[10] = ChanSel + 0x31;  //start at 1 not 0
            putsConsole(OutString);
            temp2 = ChanTime %10;
            temp3 = (ChanTime - temp2)/10;
            sprintf(OutString, "ChanTime=     ");
            OutString[10] = temp3 + 0x30;
            OutString[11] = temp2 + 0x30;
            putsConsole(OutString);
           while (ChanTime < Channel[jloop])
             {
               LED_D3 = 0;
               LED_D4 = 0;
               LED_D5 = 0;
               LED_D6 = 0;
               LED_D7 = 0;
               LED_D8 = 0;
               LED_D9 = 0;
               if (ChanSel == 0) LED_D3 = 1;
               if (ChanSel == 1) LED_D4 = 1;
               if (ChanSel == 2) LED_D5 = 1;
               if (ChanSel == 3) LED_D6 = 1;
               if (ChanSel == 4) LED_D7 = 1;
               if (ChanSel == 5) LED_D8 = 1;
               if (ChanSel == 6) LED_D9 = 1;
               Delayms(1000);  // the 1 second count
               ChanTime++;
               sprintf(OutString, "   ");
               temp2 = ChanTime %10;
               temp3 = (char) ((ChanTime - temp2) /10);
               OutString[0] = temp3 + 0x30;
               OutString[1] = temp2 + 0x30;
               putsConsole(OutString);
             }
               LED_D3 = 0;
               LED_D4 = 0;
               LED_D5 = 0;
               LED_D6 = 0;
               LED_D7 = 0;
               LED_D8 = 0;
               LED_D9 = 0;
           }  //  big else
        }  // main jloop
    }  // MsgSame if statement

  // ***************************************************






    } // big iloop of 25 passes

  return 0;
} // main
Beispiel #25
0
void UnitCfg::QueryResponse (QObject *p, const QString &c, int State, QObject*caller) // notify transaction completerequestrt needs the name record addedivityLled int2);, tion text,repprint int2);ate text);
{
	if(p != this) return;

	IT_IT("UnitCfg::QueryResponse");

	switch (State)
	{
		case tList:
		{
			// fill the name list box
			GetConfigureDb ()->FillComboBox (Name, "NAME");
			Name->setCurrentItem (0);
			SelChanged (0);
			Name->setFocus ();
			ButtonState (true);
		};
		break;
		case tItem:
		{
			IT_COMMENT("Received User Data");
			// fill the fields     
			Comment->setText (UndoEscapeSQLText(GetConfigureDb()->GetString ("COMMENT")));
			SetComboItem (UnitType, GetConfigureDb ()->GetString ("UNITTYPE"));
			Enabled->setChecked (GetConfigureDb ()->GetString ("ENABLED").toInt ());
			Comment->setFocus ();
			ButtonState (true);
		};
		break;
		case tDrop:
		{
			int n = GetConfigureDb()->GetNumberResults();
			
			QStringList list;
			QString point_list = "(";
			if (n)
			{
				for(int i = 0; i < n; i++,GetConfigureDb()->FetchNext())
				{
					if(i)
					{
						point_list += ",";
					};
					point_list += "'" + GetConfigureDb()->GetString("NAME") + "'";
					//
					list << GetConfigureDb()->GetString ("NAME");
				};

				point_list += ");";
			}

			QString cmd ="delete from TAGS_DB where NAME in " + point_list;
			GetCurrentDb ()->DoExec (0,cmd,0);
			//
			cmd ="delete from CVAL_DB where NAME in " + point_list;
			GetCurrentDb ()->DoExec (0,cmd,0);

			
			if(!list.isEmpty())
			{
				QStringList::Iterator it = list.begin();
				for(;it != list.end();++it)
				{
					QString cmd = "drop table "+ (*it) + ";";
					GetResultDb()->DoExec(0,cmd,0);
				}
			}

			//TO DO APA caricare tutti i Driver *p in un dizionario come fa il monitor
			//e poi usarli quando e' necessario
			Driver * p = FindDriver(UnitType->currentText());
			if(p)
			{
				DOAUDIT(tr("Drop Unit Tables:") + Name->currentText());
				p->DropAllSpecTables(list); // invoked the unit level drop tables 
			}

		}
		break;
		case tNew:
		case tDelete:
		case tApply:
		ButtonState (true);
		default:
		break;
	};
};
Beispiel #26
0
void AlarmGroupCfg::QueryResponse (QObject *p, const QString &, int State, QObject*caller) // notify transaction completerequestrt needs the name record addedaphpage int2, samples text);;dtod text,enddate text);
{
	if(p != this) return;

	IT_IT("AlarmGroupCfg::QueryResponse");

	switch (State)
	{
		case tList:
		{
			// fill the name list box
			GetConfigureDb ()->FillComboBox (Name, "NAME");
			Name->setCurrentItem (0);
			Name->setFocus ();
		};
		return;			// next step int he state machine
		case tListSPs:		// list sample points
		{
			GetConfigureDb ()->FillListBox (SamplePoints, "NAME");
			// now fill the dictionary
			SPD.clear ();
			for (unsigned i = 0; i < SamplePoints->count (); i++)
			{
				NameDict::value_type pr (SamplePoints->text (i), false);
				SPD.insert (pr);
			};
			//
			//
			ButtonState (true);
			SelChanged (0);
		};
		break;
		case tItem:
		{
			IT_COMMENT("Received User Data");

			if(GetConfigureDb()->GetNumberResults() > 0)
			{
				Comment->setText (UndoEscapeSQLText(GetConfigureDb()->GetString ("COMMENT")));
				// Now we read the image field and load up the Report List
				GroupList->clear ();
				QString s = GetConfigureDb ()->GetString ("SAMPLES");
				//
				// now extract the strings
				// 
				QTextIStream is (&s);
				int n = 0;		// how many names
				is >> n;
				//
				ClearSPD ();
				if (n > 0)
				{
					for (int i = 0; i < n; i++)
					{
						QString a;
						is >> a;
						a = a.stripWhiteSpace ();
						GroupList->insertItem (a);
						//
						// mark as in report list
						NameDict::iterator k = SPD.find (a);
						if (!(k == SPD.end()))
						{
							(*k).second = true;
						};
					};
				};
				//
				//
				Comment->setFocus ();
				ButtonState (true);
				//
				// set up the sample list
				// 
				NameDict::iterator j = SPD.begin ();
				SamplePoints->clear ();
				//
				for (; !(j == SPD.end()); j++)
				{
					if (!(*j).second)
					{
						SamplePoints->insertItem ((*j).first);
					};
				};
			};
			//
		};
		break;
		case tNew:
		case tDelete:
		case tApply:
		ButtonState (true);
		default:
		break;
	};
Beispiel #27
0
void ScheduleCfg::DoSelChange () // action the fetchangedorord record - we wan to avoid too much activityy from the properties table) text,enddate text);
{
	QString cmd = "select * from SCHEDULE where NAME='" + Name->currentText()+ "';";
	GetConfigureDb ()->DoExec (this,  cmd, tItem);	// lock the db and action the request
	ButtonState (false);
};
Beispiel #28
0
void ScheduleCfg::QueryResponse (QObject *p, const QString &c, int State, QObject*caller) // notify transaction completerequestrt needs the name record added8,repname text, action text,repprint int2);ate text);
{
	if(p != this) return;

	IT_IT("ScheduleCfg::QueryResponse");

	switch (State)
	{
		case tList:
		{
			// fill the name list box
			GetConfigureDb ()->FillComboBox (Name, "NAME");
			GetConfigureDb ()->DoneExec (this);
			Name->setCurrentItem (0);
			SelChanged (0);
			Name->setFocus ();
			//
		};
		break;
		case tItem:
		{
			
			IT_COMMENT("Received User Data");
						//
			// fill the fields 
			// 
			Comment->setText (UndoEscapeSQLText(GetConfigureDb()->GetString ("COMMENT")));
			FrequencyMode->setCurrentItem (GetConfigureDb ()->GetInt ("FREQMODE"));
			Time->setText (IntervalToString(GetConfigureDb ()->GetInt ("TOD")));
			SetComboItem (SamplePointList,
			GetConfigureDb ()->GetString ("TRIGGERPOINT"));
			RelOp->setCurrentItem (GetConfigureDb ()->GetInt ("RELOP"));
			//
			TagList->clear ();
			TagList->insertItem (GetConfigureDb ()->GetString ("TRIGGERTAG"));
			//
			// we should now fetch the tag list for the selected trigger point
			// 
			TriggerValue->setText (GetConfigureDb ()->GetString ("TRIGGERVAL"));
			//
			SetComboItem (ReportList, GetConfigureDb ()->GetString ("REPNAME"));
			//
			PrintReport->setChecked (GetConfigureDb ()->GetBool ("REPPRINT"));
			//
			// Get the action string
			//
			Action->setText(GetConfigureDb ()->GetString("ACTIONS"));
			SetComboItem(ReceipeList,GetConfigureDb()->GetString("RECEIPE"));
			//
			Comment->setFocus ();
			ButtonState (true);
			//
			SpChanged(0);
			//
		};
		return;
		case tTagList:		// 
		{
			QString s = TagList->currentText ();	// should have been set
			TagList->clear ();
			GetConfigureDb ()->FillComboBox (TagList, "TAG");
			//
			if (GetConfigureDb ()->GetNumberResults () > 0)
			{
				SetComboItem (TagList, s);	// put it back as it was
			}
			else
			{
				TagList->insertItem (tr(NONE_STR));
			};
			//
			GetConfigureDb ()->DoneExec (this);	// all done so release
		};
		break;
		case tReportList:		// get the list of reports
		{
			GetConfigureDb ()->FillComboBox (ReportList, "NAME");
			ReportList->insertItem(tr(NONE_STR));
			SetComboItem(ReportList,tr(NONE_STR));
		};
		break;
		case tSamplePointList:	//
		{
			GetConfigureDb ()->FillComboBox (SamplePointList, "NAME");
			SamplePointList->insertItem (tr(NONE_STR));	// the null choice
			SetComboItem(SamplePointList,tr(NONE_STR));
			ButtonState (true);	// the basic field are all set up now
			SelChanged (0);		// get the top of the list - load up first record
		};
		break;
		case tReceipeList:
		{
			GetConfigureDb ()->FillComboBox (ReceipeList, "NAME");
			ReceipeList->insertItem (tr(NONE_STR));	// the null choice
		};
		break;
		case tDelete:
		case tNew:
		case tApply:
		ButtonState (true);
		default:
		break;
	};
};
void TrackSelectionState::Init()
{
   if (m_state.midi_out) m_state.midi_out->Reset();

   Midi &m = *m_state.midi;

   // Prepare a very simple count of the playable tracks first
   int track_count = 0;
   for (size_t i = 0; i < m.Tracks().size(); ++i)
   {
      if (m.Tracks()[i].Notes().size()) track_count++;
   }

   m_back_button = ButtonState(Layout::ScreenMarginX,
      GetStateHeight() - Layout::ScreenMarginY/2 - Layout::ButtonHeight/2,
      Layout::ButtonWidth, Layout::ButtonHeight);

   m_continue_button = ButtonState(GetStateWidth() - Layout::ScreenMarginX - Layout::ButtonWidth,
      GetStateHeight() - Layout::ScreenMarginY/2 - Layout::ButtonHeight/2,
      Layout::ButtonWidth, Layout::ButtonHeight);

   // Determine how many track tiles we can fit
   // horizontally and vertically. Integer division
   // helps us round down here.
   int tiles_across = (GetStateWidth() + Layout::ScreenMarginX) / (TrackTileWidth + Layout::ScreenMarginX);
   tiles_across = std::max(tiles_across, 1);

   int tiles_down = (GetStateHeight() - Layout::ScreenMarginX - Layout::ScreenMarginY * 2) / (TrackTileHeight + Layout::ScreenMarginX);
   tiles_down = std::max(tiles_down, 1);

   // Calculate how many pages of tracks there will be
   m_tiles_per_page = tiles_across * tiles_down;

   m_page_count        = track_count / m_tiles_per_page;
   const int remainder = track_count % m_tiles_per_page;
   if (remainder > 0) m_page_count++;

   // If we have fewer than one row of tracks, just
   // center the tracks we do have
   if (track_count < tiles_across) tiles_across = track_count;

   // Determine how wide that many track tiles will
   // actually be, so we can center the list
   int all_tile_widths = tiles_across * TrackTileWidth + (tiles_across-1) * Layout::ScreenMarginX;
   int global_x_offset = (GetStateWidth() - all_tile_widths) / 2;

   const static int starting_y = 100;

   int tiles_on_this_line = 0;
   int tiles_on_this_page = 0;
   int current_y = starting_y;
   for (size_t i = 0; i < m.Tracks().size(); ++i)
   {
      const MidiTrack &t = m.Tracks()[i];
      if (t.Notes().size() == 0) continue;

      int x = global_x_offset + (TrackTileWidth + Layout::ScreenMarginX)*tiles_on_this_line;
      int y = current_y;

      Track::Mode mode = Track::ModePlayedAutomatically;
      if (t.IsPercussion()) mode = Track::ModePlayedButHidden;

      Track::TrackColor color = static_cast<Track::TrackColor>((m_track_tiles.size()) % Track::UserSelectableColorCount);

      // If we came back here from StatePlaying, reload all our preferences
      if (m_state.track_properties.size() > i)
      {
         color = m_state.track_properties[i].color;
         mode = m_state.track_properties[i].mode;
      }

      TrackTile tile(x, y, i, color, mode);

      m_track_tiles.push_back(tile);


      tiles_on_this_line++;
      tiles_on_this_line %= tiles_across;
      if (!tiles_on_this_line)
      {
         current_y += TrackTileHeight + Layout::ScreenMarginX;
      }

      tiles_on_this_page++;
      tiles_on_this_page %= m_tiles_per_page;
      if (!tiles_on_this_page)
      {
         current_y = starting_y;
         tiles_on_this_line = 0;
      }
   }
}
Beispiel #30
0
void UserCfgDlg::QueryResponse (QObject *p, const QString &c, int State, QObject*caller) // notify transaction completerequestrt needs the name record addedivityLled int2);, tion text,repprint int2);ate text);
{
	if(p != this) return;

	IT_IT("UserCfgDlg::QueryResponse");

	switch (State)
	{
		case tList:
		{
			// fill the name list box
			GetConfigureDb ()->FillComboBox (Name, "NAME");
			GetConfigureDb ()->DoneExec (this);
			Name->setCurrentItem (0);
			SelChanged (0);
			Name->setFocus ();
			ButtonState (true);
		};
		break;
		case tItem:
		{
			IT_COMMENT("Received User Data");
			
			// fill the fields     
			Password->setText (tr(NONE_STR)); // we set the password to tr(NONE_STR). If it changes we save it otherwise leave it alone
			Comment->setText (UndoEscapeSQLText(GetConfigureDb()->GetString ("COMMENT")));
			SetComboItem (Language, GetConfigureDb ()->GetString ("LANGUAGE"));
			//
			// get the privs 
			// 
			int p = GetConfigureDb ()->GetString ("PRIVS").toInt ();
			//
			AllPriv->setChecked (0);
			ReportsPriviledge->setChecked (0);
			AlarmAckPriv->setChecked (0);
			ReportsPriv->setChecked (0);
			AgePassword->setChecked(0);
			FactoryAdministrator->setChecked(0);
			ExitApp->setChecked(0);
			AgeDays->setValue(GetConfigureDb ()->GetInt("EXPIREDAYS"));
			if (p == (int) PRIVS_ALL)
			{
				AllPriv->setChecked (true);
				AllChanged (true);
			}
			else
			{
				AllChanged (false);	// mark as not all privs
				ReportsPriviledge->setChecked (p & PRIVS_REPORTS);
				AlarmAckPriv->setChecked (p & PRIVS_ACK_ALARMS);
				ReportsPriv->setChecked (p & PRIVS_REPORT_MAKE);
				AgePassword->setChecked (p & PRIVS_AGE_PASSWORD);
				FactoryAdministrator->setChecked (p & PRIVS_FACTORY_ADMIN);
				ExitApp->setChecked(p & PRIVS_CAN_EXIT);
			};
			Password->setFocus ();
			ButtonState (true);
		};
		break;
		case tDelete:
		case tNew:
		case tApply:
		ButtonState (true);
		default:
		break;
	};
};