示例#1
0
void ADAFRUITBLE::loadConfiguration() {
    BLEConfiguration *config = (BLEConfiguration *)getConfiguration();

    if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
        Logger::debug(ADABLUE, "Valid checksum so using stored BLE config values");
//		prefsHandler->read(EESYS_WIFI0_SSID, &config->ssid);
    }
}
示例#2
0
void ELM327Emu::saveConfiguration()
{
    ELM327Configuration *config = (ELM327Configuration *) getConfiguration();

    //TODO: implement processing of config params for WIFI
//  prefsHandler->write(EESYS_WIFI0_SSID, config->ssid);
    prefsHandler->saveChecksum();
}
void PlayerImplClient::handleNotification( const yaf3d::EntityNotification& notification )
{
    // handle some notifications
    switch( notification.getId() )
    {
        case YAF3D_NOTIFY_MENU_ENTER:

            if ( !_isRemoteClient )
            {
                getChatManager()->show( false );
                _p_inputHandler->setMenuEnabled( true );

                // reset player's movement and sound
                _p_playerPhysics->stopMovement();
                _p_playerAnimation->animIdle();
                if ( _p_playerSound )
                    _p_playerSound->stopPlayingAll();

                // very important: diable the camera when we enter menu!
                _p_camera->setEnable( false );

                // players are all rendered in menu, regardless their camera mode
                _p_playerAnimation->enableRendering( true );
            }
            break;

        case YAF3D_NOTIFY_MENU_LEAVE:
        {
            if ( !_isRemoteClient )
            {
                getChatManager()->show( true );
                _p_inputHandler->setMenuEnabled( false );

                // refresh our configuration settings
                getConfiguration();

                // very important: enable the camera when we leave menu!
                _p_camera->setEnable( true );

                // if we are in ego mode then disable player avatar rendering
                if ( _cameraMode == Ego )
                    _p_playerAnimation->enableRendering( false );
            }
        }
        break;

        case YAF3D_NOTIFY_SHUTDOWN:
        case YAF3D_NOTIFY_UNLOAD_LEVEL:
        {
            // destroy the chat manager
            destroyChatManager();
        }
        break;

        default:
            ;
    }
}
示例#4
0
文件: CLog.cpp 项目: gg-uah/GARouter
//...................................................... constructor and destructor ...
CLog::CLog(const string & logConfig,
		   const string & dumpConfig) {
	// Resolve the log and dump configuration path names
	__logConfig  = EnvironmentUtil::transformString(logConfig, _ISWIN32);
	__dumpConfig = EnvironmentUtil::transformString(dumpConfig, _ISWIN32);

    //Read the configuration file
    getConfiguration(__logConfig);
}
 std::shared_ptr<ACSACR1222LReaderUnitConfiguration> ACSACR1222LReaderUnit::getACSACR1222LConfiguration()
 {
     auto cfg = std::dynamic_pointer_cast<ACSACR1222LReaderUnitConfiguration>(getConfiguration());
     if (!cfg)
     {
         LOG(WARNINGS) << "Requested ACSACR1222L ReaderUnit Configuration but type mismatch";
     }
     return cfg;
 }
示例#6
0
void ELM327Emu::loadConfiguration() {
	ELM327Configuration *config = (ELM327Configuration *)getConfiguration();

	if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
		Logger::debug(ELM327EMU, "Valid checksum so using stored elm327 emulator config values");
		//TODO: implement processing of config params for WIFI
//		prefsHandler->read(EESYS_WIFI0_SSID, &config->ssid);
	}
}
示例#7
0
Router::Router(char* name, char* conf)
{
	_isRunning = true;
    _name = new std::string(name);
    seqnum = 0;

   	// * * * * lecture fichier config * * * *
	config = config__readRouter(conf);

	exec = new Exec(this);
	paction = new PromptActions(this);
	saction = new SockActions(this);
	glob__router = this;

	init(); // windows compatibility

	std::chrono::seconds controllerTimeout( getConfiguration()->controllerUpdateInterval );

	// * * * * ouverture serveur * * * *
	net = network__open(config->routerPort);

	// * * * * evenements * * * *
	net->input_event =  Event::input;
	net->connection_event = Event::connect;
	net->disconnection_event = Event::disconnect;
	net->message_event = Event::message;

	// * * * * connexion sortante * * * *
	do
	{
		std::cout << "Connection to controller : "<< config->controllerAddress << ":" << config->controllerPort << std::endl;
		controller = network__connect(net, config->controllerAddress, config->controllerPort);
		if(!controller)
			std::this_thread::sleep_for(controllerTimeout);
	} while(!controller);


	strcpy(controller->id, "controlleur");
	std::cout << "Connected on socket " << controller->sock << std::endl;

	sockActions()->login(config->routerPort, name);


	// * * * * gestion stdin   * * * *
	void (Exec::*meth)(Message* m) = &Exec::prompt_message;
	prompt.start(exec, meth);

	// début
	runControllerLoop = true;
	runRouterLoop = true;
	runMainLoop = true;

	mainLoopThread = new std::thread(&Router::mainLoop, this);
	controllerLoopThread = new std::thread(&Router::controllerLoop, this);
	routerLoopThread = new std::thread(&Router::routerLoop, this);
}
示例#8
0
/**
 * Load configuration.
 */
void ServerContextImpl::loadConfiguration()
{
    Configuration::shared_pointer config = getConfiguration();

    // TODO for now just a simple switch
    int32 debugLevel = config->getPropertyAsInteger(PVACCESS_DEBUG, 0);
    if (debugLevel > 0)
        SET_LOG_LEVEL(logLevelDebug);

    // TODO multiple addresses
    _ifaceAddr.ia.sin_family = AF_INET;
    _ifaceAddr.ia.sin_addr.s_addr = htonl(INADDR_ANY);
    _ifaceAddr.ia.sin_port = 0;
    config->getPropertyAsAddress("EPICS_PVAS_INTF_ADDR_LIST", &_ifaceAddr);

    _beaconAddressList = config->getPropertyAsString("EPICS_PVA_ADDR_LIST", _beaconAddressList);
    _beaconAddressList = config->getPropertyAsString("EPICS_PVAS_BEACON_ADDR_LIST", _beaconAddressList);

    _autoBeaconAddressList = config->getPropertyAsBoolean("EPICS_PVA_AUTO_ADDR_LIST", _autoBeaconAddressList);
    _autoBeaconAddressList = config->getPropertyAsBoolean("EPICS_PVAS_AUTO_BEACON_ADDR_LIST", _autoBeaconAddressList);

    _beaconPeriod = config->getPropertyAsFloat("EPICS_PVA_BEACON_PERIOD", _beaconPeriod);
    _beaconPeriod = config->getPropertyAsFloat("EPICS_PVAS_BEACON_PERIOD", _beaconPeriod);

    _serverPort = config->getPropertyAsInteger("EPICS_PVA_SERVER_PORT", _serverPort);
    _serverPort = config->getPropertyAsInteger("EPICS_PVAS_SERVER_PORT", _serverPort);
    _ifaceAddr.ia.sin_port = htons(_serverPort);

    _broadcastPort = config->getPropertyAsInteger("EPICS_PVA_BROADCAST_PORT", _broadcastPort);
    _broadcastPort = config->getPropertyAsInteger("EPICS_PVAS_BROADCAST_PORT", _broadcastPort);

    _receiveBufferSize = config->getPropertyAsInteger("EPICS_PVA_MAX_ARRAY_BYTES", _receiveBufferSize);
    _receiveBufferSize = config->getPropertyAsInteger("EPICS_PVAS_MAX_ARRAY_BYTES", _receiveBufferSize);

    _channelProviderNames = config->getPropertyAsString("EPICS_PVA_PROVIDER_NAMES", _channelProviderNames);
    _channelProviderNames = config->getPropertyAsString("EPICS_PVAS_PROVIDER_NAMES", _channelProviderNames);

    //
    // introspect network interfaces
    //

    SOCKET sock = epicsSocketCreate(AF_INET, SOCK_STREAM, 0);
    if (!sock) {
        THROW_BASE_EXCEPTION("Failed to create a socket needed to introspect network interfaces.");
    }

    if (discoverInterfaces(_ifaceList, sock, &_ifaceAddr))
    {
        THROW_BASE_EXCEPTION("Failed to introspect network interfaces.");
    }
    else if (_ifaceList.size() == 0)
    {
        THROW_BASE_EXCEPTION("No (specified) network interface(s) available.");
    }
    epicsSocketDestroy(sock);
}
示例#9
0
/** \brief
 */
void Router::controllerLoop()
{
	std::chrono::seconds poll_time(getConfiguration()->controllerUpdateInterval );
	std::this_thread::sleep_for(std::chrono::seconds(1));
	while(runControllerLoop)
	{
		sockActions()->poll();
		std::this_thread::sleep_for(poll_time); // j'aime quand on peut lire le code
	}
}
示例#10
0
void CanPIDListener::loadConfiguration()
{
    CanPIDConfiguration *config = (CanPIDConfiguration *) getConfiguration();

    if (!config) { // as lowest sub-class make sure we have a config object
        config = new CanPIDConfiguration();
        setConfiguration(config);
    }

    Device::loadConfiguration(); // call parent
    Logger::info(this, "CAN PID listener configuration:");

#ifdef USE_HARD_CODED

    if (false) {
#else

    if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
#endif
        //prefsHandler->write(EE_, &config->pidId);
        //prefsHandler->write(EE_, &config->pidMask);
    } else { //checksum invalid. Reinitialize values and store to EEPROM
        config->pidId = 0x200;
        config->pidMask = 0x7ff;
        saveConfiguration();
    }

    Logger::info(this, "pid: %d pid mask: %d", config->pidId, config->pidMask);
}

/*
 * Store the current configuration to EEPROM
 */
void CanPIDListener::saveConfiguration()
{
    CanPIDConfiguration *config = (CanPIDConfiguration *) getConfiguration();

    Device::saveConfiguration(); // call parent

    //prefsHandler->write(EE_, config->pidId);
    //prefsHandler->write(EE_, config->pidMask);
    prefsHandler->saveChecksum();
}
示例#11
0
void DCDCController::loadConfiguration() {
	DCDCConfiguration *config = (DCDCConfiguration *)getConfiguration();

	if (!config) {
		config = new DCDCConfiguration();
		setConfiguration(config);
	}

	Device::loadConfiguration(); // call parent
}
示例#12
0
void CanPIDListener::loadConfiguration() {
	CanPIDConfiguration *config = (CanPIDConfiguration *) getConfiguration();

	if (!config) { // as lowest sub-class make sure we have a config object
		config = new CanPIDConfiguration();
		setConfiguration(config);
	}

	Device::loadConfiguration(); // call parent

#ifdef USE_HARD_CODED
	if (false) {
#else
	if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
#endif
		Logger::debug(PIDLISTENER, (char *)Constants::validChecksum);
		//prefsHandler->read(EETH_MIN_ONE, &config->minimumLevel1);
		//prefsHandler->read(EETH_MAX_ONE, &config->maximumLevel1);
		//prefsHandler->read(EETH_CAR_TYPE, &config->carType);
	} else { //checksum invalid. Reinitialize values and store to EEPROM
		Logger::warn(PIDLISTENER, (char *)Constants::invalidChecksum);
		//config->minimumLevel1 = Throttle1MinValue;
		//config->maximumLevel1 = Throttle1MaxValue;
		//config->carType = Volvo_S80_Gas;
		saveConfiguration();
	}
	//Logger::debug(CANACCELPEDAL, "T1 MIN: %l MAX: %l Type: %d", config->minimumLevel1, config->maximumLevel1, config->carType);
}

/*
 * Store the current configuration to EEPROM
 */
void CanPIDListener::saveConfiguration() {
	CanPIDConfiguration *config = (CanPIDConfiguration *) getConfiguration();

	Device::saveConfiguration(); // call parent

	//prefsHandler->write(EETH_MIN_ONE, config->minimumLevel1);
	//prefsHandler->write(EETH_MAX_ONE, config->maximumLevel1);
	//prefsHandler->write(EETH_CAR_TYPE, config->carType);
	//prefsHandler->saveChecksum();
}
示例#13
0
void turnHeatOff() {
	DBG("Turn Heat Off\n");

	Control* control = getControl();
	control->mode = MODE_HEAT_OFF;

	lockSteps();

	Configuration * cfg = getConfiguration();
	if (cfg != NULL) {
		BreweryLayout * bl = cfg->brewLayout;
		if (bl != NULL && bl->tanks.data != NULL) {
			Tank * tA = (Tank *) bl->tanks.data;
			for (int tankIndex = 0; tankIndex < bl->tanks.count; tankIndex++) {
				Tank * t = &tA[tankIndex];
				if (t->heater != NULL) {
					// Found a heater element. Turn it off.
					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++) {
							ControlPoint * cp = &cs->controlPoints[cpIndex];
							if (cp->controlIo == t->heater->io) {
								setHeatOn(&cp->dutyController, false);
							}
						}
					}
				}
			}
		}
		// Turn pumps on if manual.  Off otherwise
		if (bl != NULL && bl->pumps.data != NULL) {
			Pump * pA = (Pump *) bl->pumps.data;
			for (int pumpIndex = 0; pumpIndex < bl->pumps.count; pumpIndex++) {
				Pump * p = &pA[pumpIndex];
				// Found a heater element. Turn it off.
				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++) {
						ControlPoint * cp = &cs->controlPoints[cpIndex];
						if (cp->controlIo == p->io) {
							if (cp->automaticControl) {
								setHeatOn(&cp->dutyController, false);
							} else {
								setHeatOn(&cp->dutyController, true);
							}
						}
					}
				}
			}
		}
	}
	unlockSteps();

}
示例#14
0
void addManualStep() {
	Configuration * cfg = getConfiguration();
	if (cfg != NULL) {

		DBG("Create new Manual Step\n");
		ControlStep * step = &controlSteps[0];
		step->stepTime = 0;
		step->active = false;
		sprintf(step->name, "Manual Step");

		char * stepId = generateRandomId();
		sprintf(step->id, "%s", stepId);
		free(stepId);

		step->controlPointCount = 0;
		BreweryLayout * bl = cfg->brewLayout;
		if (bl != NULL && bl->tanks.data != NULL) {
			Tank * tA = (Tank *) bl->tanks.data;
			for (int tankIndex = 0; tankIndex < bl->tanks.count; tankIndex++) {
				Tank * t = &tA[tankIndex];
				if (t->heater != NULL) {
					ControlPoint * cp = &step->controlPoints[step->controlPointCount];
					cp->controlIo = t->heater->io;
					cp->automaticControl = false;
					cp->duty = 0;
					cp->fullOnAmps = t->heater->fullOnAmps;
					cp->hasDuty = t->heater->hasDuty;
					cp->initComplete = false;
					setupControlPoint(cp);
					step->controlPointCount++;

					DBG("Setup control point for io %d\n",cp->controlIo);

				}
			}

			Pump * pA = (Pump *) bl->pumps.data;
			for (int pumpIndex = 0; pumpIndex < bl->pumps.count; pumpIndex++) {
				Pump * p = &pA[pumpIndex];
				ControlPoint * cp = &step->controlPoints[step->controlPointCount];
				cp->controlIo = p->io;
				cp->automaticControl = false;
				cp->duty = 0;
				cp->fullOnAmps = 0;
				cp->hasDuty = p->hasDuty;
				cp->initComplete = false;
				setupControlPoint(cp);
				step->controlPointCount++;
			}
		}
		stepCount = 1;
	}

}
void CodaMotorController::loadConfiguration() {
	CodaMotorControllerConfiguration *config = (CodaMotorControllerConfiguration *)getConfiguration();

	if (!config) {
		config = new CodaMotorControllerConfiguration();
		setConfiguration(config);
	}

	MotorController::loadConfiguration(); // call parent

}
示例#16
0
/*
 * Overrides the standard implementation of throttle mapping as different rules apply to
 * brake based regen.
 */
int16_t PotBrake::mapPedalPosition(int16_t pedalPosition) {
	ThrottleConfiguration *config = (ThrottleConfiguration *) getConfiguration();
	int16_t brakeLevel, range;

	range = config->maximumRegen - config->minimumRegen;
	brakeLevel = -10 * range * pedalPosition / 1000;
	brakeLevel -= 10 * config->minimumRegen;
	//Logger::debug(POTBRAKEPEDAL, "level: %d", level);

	return brakeLevel;
}
示例#17
0
void ELM327Emu::loadConfiguration()
{
    ELM327Configuration *config = (ELM327Configuration *) getConfiguration();

    if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
        //TODO: implement processing of config params for WIFI
//      prefsHandler->read(EESYS_WIFI0_SSID, &config->ssid);
    } else {
        saveConfiguration();
    }
}
// reset resets the configuration
//
void Coordinator::reset() {

    if (getConfiguration()) {
        // reset the sound files
	    for (unsigned i = 0; i < sound.size(); i++) {
            if (sound[i]->relFileName() && 
    	     strcmp(soundFile((ModelSound)i), sound[i]->relFileName()))
		     sound[i]->change(soundFile((ModelSound)i));
        }
    }
}
示例#19
0
文件: main.cpp 项目: recreate/Bound
int main(int argc, char* argv[]) {
	struct config* cfg = getConfiguration();
	initSDL(cfg);
	
	initGLEW();
	
	init();
	mainLoop();
	
	cleanup();
	return 0;
}
void CodaMotorController::sendCmd1() 
{
	CodaMotorControllerConfiguration *config = (CodaMotorControllerConfiguration *)getConfiguration();
	
	CAN_FRAME output;
	output.length = 5;
	output.id = 0x204;
	output.extended = 0; //standard frame
	output.rtr = 0;
	output.data.bytes[0] = 0x00; //First byte is always zero.
      
	
      if(operationState==ENABLE)
        	{ 
        	  output.data.bytes[1] = 0x80; //1000 0000
        	}
        	else
        	 {
        	  output.data.bytes[1] = 0x40; //0100 0000
        	  }

        if(selectedGear==DRIVE) 
        	{
        		output.data.bytes[1] |= 0x20; //xx10 0000
        	 }
        	 else 
        	 	{
        	 	output.data.bytes[1] |= 0x10;//xx01 0000
        	 	}
        	 
        sequence+=1; //Increment sequence
		if (sequence==8){sequence=0;} //If we reach 8, go to zero
		output.data.bytes[1] |= sequence; //This should retain left four and add sequence count
										  //to right four bits.
        //Requested throttle is [-1000, 1000]
       //Two byte torque request in 0.1NM Can be positive or negative  
      
        torqueCommand=32128; //Set our zero offset value -torque=0
        torqueRequested = ((throttleRequested * config->torqueMax) / 1000); //Calculate torque request from throttle position x maximum torque 
        if(speedActual<config->speedMax){torqueCommand += torqueRequested;} //If actual rpm less than max rpm, add torque command to offset
          else {torqueCommand+= torqueRequested/2;}  //If at RPM limit, cut torque command in half.
        output.data.bytes[3] = (torqueCommand & 0xFF00) >> 8;  //Stow torque command in bytes 2 and 3.
        output.data.bytes[2] = (torqueCommand & 0x00FF);
        output.data.bytes[4] = genCodaCRC(output.data.bytes[1], output.data.bytes[2], output.data.bytes[3]); //Calculate security byte
            
	CanHandler::getInstanceEV()->sendFrame(output);  //Mail it.
        timestamp();

        Logger::debug("Torque command: %X   %X  ControlByte: %X  LSB %X  MSB: %X  CRC: %X  %d:%d:%d.%d",output.id, output.data.bytes[0],
output.data.bytes[1],output.data.bytes[2],output.data.bytes[3],output.data.bytes[4], hours, minutes, seconds, milliseconds);
          
}
/*
 * Send DMC_LIM message to the motor controller.
 *
 * This message controls the electrical limits in the controller.
 */
void BrusaMotorController::sendLimits() {
	BrusaMotorControllerConfiguration *config = (BrusaMotorControllerConfiguration *)getConfiguration();

	prepareOutputFrame(CAN_ID_LIMIT);
	outputFrame.data.bytes[0] = (config->dcVoltLimitMotor & 0xFF00) >> 8;
	outputFrame.data.bytes[1] = (config->dcVoltLimitMotor & 0x00FF);
	outputFrame.data.bytes[2] = (config->dcVoltLimitRegen & 0xFF00) >> 8;
	outputFrame.data.bytes[3] = (config->dcVoltLimitRegen & 0x00FF);
	outputFrame.data.bytes[4] = (config->dcCurrentLimitMotor & 0xFF00) >> 8;
	outputFrame.data.bytes[5] = (config->dcCurrentLimitMotor & 0x00FF);
	outputFrame.data.bytes[6] = (config->dcCurrentLimitRegen & 0xFF00) >> 8;
	outputFrame.data.bytes[7] = (config->dcCurrentLimitRegen & 0x00FF);

	CanHandler::getInstanceEV()->sendFrame(outputFrame);
}
/*
 * Send DMC_CTRL2 message to the motor controller.
 *
 * This message controls the mechanical power limits for motor- and regen-mode.
 */
void BrusaMotorController::sendControl2() {
	BrusaMotorControllerConfiguration *config = (BrusaMotorControllerConfiguration *)getConfiguration();

	prepareOutputFrame(CAN_ID_CONTROL_2);
	outputFrame.data.bytes[0] = ((config->torqueSlewRate * 10) & 0xFF00) >> 8;
	outputFrame.data.bytes[1] = ((config->torqueSlewRate * 10) & 0x00FF);
	outputFrame.data.bytes[2] = (config->speedSlewRate & 0xFF00) >> 8;
	outputFrame.data.bytes[3] = (config->speedSlewRate & 0x00FF);
	outputFrame.data.bytes[4] = (config->maxMechanicalPowerMotor & 0xFF00) >> 8;
	outputFrame.data.bytes[5] = (config->maxMechanicalPowerMotor & 0x00FF);
	outputFrame.data.bytes[6] = (config->maxMechanicalPowerRegen & 0xFF00) >> 8;
	outputFrame.data.bytes[7] = (config->maxMechanicalPowerRegen & 0x00FF);

	CanHandler::getInstanceEV()->sendFrame(outputFrame);
}
示例#23
0
void Project::createDefaultConfigs()
{
    for (int i = 0; i < 2; ++i)
    {
        addNewConfiguration (nullptr);
        BuildConfiguration config = getConfiguration (i);

        const bool debugConfig = i == 0;

        config.getName() = debugConfig ? "Debug" : "Release";
        config.isDebug() = debugConfig;
        config.getOptimisationLevel() = debugConfig ? 1 : 2;
        config.getTargetBinaryName() = getProjectFilenameRoot();
    }
}
示例#24
0
/*
 * Load the device configuration.
 * If possible values are read from EEPROM. If not, reasonable default values
 * are chosen and the configuration is overwritten in the EEPROM.
 */
void PotBrake::loadConfiguration() {
	PotBrakeConfiguration *config = new PotBrakeConfiguration();
	setConfiguration(config);

	// we deliberately do not load config via parent class here !

#ifdef USE_HARD_CODED
	if (false) {
#else
	if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
#endif
		prefsHandler->read(EETH_BRAKE_MIN, &config->minimumLevel1);
		prefsHandler->read(EETH_BRAKE_MAX, &config->maximumLevel1);
		prefsHandler->read(EETH_MAX_BRAKE_REGEN, &config->maximumRegen);
		prefsHandler->read(EETH_MIN_BRAKE_REGEN, &config->minimumRegen);
		prefsHandler->read(EETH_ADC_1, &config->AdcPin1);
          config->AdcPin1 = 2;
		Logger::debug(POTBRAKEPEDAL, "BRAKE MIN: %l MAX: %l", config->minimumLevel1, config->maximumLevel1);
		Logger::debug(POTBRAKEPEDAL, "Min: %l MaxRegen: %l", config->minimumRegen, config->maximumRegen);
	} else { //checksum invalid. Reinitialize values and store to EEPROM

		//these four values are ADC values
		//The next three are tenths of a percent
		config->maximumRegen = BrakeMaxRegenValue; //percentage of full power to use for regen at brake pedal transducer
		config->minimumRegen = BrakeMinRegenValue;
		config->minimumLevel1 = BrakeMinValue;
		config->maximumLevel1 = BrakeMaxValue;
		config->AdcPin1 = BrakeADC;
		saveConfiguration();
	}
}

/*
 * Store the current configuration to EEPROM
 */
void PotBrake::saveConfiguration() {
	PotBrakeConfiguration *config = (PotBrakeConfiguration *) getConfiguration();

	// we deliberately do not save config via parent class here !

	prefsHandler->write(EETH_BRAKE_MIN, config->minimumLevel1);
	prefsHandler->write(EETH_BRAKE_MAX, config->maximumLevel1);
	prefsHandler->write(EETH_MAX_BRAKE_REGEN, config->maximumRegen);
	prefsHandler->write(EETH_MIN_BRAKE_REGEN, config->minimumRegen);
	prefsHandler->write(EETH_ADC_1, config->AdcPin1);
	prefsHandler->saveChecksum();
}
示例#25
0
void ProjectExporter::createDefaultConfigs()
{
    settings.getOrCreateChildWithName (Ids::CONFIGURATIONS, nullptr);

    for (int i = 0; i < 2; ++i)
    {
        addNewConfiguration (nullptr);
        BuildConfiguration::Ptr config (getConfiguration (i));

        const bool debugConfig = i == 0;

        config->getNameValue() = debugConfig ? "Debug" : "Release";
        config->isDebugValue() = debugConfig;
        config->getOptimisationLevel() = debugConfig ? optimisationOff : optimiseMinSize;
        config->getTargetBinaryName() = project.getProjectFilenameRoot();
    }
}
示例#26
0
FrameSource::FrameStatus OpenCVFrameSourceImpl::fetch(vx_image image, vx_uint32 timeout)
{
    cv::Mat frame;

    if (queue_.pop(frame, timeout))
    {
        vx_imagepatch_addressing_t image_addr;
        image_addr.dim_x = frame.cols;
        image_addr.dim_y = frame.rows;
        image_addr.stride_x = static_cast<vx_int32>(frame.channels());
        image_addr.stride_y = static_cast<vx_int32>(frame.step);
        image_addr.scale_x = image_addr.scale_y = VX_SCALE_UNITY;

        convertFrame(context_,
                     image,
                     getConfiguration(),
                     image_addr,
                     frame.data,
                     false,
                     devMem,
                     devMemPitch,
                     scaledImage);

        lastFrameTimestamp.tic();

        return OK;
    }
    else
    {
        if (alive_)
        {
            if ((lastFrameTimestamp.toc()/1000.0) > Application::get().getSourceDefaultTimeout())
            {
                close();
                return CLOSED;
            }
            else
                return TIMEOUT;
        }
        else
        {
            close();
            return CLOSED;
        }
    }
}
示例#27
0
void Router::routerLoop()
{
	std::chrono::seconds vect_time( getConfiguration()->routerUpdateInterval );
	std::this_thread::sleep_for(std::chrono::seconds(1));
	while(runRouterLoop)
	{
		for(RouteTable::iterator i = routeTable.begin(); i != routeTable.end(); i++)
		{
			if((*i).second.isNeighbor() && (*i).second.isComplete())
			{
				char * vect_str = routeTable.vector((*i).first);
				//std::cout << "\nici\n" << (*i).first << " " << (*i).second.client()->id << "\n";
				sockActions()->vector((char*) (*i).first.c_str(), vect_str);
			}
		}
		std::this_thread::sleep_for(vect_time);
	}
}
示例#28
0
bool ExtraRfbServers::reload(bool asService, RfbClientManager *mgr)
{
  Log::detail(_T("Considering to reload extra RFB servers"));

  Conf newConf;
  getConfiguration(&newConf);
  bool noConfigChanges = newConf.equals(&m_effectiveConf);
  bool enoughServers = (newConf.extraPorts.count() == m_servers.size());
  Log::detail(_T("Same Extra Ports configuration = %d, enough servers = %d"),
              (int)noConfigChanges, (int)enoughServers);

  if (noConfigChanges && enoughServers) {
    return true; 
  }

  Log::message(_T("Need to reconfigure extra RFB servers"));
  shutDown();
  return startUp(asService, mgr);
}
示例#29
0
/*
 * Convert the raw ADC values to a range from 0 to 1000 (per mille) according
 * to the specified range and the type of potentiometer.
 */
uint16_t PotBrake::calculatePedalPosition(RawSignalData *rawSignal) {
	PotBrakeConfiguration *config = (PotBrakeConfiguration *) getConfiguration();
	uint16_t calcBrake1, clampedLevel;

	if (config->maximumLevel1 == 0) //brake processing disabled if max is 0
		return 0;

	clampedLevel = constrain(rawSignal->input1, config->minimumLevel1, config->maximumLevel1);
	calcBrake1 = map(clampedLevel, config->minimumLevel1, config->maximumLevel1, (uint16_t) 0, (uint16_t) 1000);

	//This prevents flutter in the ADC readings of the brake from slamming regen on intermittently
	// just because the value fluttered a couple of numbers. This makes sure that we're actually
	// pushing the pedal. Without this even a small flutter at the brake will send minregen
	// out and ignore the accelerator. That'd be unpleasant.
	if (calcBrake1 < 15)
		calcBrake1 = 0;

	return calcBrake1;
}
/*
 * Send DMC_CTRL message to the motor controller.
 *
 * This message controls the power-stage in the controller, clears the error latch
 * in case errors were detected and requests the desired torque / speed.
 */
void BrusaMotorController::sendControl() {
	BrusaMotorControllerConfiguration *config = (BrusaMotorControllerConfiguration *)getConfiguration();
	prepareOutputFrame(CAN_ID_CONTROL);

	speedRequested = 0;
	torqueRequested = 0;

	outputFrame.data.bytes[0] = enablePositiveTorqueSpeed; // | enableNegativeTorqueSpeed;
	if (faulted) {
		outputFrame.data.bytes[0] |= clearErrorLatch;
	} else {
		if ((running || speedActual > 1000) && !getDigital(1)) { // see warning about field weakening current to prevent uncontrollable regen
			outputFrame.data.bytes[0] |= enablePowerStage;
		}
		if (running) {
			if (config->enableOscillationLimiter)
				outputFrame.data.bytes[0] |= enableOscillationLimiter;

			if (powerMode == modeSpeed) {
				outputFrame.data.bytes[0] |= enableSpeedMode;
				speedRequested = throttleRequested * config->speedMax / 1000;
				torqueRequested = config->torqueMax; // positive number used for both speed directions
			} else { // torque mode
				speedRequested = config->speedMax; // positive number used for both torque directions
				torqueRequested = throttleRequested * config->torqueMax / 1000;
			}

			// set the speed in rpm
			outputFrame.data.bytes[2] = (speedRequested & 0xFF00) >> 8;
			outputFrame.data.bytes[3] = (speedRequested & 0x00FF);

			// set the torque in 0.01Nm (GEVCU uses 0.1Nm -> multiply by 10)
			outputFrame.data.bytes[4] = ((torqueRequested * 10) & 0xFF00) >> 8;
			outputFrame.data.bytes[5] = ((torqueRequested * 10) & 0x00FF);
		}
	}

	if (Logger::isDebug())
		Logger::debug(BRUSA_DMC5, "requested Speed: %l rpm, requested Torque: %f Nm", speedRequested, (float)torqueRequested/10.0F);

	CanHandler::getInstanceEV()->sendFrame(outputFrame);
}