Ejemplo n.º 1
0
    static void
    load_cc ()
    {
      path::paths parts;
      std::string rtems_pkgconfig;
      std::string bsp;

      if (_path.empty ())
        throw rld::error ("Not set", "RTEMS path");

      bsp = rtems_arch_bsp ();

      parts.push_back ("lib");
      parts.push_back ("pkgconfig");

      rld::path::path_join (path (), parts, rtems_pkgconfig);

      if (!path::check_directory (rtems_pkgconfig))
        throw rld::error ("Invalid RTEMS path", path ());

      rld::path::path_join (rtems_pkgconfig, bsp + ".pc", rtems_pkgconfig);

      if (!path::check_file (rtems_pkgconfig))
        throw rld::error ("RTEMS BSP not found", arch_bsp ());

      if (rld::verbose () >= RLD_VERBOSE_INFO)
        std::cout << " rtems: " << _arch_bsp << ": "
                  << rtems_pkgconfig << std::endl;

      pkgconfig::package pkg (rtems_pkgconfig);

      /*
       * Check the pc file matches what we ask for.
       */
      std::string name;
      if (!pkg.get ("name", name))
        throw rld::error ("RTEMS BSP no name in pkgconfig file", _arch_bsp);

      if (name != bsp)
        throw rld::error ("RTEMS BSP does not match the name in pkgconfig file",
                          _arch_bsp);

      std::string flags;

      if (pkg.get ("CPPFLAGS", flags))
      {
        rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_cppflags);
        if (rld::verbose () >= RLD_VERBOSE_INFO)
          std::cout << " rtems: " << arch_bsp ()
                    << ": CPPFLAGS="
                    << rld::cc::get_flags (rld::cc::ft_cppflags)
                    << std::endl;
      }

      if (pkg.get ("CFLAGS", flags))
      {
        rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_cflags);
        if (rld::verbose () >= RLD_VERBOSE_INFO)
        {
          std::cout << " rtems: " << arch_bsp ()
                    << ": CFLAGS=" << rld::cc::get_flags (rld::cc::ft_cflags)
                    << std::endl;
          std::cout << " rtems: " << _arch_bsp
                    << ": WARNINGS=" << rld::cc::get_flags (rld::cc::fg_warning_flags)
                    << std::endl;
          std::cout << " rtems: " << arch_bsp ()
                    << ": INCLUDES=" << rld::cc::get_flags (rld::cc::fg_include_flags)
                    << std::endl;
          std::cout << " rtems: " << arch_bsp ()
                    << ": MACHINES=" << rld::cc::get_flags (rld::cc::fg_machine_flags)
                    << std::endl;
          std::cout << " rtems: " << arch_bsp ()
                    << ": SPECS=" << rld::cc::get_flags (rld::cc::fg_spec_flags)
                    << std::endl;
        }
      }

      if (pkg.get ("CXXFLAGS", flags))
      {
        rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_cxxflags);
        if (rld::verbose () >= RLD_VERBOSE_INFO)
          std::cout << " rtems: " << arch_bsp ()
                    << ": CXXFLAGS=" << rld::cc::get_flags (rld::cc::ft_cxxflags)
                    << std::endl;
      }

      if (pkg.get ("LDFLAGS", flags))
      {
        rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_ldflags);
        if (rld::verbose () >= RLD_VERBOSE_INFO)
          std::cout << " rtems: " << arch_bsp ()
                    << ": LDFLAGS=" << rld::cc::get_flags (rld::cc::ft_ldflags)
                    << std::endl;
      }

      rld::cc::set_exec_prefix (arch ());
    }
Ejemplo n.º 2
0
void CPigeonServerMtm::DoStartCommandL(CMsvEntrySelection& aSelection, TSchSendTestOperation aCommand, const TDesC8& aParameter, TRequestStatus& aStatus)
{

    if(iHeapFailure)
        __UHEAP_FAILNEXT(iNextFailure++);
    else
        __UHEAP_RESET;

    TMsvSchedulePackage package;
    package.iCommandId = ESendScheduledL;
    package.iParameter = aParameter;

    switch(aCommand)
    {
    case EOpFail:
    {
        TPckgC<TInt> pkg(0);
        pkg.Set(aParameter);
        User::Leave(pkg());
    }
    break;
    case EScheduleOpFail:
    {
        package.iCommandId = EOpFail;
        //pass through
    }
    case EScheduleAllL:
    {
        iScheduleSend->ScheduleL(aSelection, package);
        UpdateProgressL(aSelection);
    }
    break;
    case EReScheduleRetryAllL:
    {
        // Change the iCommandId to do a re-schedule
        package.iCommandId = EReScheduleRetryAllL;
        iScheduleSend->ReScheduleL(aSelection, package);
        UpdateProgressL(aSelection);

        // Bit of a hack here!! Check the selection to see if the messages
        // have been re-scheduled. If they have not been re-scheduled, then
        // copy to the Sent folder...
        for( TInt i=0; i<aSelection.Count(); ++i )
        {
            User::LeaveIfError(iServerEntry->SetEntry(aSelection[i]));
            TMsvEntry entry = iServerEntry->Entry();

            if( entry.SendingState() == KMsvSendStateWaiting )
            {
                User::LeaveIfError(iServerEntry->SetEntry(KMsvSentEntryId));
                User::LeaveIfError(iServerEntry->CreateEntry(entry));
            }
        }
        User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId));
    }
    break;
    case EReScheduleAllL:
    {
        // Pass through action to be performed on reschedule. (Default is to do nothing.)
        TMsvSendErrorAction laterAction;
        laterAction.iAction = ESendActionRetryImmediately;
        laterAction.iRetries = ESendRetriesFixed;
        laterAction.iRetrySpacing = ESendRetrySpacingStatic;

        iScheduleSend->ReScheduleL(aSelection, package, &laterAction);
        UpdateProgressL(aSelection);
    }
    break;
    case EDeleteScheduleL:
    {
        iScheduleSend->DeleteScheduleL(aSelection);
    }
    break;
    case ESendScheduledL:
    {
        SendScheduledL(aSelection, aCommand, aParameter, aStatus);
    }
    break;
    case ECheckScheduleL:
    {
        iScheduleSend->CheckScheduleL(aSelection);
    }
    break;
    case ESetRetryImmediately:
    case ESetRetryLater:
    case ESetRetryVariable:
    case ESetNoRetry:
    {
        iScheduleSend->SetupL(aCommand);

        CRepository* repository = CRepository::NewLC(KUidMsgTypePigeon);
        iScheduleSend->SaveSysAgentActionsL(*repository);
        CleanupStack::PopAndDestroy(repository);
    }
    break;
    case ESetNowOffPeak:
    case ESetNowNotOffPeak:
    case ESetFirstOffPeakBest:
    case ESetLastOffPeakBest:
    {
        iScheduleSend->SetupL(aCommand);
    }
    break;
    case ESetIncrementalHeapFailure:
    {
        iHeapFailure = ETrue;
        // drop through
    }
    case EResetIncrementalHeapFailure:
    {
        iNextFailure = 0;
    }
    break;
    case ENoIncrementalHeapFailure:
    {
        iHeapFailure = EFalse;
        __UHEAP_RESET;
    }
    break;
    case EScheduleFailFirstSend:
    {
        SetFailFirstSendL(aSelection);

        iScheduleSend->ScheduleL(aSelection, package);
        UpdateProgressL(aSelection);
    }
    break;
    default:
        User::Panic(_L("pigeon server"), 1);
        break;
    }

    if(iHeapFailure)
    {
        __UHEAP_RESET;
    }

}
Ejemplo n.º 3
0
  void TracLight_c::processMsg( const CanPkg_c& arc_data )
  {    
    CanPkgExt_c pkg( arc_data, getMultitonInst() );
    if( !pkg.isValid() || (pkg.getMonitorItemForSA() == NULL) )
      return;

    IsoName_c const& rcc_tempISOName = pkg.getISONameForSA();

    lightBitData_t* pt_data = NULL;

    switch (pkg.isoPgn() /*& 0x3FFFF*/) // don't need to &, we're interested in the whole PGN!
    {
      case LIGHTING_DATA_PGN:
        // lighting state information is sent by more than one sender -> store ALL messages with SA as key in STL_NAMESPACE::map
        pt_data = &(mmap_data[pkg.isoSa()]);
        if (pt_data != NULL)
          pt_data->dataMsgReq = IsoAgLib::IsoDontCare; //reserved field in lighting data
        break;
      case LIGHTING_COMMAND_PGN:
        // CMD is EXCLUSIVELY SENT BY ONE TRACTOR ECU!!! --> CHECK
        if ( checkParseReceived (rcc_tempISOName) )
        { // sender is allowed to send
          pt_data = &mt_cmd;
          mt_cmd.dataMsgReq = IsoAgLib::IsoDataReq_t( pkg.getUint8Data(7) & 3 );

          if (mt_cmd.dataMsgReq == IsoAgLib::IsoDataRequested)
            mb_cmdWait4Response = true;

          // set last time - use the array of send time stamps which is needed in tractor mode
          // in implement mode, the first item can be used to trace received tractor commands
          marr_timeStamp[0] = pkg.time();

          setSelectedDataSourceISOName (rcc_tempISOName);
          setUpdateTime( pkg.time() );
        } else
        { // there is a sender conflict
          IsoAgLib::getILibErrInstance().registerNonFatal( IsoAgLib::iLibErr_c::TracMultipleSender, getMultitonInst() );
        }
        break;
    }

    if ( pt_data == NULL )
    { // preconditions for parsing of this message are NOT fullfilled --> exit function with false
      return;
    }
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // from here on, we can safely process the message as all preconditions are fullfilled
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    uint16_t ui16_temp = pkg.getUint16Data( 0 );
    pt_data->daytimeRunning =       IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  0) & 3 ) ;
    pt_data->alternateHead  =       IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  2) & 3 ) ;
    pt_data->lowBeamHead  =         IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  4) & 3 ) ;
    pt_data->highBeamHead  =        IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  6) & 3 ) ;
    pt_data->frontFog =             IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  8) & 3 ) ;
    pt_data->beacon  =              IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 10) & 3 ) ;
    pt_data->rightTurn  =           IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 12) & 3 ) ;
    pt_data->leftTurn  =            IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 14) & 3 ) ;
    ui16_temp = pkg.getUint16Data( 2 );
    pt_data->backUpLightAlarmHorn = IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  0) & 3 ) ;
    pt_data->centerStop  =          IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  2) & 3 ) ;
    pt_data->rightStop  =           IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  4) & 3 ) ;
    pt_data->leftStop  =            IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  6) & 3 ) ;
    pt_data->implClearance =        IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  8) & 3 ) ;
    pt_data->tracClearance  =       IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 10) & 3 ) ;
    pt_data->implMarker  =          IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 12) & 3 ) ;
    pt_data->tracMarker  =          IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 14) & 3 ) ;
    ui16_temp = pkg.getUint16Data( 4 );
    pt_data->rearFog =              IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  0) & 3 ) ;
    pt_data->undersideWork  =       IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  2) & 3 ) ;
    pt_data->rearLowWork  =         IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  4) & 3 ) ;
    pt_data->rearHighWork  =        IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  6) & 3 ) ;
    pt_data->sideLowWork =          IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  8) & 3 ) ;
    pt_data->sideHighWork  =        IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 10) & 3 ) ;
    pt_data->frontLowWork  =        IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 12) & 3 ) ;
    pt_data->frontHighWork  =       IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 14) & 3 ) ;
    ui16_temp = pkg.getUint16Data( 6 );
    pt_data->implOEMOpt2 =          IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  0) & 3 ) ;
    pt_data->implOEMOpt1  =         IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  2) & 3 ) ;
    pt_data->implRightForwardWork  =IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  4) & 3 ) ;
    pt_data->implLeftForwardWork  = IsoAgLib::IsoActiveFlag_t( (ui16_temp >>  6) & 3 ) ;
    // pt_data->dataMsgReq is treated separately
    pt_data->implRightFacingWork  = IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 10) & 3 ) ;
    pt_data->implLeftFacingWork  =  IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 12) & 3 ) ;
    pt_data->implRearWork  =        IsoAgLib::IsoActiveFlag_t( (ui16_temp >> 14) & 3 ) ;

    if ( mb_cmdWait4Response )
      sendMessage();
  }
Ejemplo n.º 4
0
void SyncTransferThread::slot_syncDownload(QPair<QString, LIBSSH2_SFTP_ATTRIBUTES*> task)
{
    q_debug()<<"";
    SyncTaskPackage pkg(task.first, task.second, TASK_DOWNLOAD);
    this->addTask(pkg);
}
Ejemplo n.º 5
0
void SyncTransferThread::slot_syncUpload(QPair<QString, LIBSSH2_SFTP_ATTRIBUTES*> task)
{
    SyncTaskPackage pkg(task.first, task.second, TASK_UPLOAD);
    this->addTask(pkg);
}
Ejemplo n.º 6
0
int main(int argc, const char *argv[]) {
	// Pick up configuration parameters
	boost::program_options::variables_map vm;

	bool bTest, bBuild, bPackage;
	bTest = bBuild = bPackage = false;
	unsigned int iLogRotationSize;
	std::string sWorkingDir;
	std::string sStageDir;
	std::string sInstallPrefix;
	std::string sPackageName;
	std::string sPackageControlFile;
	std::string sArchitecture;
	std::string sSection;
	std::string sCfgfile;
	std::string sRosVersion;
	std::string sPriority;
	std::string sLogFile;
	std::string sLogFilter;
	std::string sLogFormat;
	std::string sDebianLocation;
	std::string sDebianType;
	std::string sDBHost;
	std::string sDBDatabase;
	uint32_t uiDBPort;
	std::string sDBUser;
	std::string sDBPassword;

	boost::filesystem::path idir;
	// capture the directory from which urpackager was run.
	// we return the user to this directory when we exit.
	idir = boost::filesystem::initial_path();

	// work is run out of the users home directory
	sWorkingDir = getenv("HOME");
	if (sWorkingDir.empty()) // not a  popular linux version configuration
		sWorkingDir = getenv("USERPROFILE");
	if (sWorkingDir.empty()) {
		std::cout << "The user running this utility must have a home directory" << std::endl;
		return (ERROR_FILESYSTEM);
	}

	// If this is the first time run, configuration file and control files will not exist
	sWorkingDir += "/.urpackager";
	boost::filesystem::path wdir(sWorkingDir);
	if (!boost::filesystem::is_directory(wdir)) { // First time the utility was run by this user.
		if (!boost::filesystem::create_directory(wdir)) {
			std::cout << "Unable to write to the user's home directory" << std::endl;
			return (ERROR_FILESYSTEM);
		}
		boost::filesystem::current_path(wdir);
		boost::filesystem::create_directory("./pkgcontrol");
		boost::filesystem::create_directory("./log");
		urpackagerConfFileCreate();
		std::cout << "This is the first time you have run \"urpackager.\"" << std::endl;
		std::cout << "Edit the file '~/.urpackager/urpackager.conf'" << std::endl;
		return (EXEC_SUCCESS);
	}
	boost::filesystem::current_path(wdir);

	// get run parameters
	try {
		/** Define and parse the program options */
		boost::program_options::options_description generic("Generic Options", 255); // command line only options
		generic.add_options()
				("help,h", "Print help messages")
				("version,v", "Version 1.0.0");

		boost::program_options::options_description config("Configuration Options"); // command line or configuration file and environment
		config.add_options()
		("package", boost::program_options::value<std::string>(),
				"The name of the package for which to create a debian")
		("architecture", boost::program_options::value<std::string>(),
				"Architecture for which you wish to create a debian file")
		("section", boost::program_options::value<std::string>()->default_value("amd64"),
				"repository section for which you wish to create a debian file")
		("test", boost::program_options::value<bool>()->default_value(false),
				"prints out variables but does no work")
		("stagedir", boost::program_options::value<std::string>()->default_value("unique_path"),
				"The directory under which the debian manifest will be temporarily created")
		("installprefix", boost::program_options::value<std::string>()->default_value("/opt/magni/v4"),
				"Prefix directory into which files will be (default) installed")
		("config", boost::program_options::value<std::string>()->default_value("./urpackager.conf"),
				"The configuration file")
		("log.file", boost::program_options::value<std::string>()->default_value("./log/urpackager.log"),
				"The log file")
		("log.filter", boost::program_options::value<std::string>()->default_value("INFO"),
				"The log level")
		("log.rotationsize", boost::program_options::value<int>()->default_value(100),
				"The maximum size for the log file in MB")
		("log.format", boost::program_options::value<std::string>()->default_value("[%TimeStamp%]: %Message%"),
				"The format log messages take")
		("ros.version", boost::program_options::value<std::string>()->default_value("indigo"),
				"The version of ROS this build - appended to <run_depend> package names")
		("debian.type", boost::program_options::value<std::string>()->default_value("deb"),
				"Package either a binary (type = \"deb\") or a micro binary (type = \"udeb\")")
		("debian.location", boost::program_options::value<std::string>(),
				"Directory into which to place the debian file")
    ("database.host", boost::program_options::value<std::string>(),
	      "The host where the urpackage db is running")
    ("database.database", boost::program_options::value<std::string>(),
        "The mysql schema")
    ("database.port", boost::program_options::value<int>(),
        "The port on which the database is listening")
    ("database.user", boost::program_options::value<std::string>(),
        "The user of the database")
    ("database.password", boost::program_options::value<std::string>(),
        "Password to log into the database");
		boost::program_options::options_description hidden("Hidden"); // command line or configuration file/environment but not shown

		hidden.add_options()("administrator", boost::program_options::value<std::string>(),
				"Administration capabilities");

		boost::program_options::options_description cmdline_options;
		cmdline_options.add(generic).add(config).add(hidden);

		boost::program_options::options_description cfgfile_options;
		cfgfile_options.add(config).add(hidden);

		boost::program_options::options_description visible("Allowed options");
		visible.add(generic).add(config);

    boost::program_options::store(boost::program_options::parse_command_line(argc, argv, cmdline_options), vm); // can throw

		/* --help option */
		if (vm.count("help")) {
			std::cout << "Foo help...." << std::endl
					<< config << std::endl;
			graceful_exit(idir, EXEC_SUCCESS);
		}

		if (vm.count("version")) {
			std::cout << "urpackager Version 1.0.0" << std::endl
					<< config << std::endl;
			graceful_exit(idir, EXEC_SUCCESS);
		}

		if (vm.count("package")) {
			sPackageName = vm["package"].as<std::string>();
		}

		if (vm.count("architecture")) {
			sArchitecture = vm["architecture"].as<std::string>();
		}

		if (vm.count("section")) {
			sSection = vm["section"].as<std::string>();
		}

		if (vm.count("test")) {
			bTest = vm["test"].as<bool>();
		}

		if (vm.count("stagedir")) {
			sStageDir = vm["stagedir"].as<std::string>();
		}

		if (vm.count("installprefix")) {
			sInstallPrefix = vm["installprefix"].as<std::string>();
		}

		if (vm.count("config"))
			sCfgfile = (const std::string&) vm["config"].as<std::string>();

		std::ifstream cfgfile(sCfgfile.c_str(), std::ios::in);
		if (cfgfile.fail())
			std::cout << "Config file failed to open" << std::endl;

		boost::program_options::store(parse_config_file(cfgfile, cfgfile_options, true), vm);
		cfgfile.close();

		boost::program_options::notify(vm); // throws on error, so do after help in case
		// there are any problems
	} catch (boost::program_options::error& e) {
		std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
		graceful_exit(idir, ERROR_COMMAND_LINE);
	}

	try {
		if (vm.count("log.file"))
			sLogFile = (const std::string&) vm["log.file"].as<std::string>();

		if (vm.count("log.filter"))
			sLogFilter = (const std::string&) vm["log.filter"].as<std::string>();

		if (vm.count("log.rotationsize"))
			iLogRotationSize = (int) vm["log.rotationsize"].as<int>();

		if (vm.count("log.format"))
			sLogFormat = (const std::string&) vm["log.format"].as<std::string>();

		if (vm.count("debian.location"))
			sDebianLocation = (const std::string&) vm["debian.location"].as<std::string>();

		if (vm.count("debian.type"))
			sDebianType = (const std::string&) vm["debian.type"].as<std::string>();

		if (vm.count("ros.version"))
			sRosVersion = (const std::string&) vm["ros.version"].as<std::string>();

		if (sPackageName.empty()) {
			std::cout << "Execution of this utility requires a package name" << std::endl;
			graceful_exit(idir, ERROR_COMMAND_LINE);
		}

		if (sArchitecture.empty()) {
			sPackageControlFile = sWorkingDir + "/pkgcontrol/"
					              + sPackageName + ".pkgctl";
		} else {
			sPackageControlFile = sWorkingDir + "/pkgcontrol/" + sPackageName +
					              "." + sArchitecture + ".pkgctl";
		}
    if (vm.count("database.host"))
      sDBHost = (const std::string&) vm["database.host"].as<std::string>();

    if (vm.count("database.database"))
      sDBDatabase = (const std::string&) vm["database.database"].as<std::string>();

    if (vm.count("database.port"))
      uiDBPort = (unsigned int) vm["database.port"].as<int>();

    if (vm.count("database.user"))
      sDBUser = (const std::string&) vm["database.user"].as<std::string>();

    if (vm.count("database.password"))
      sDBPassword = (const std::string&) vm["database.password"].as<std::string>();

	} catch (std::exception& e) {
		std::cerr << "Unhandled Exception reached after applying all options: "
				<< e.what() << ", application will now exit" << std::endl;
		graceful_exit(idir, ERROR_UNHANDLED_EXCEPTION);
	}

	/* Ready to run the utility
	 *
	 */
	ur::PackageControl pc(sPackageControlFile);
	pc.readControlFile();
	pc.setStageBase(sStageDir);
	ur::PackageXML px;
	px.readFile(pc.getPackageXML());

	if(bTest) {
		graceful_exit(idir, EXEC_SUCCESS);
	}

	ur::DebianPackage pkg(pc, px,
			              sArchitecture,
					      sSection,
					      sDebianType,
					      sDebianLocation,
					      sDBHost,
					      sDBDatabase,
					      sDBUser,
					      sDBPassword,
					      uiDBPort);

	pkg.createStageDirectory();
	pkg.stageManifest();
	pkg.writeDebianControleFile();
	pkg.generateChecksums();
	pkg.generateDebianPackage();
	pkg.moveDebianPackage();
	pkg.deleteStaging();

	return (EXEC_SUCCESS);
}
Ejemplo n.º 7
0
// ---------------------------------------------------------------------------
// CFotaSrvSession::ServiceL
// Handle client request
// ---------------------------------------------------------------------------
//
void CFotaSrvSession::ServiceL(const RMessage2& aMessage)
    {
    TInt err(KErrNone);
    TInt pkgid = 0;
    TPackageState state;
    RThread clt;
    aMessage.ClientL(clt);
    TFullName cltnm = clt.FullName();
    FLOG(_L( "CFotaSrvSession::ServiceL      %d   serving for %S?" ),
            aMessage.Function(), &cltnm);

    TFotaClient client = CheckClientSecureIdL(aMessage);

    if (client == EUnknown)
        {
        FLOG(_L("Permission denied to use fota services!"));
        User::Leave(KErrPermissionDenied);
        }

    TInt cmd = aMessage.Function();
    if ((cmd != EGetState) && (cmd != EGetResult) && (cmd != EGetCurrFwDetails) && (cmd != EGetUpdateTimestamp))
        {
    
        TInt fotaValue(1);
        CRepository* centrep(NULL);
        TUid uidValue =
            {
            0x101F9A08
            }; // KCRFotaAdapterEnabled

        centrep = CRepository::NewL(uidValue);
        if (centrep)
            {
            FLOG(_L("centralrepository found "));
            centrep->Get(1, fotaValue); // KCRFotaAdapterEnabled     
            delete centrep;
            }

        if (!fotaValue)
            {
            FLOG(_L("Fota is disabled or not supported!"));
            User::Leave(KErrNotSupported);
            }
            
        }

    switch (aMessage.Function())
        {

        case EFotaDownload:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL DOWNLOAD"));
            TDownloadIPCParams ipc;
            TPckg<TDownloadIPCParams> pkg(ipc);
            aMessage.Read(0, pkg);
            TInt deslen = aMessage.GetDesLengthL(1);
            HBufC8* urlbuf = HBufC8::NewLC(deslen);
            TPtr8 urlptr = urlbuf->Des();
            aMessage.Read(1, urlptr);
            TInt silent = aMessage.Int2();
            FotaServer()->DownloadL(ipc, urlptr, client, silent, EFalse);
            CleanupStack::PopAndDestroy(urlbuf); // urlbuf
            aMessage.Complete(KErrNone);

            break;
            }
        case EFotaUpdate:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL UPDATE" ));
            TDownloadIPCParams ipc;
            TPckg<TDownloadIPCParams> pkg(ipc);
            aMessage.Read(0, pkg);

            // If update started from omadmappui, no alert should be sent if 
            // update is cancelled
            if (client == EOMADMAppUi)
                {
                ipc.iSendAlert = EFalse;
                }
            FotaServer()->TryUpdateL(client);
            aMessage.Complete(KErrNone);
            break;
            }
        case EFotaDownloadAndUpdate:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL DOWNLOADANDUPDATE" ));
            TDownloadIPCParams ipc;
            TPckg<TDownloadIPCParams> pkg(ipc);
            aMessage.Read(0, pkg);
            TInt deslen = aMessage.GetDesLengthL(1);
            HBufC8* urlbuf = HBufC8::NewLC(deslen);
            TPtr8 urlptr = urlbuf->Des();
            aMessage.Read(1, urlptr);
            TFotaClient requester = CheckClientSecureIdL(aMessage);

            TInt silent = aMessage.Int2();
            FotaServer()->DownloadL(ipc, urlptr, requester, silent, ETrue);
            CleanupStack::PopAndDestroy(urlbuf);
            aMessage.Complete(KErrNone);
            }
            break;

        case EFotaTryResumeDownload:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL TRYRESUMEDOWNLOAD" ));
            if (client == EOMADMAppUi || client == EFMSServer || client
                    == EFotaTestApp)
                {
                TInt silent = aMessage.Int0();
                
                FotaServer()->TryResumeDownloadL(client, silent); // silent
                aMessage.Complete(KErrNone);
                }
            else
                {
                aMessage.Complete(KErrAccessDenied);
                }

            }
            break;

        case EDeletePackage:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL DELETEPACKAGE"));
            pkgid = aMessage.Int0();
            FotaServer()->DeletePackageL(pkgid);
            aMessage.Complete(KErrNone);
            }
            break;
        case EGetState:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL GETSTATE" ));
            pkgid = aMessage.Int0();

            state = FotaServer()->GetStateL(pkgid);

            FLOG(_L( "CFotaSrvSession::ServiceL GETSTATE << %d" ),  state.iState);
            TPckg<RFotaEngineSession::TState> pkg2(state.iState);
            aMessage.Write(1, pkg2);
            aMessage.Complete(KErrNone);
            }
            break;
        case EGetResult:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL GETRESULT >>" ));
            pkgid = aMessage.Int0();
            state = FotaServer()->GetStateL(pkgid);
            TPckg<TInt> pkg2(state.iResult);
            FLOG(_L( "CFotaSrvSession::ServiceL GETRESULT << %d" ),
                    state.iResult);
            aMessage.Write(1, pkg2);
            aMessage.Complete(err);
            break;
            }
        case EGetUpdatePackageIds:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL EGETUPDATEPACKAGEIDS" ));
            TPkgIdList pkgids;
            FotaServer()->GetUpdatePackageIdsL(pkgids);
            TPckg<TPkgIdList> pkgids_pkg(pkgids);
            aMessage.Write(0, pkgids_pkg);
            aMessage.Complete(KErrNone);
            }
            break;

        case EGetUpdateTimestamp:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL EGETUPDATETIMESTAMP" ));
            TBuf16<15> timestamp;
            FotaServer()->GetUpdateTimeStampL(timestamp);
            aMessage.Write(0, timestamp);
            aMessage.Complete(KErrNone);
            }
            break;

        case EGenericAlertSentForPackage:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL EGENERICALERTSENT FOR PKGID" ));
            TInt pkgid = aMessage.Int0();
            FotaServer()->ResetFotaStateL(pkgid);
            aMessage.Complete(err);
            }
            break;

        case EScheduledUpdate:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL ESCHEDULEDUPDATE" ));
            TFotaScheduledUpdate sched(-1, -1);
            TPckg<TFotaScheduledUpdate> p(sched);
            aMessage.Read(0, p);

            FLOG(_L(" pkgid: %d   scheduleid:%d"), sched.iPkgId,
                    sched.iScheduleId);
            FotaServer()->ScheduledUpdateL(sched, client);
            aMessage.Complete(KErrNone);
            
            }
            break;

        case EPauseDownload:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL EPAUSEDOWNLOAD" ));
            FotaServer()->PauseDownloadL();
            aMessage.Complete(KErrNone);
            }
            break;
        case EGetCurrFwDetails:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL EGETCURRFWDETAILS" ));

            TBuf8<KFotaMaxPkgNameLength> name;
            TBuf8<KFotaMaxPkgVersionLength> version;
            TInt size(0);

            FotaServer()->GetCurrentFwDetailsL(name, version, size);

            /*
            aMessage.Write(1, name);
            aMessage.Write(2, version);
            TPckg<TInt> psize(size);
            aMessage.Write(3, psize);

            aMessage.Complete(KErrNone);*/
            
            aMessage.Write(0, name);
            aMessage.Write(1, version);
            TPckg<TInt> psize(size);
            aMessage.Write(2, psize);

            aMessage.Complete(KErrNone);


            }
            break;
        default:
            {
            FLOG(_L( "CFotaSrvSession::ServiceL In default case" ));
            }
            break;
        }
    }
// -----------------------------------------------------------------------------
// RUpnpMediaServerClient::Stop
// -----------------------------------------------------------------------------
//
EXPORT_C TInt RUpnpMediaServerClient::GetAddress(TInetAddr& aAddr)
    {
    TPckg<TInetAddr> pkg(aAddr);
    TIpcArgs args(&pkg);
    return SendReceive( EMediaServerGetIpAndPort, args );
    }
Ejemplo n.º 9
0
static int manage_package_mode(const std::string &packagename, bool manager,
                               int processor, const CmdArgs &args)
{
    CmdArgs::const_iterator it = args.begin();
    CmdArgs::const_iterator end = args.end();
    bool stop = false;

    vle::utils::Package pkg(packagename);

    if (not init_package(pkg, args))
        return EXIT_FAILURE;


    for (; not stop and it != end; ++it) {
        if (*it == "create") {
            pkg.create();
        } else if (*it == "configure") {
            pkg.configure();
            pkg.wait(std::cerr, std::cerr);
            stop = not pkg.isSuccess();
        } else if (*it == "build") {
            pkg.build();
            pkg.wait(std::cerr, std::cerr);
            if (pkg.isSuccess()) {
                pkg.install();
                pkg.wait(std::cerr, std::cerr);
            }
            stop = not pkg.isSuccess();
        } else if (*it == "test") {
            pkg.test();
            pkg.wait(std::cerr, std::cerr);
            stop = not pkg.isSuccess();
        } else if (*it == "install") {
            pkg.install();
            pkg.wait(std::cerr, std::cerr);
            stop = not pkg.isSuccess();
        } else if (*it == "clean") {
            pkg.clean();
            pkg.wait(std::cerr, std::cerr);
            stop = not pkg.isSuccess();
        } else if (*it == "rclean") {
            pkg.rclean();
        } else if (*it == "package") {
            pkg.pack();
            pkg.wait(std::cerr, std::cerr);
            stop = not pkg.isSuccess();
        } else if (*it == "all") {
            std::cerr << "all is not yet implemented\n";
            stop = true;
        } else if (*it == "depends") {
            std::cerr << "Depends is not yet implemented\n";
            stop = true;
        } else if (*it == "list") {
            show_package_content(pkg);
        } else {
            break;
        }
    }

    int ret = EXIT_SUCCESS;

    if (stop)
        ret = EXIT_FAILURE;
    else if (it != end) {
#ifndef NDEBUG
        vle::devs::ExternalEvent::allocated = 0;
        vle::devs::ExternalEvent::deallocated = 0;
        vle::devs::InternalEvent::allocated = 0;
        vle::devs::InternalEvent::deallocated = 0;
        vle::value::Value::allocated = 0;
        vle::value::Value::deallocated = 0;
#endif
        if (manager)
            ret = run_manager(it, end, processor, pkg);
        else
            ret = run_simulation(it, end, pkg);

#ifndef NDEBUG
        std::cerr << vle::fmt(_("\n - Debug mode:\n"
                    "                       allocated   deallocated\n"
                    "   - External events: %=12d/%=12d\n"
                    "   - Internal events: %=12d/%=12d\n"
                    "   - Values         : %=12d/%=12d\n")) %
            vle::devs::ExternalEvent::allocated %
            vle::devs::ExternalEvent::deallocated %
            vle::devs::InternalEvent::allocated %
            vle::devs::InternalEvent::deallocated %
            vle::value::Value::allocated %
            vle::value::Value::deallocated;
#endif
    }

    return ret;
}
Ejemplo n.º 10
0
  void TracAux_c::processMsg( const CanPkg_c& arc_data )
  {
    CanPkgExt_c pkg( arc_data, getMultitonInst() );
    if( !pkg.isValid() || (pkg.getMonitorItemForSA() == NULL) )
      return;

    IsoName_c const& rcc_tempISOName = pkg.getISONameForSA();

    unsigned int valveNumber = 15;
    const int32_t ci32_now = pkg.time();

    switch (pkg.isoPgn() /*& 0x3FFFF*/) // don't need to &, as this is the complete PGN anyway...
    {
      case AUX_VALVE_0_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_1_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_2_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_3_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_4_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_5_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_6_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_7_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_8_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_9_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_10_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_11_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_12_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_13_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_14_ESTIMATED_FLOW:
        valveNumber--;
      case AUX_VALVE_15_ESTIMATED_FLOW:
        if ( checkParseReceived( rcc_tempISOName ) )
        { // sender is allowed to send
          marr_valve[valveNumber].ui8_extendPortEstFlow = pkg.getUint8Data(0);
          marr_valve[valveNumber].ui8_retractPortEstFlow = pkg.getUint8Data(1);
          marr_valve[valveNumber].ui8_estFailSaveMode = ( (pkg.getUint8Data(2) >> 6) & 3 );
          marr_valve[valveNumber].ui8_estValveState = ( pkg.getUint8Data(2) & 0xF );
          marr_valve[valveNumber].ui8_estValveLimitStatus = ( pkg.getUint8Data(3) >> 5);

          setSelectedDataSourceISOName (rcc_tempISOName);
          setUpdateTime( ci32_now );
        }
        else
        { // there is a sender conflict
          IsoAgLib::getILibErrInstance().registerNonFatal( IsoAgLib::iLibErr_c::TracMultipleSender, getMultitonInst() );
        }
        break;
      case AUX_VALVE_0_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_1_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_2_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_3_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_4_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_5_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_6_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_7_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_8_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_9_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_10_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_11_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_12_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_13_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_14_MEASURED_FLOW:
        valveNumber--;
      case AUX_VALVE_15_MEASURED_FLOW:
        if ( checkParseReceived( rcc_tempISOName ) )
        { // sender is allowed to send
          marr_valve[valveNumber].ui8_extendPortMeasuredFlow = pkg.getUint8Data(0);
          marr_valve[valveNumber].ui8_retractPortMeasuredFlow = pkg.getUint8Data(1);
          marr_valve[valveNumber].ui16_extendPortPressure =  ( static_cast<uint16_t>(pkg.getUint8Data(2)) +
                                                             ( static_cast<uint16_t>(pkg.getUint8Data(3)) << 8 ) );
          marr_valve[valveNumber].ui16_retractPortPressure = ( static_cast<uint16_t>(pkg.getUint8Data(4)) +
                                                             ( static_cast<uint16_t>(pkg.getUint8Data(5)) << 8 ) );
          marr_valve[valveNumber].ui8_returnPortPressure = pkg.getUint8Data(6);
          marr_valve[valveNumber].ui8_measuredValveLimitStatus = ( pkg.getUint8Data(7) >> 5 );

          setSelectedDataSourceISOName (rcc_tempISOName);
          setUpdateTime( ci32_now );
        }
        else
        { // there is a sender conflict
Ejemplo n.º 11
0
void CFriendBoss::OnTimer5s()
{
	if (m_BossIndex != 0)
	{
		int cd = 0;
//		if (m_Type == FRIEND_BOSS_STORY)
//		{
//			cd = m_StartTime + GlobalConfig::StoryFBossAliveTime - time(NULL);
//		}
//		else
//		{
//			cd = m_StartTime + GlobalConfig::ActiveFBossAliveTime - time(NULL);
//		}
		cd = m_StartTime + m_BossAliveTime * 60 - time(NULL);
		if (cd <= 0)
		{
			m_BossIndex = 0;
			m_StartTime = 0;
			m_BossHealth = 0;
			m_Level = 0;
			m_listRecord.clear();
			m_Type = 0;

			m_BossAliveTime = 0;
			m_BossLvUpPara = 0;

			CRole *pCRole = sWorld->FindUserRole(m_UserId);
			if (pCRole != NULL)
			{
				WorldPacket pkg(CMD_SC_FRIEND_BOSS_INFO);
				PkgBossInfo(pkg);
				pCRole->SendPacket(&pkg);
			}
		}
	}

	if (m_ActiveFlushTime < CActiveCtrl::FriendBossRealStartTime)
	{
		m_ActiveFlushTime = CActiveCtrl::FriendBossRealStartTime;
		m_mapActiveBoss.clear();
	}
	
	uint8_t IsUpdate = false;
//	std::map<uint32_t, Prize>::iterator it,itdel;
//	for (it = m_mapPrize.begin(); it != m_mapPrize.end();)
//	{
//		if (it->second.t + GlobalConfig::FBossPrizeCD <= time(NULL))
//		{
//			itdel = it;
//			it++;
//			m_mapPrize.erase(itdel);
//			IsUpdate = true;
//		}
//		else
//		{
//			it++;
//		}
//	}
//
//	if (IsUpdate)
//	{
//		CRole *pCRole = sWorld->FindUserRole(m_UserId);
//		if (pCRole != NULL)
//		{
//			HandlerBossPrizeInfo(pCRole);
//		}
//	}
	return;
}
// ---------------------------------------------------------------------------
// Constructeur
// ------------
bPGisBaseAccessor	::bPGisBaseAccessor(	const char* hpath,  
											int* status,
											int kind,
											int srid,
											double reso,
											double u2m,
											const char* name,
											const char* data)
					:bv300BaseAccessor(hpath,status,kind,srid,reso,u2m,name,data,10){
_bTrace_("bPGisBaseAccessor::bPGisBaseAccessor",false);
char		fname[512];
char		ldata[1024];

	for(;;){
bStdDirectory	pkg(hpath);
	sprintf(fname,"%s.type/Contents/Datas",name);
bStdDirectory	cnt(fname);

		make_data(ldata);		
		
		sprintf(fname,"%s_%s",name,"header");
		_hdr=(bStdTable*)wtbl_alloc(kTablePostGIS,ldata,fname,true,reso,srid,status);
		if(*status){
			break;
		}
		sprintf(fname,"%s_%s",name,"fields");
		_fld=(bStdTable*)wtbl_alloc(kTablePostGIS,ldata,fname,true,reso,srid,status);
		if(*status){
			break;
		}
		sprintf(fname,"%s_%s",name,"constraints");
		_cnst=(bStdTable*)wtbl_alloc(kTablePostGIS,ldata,fname,true,reso,srid,status);
		if(*status){
			break;
		}
		sprintf(fname,"%s_%s",name,"objects");
		_objs=(bStdTable*)wtbl_alloc(kTablePostGIS,ldata,fname,true,reso,srid,status);
		if(*status){
			break;
		}
		if((*status=h_new(name))){
			break;
		}
		if((*status=std_add())){
			break;
		}
		
		if(_fld->CountRecords()<kOBJ_Dir_){
			*status=-1;
			break;
		}
		if((*status=load())){
			break;
		}
		return;
	}
_err_(_strr_+"status == "+(*status));
	_elts.reset();
	_celts.reset();
	if(_fld){	
		wtbl_free(_fld);
		_fld=NULL;
	}
	if(_objs){	
		wtbl_free(_objs);
		_objs=NULL;
	}
	if(_hdr){	
		wtbl_free(_hdr);
		_hdr=NULL;
	}
	if(_cnst){	
		wtbl_free(_cnst);
		_cnst=NULL;
	}
}
Ejemplo n.º 13
0
    static bool check(const std::string& pkgname,
            const std::string& test_file_name)
    {
        std::cout << " check=" << test_file_name << std::endl;

        std::vector <std::string> test_report;
        bool fail = false;
        vu::Package pkg(pkgname);
        std::string test_file_path = pkg.getDataFile(test_file_name);
        vv::Map params;
        std::string separator = " ";
        params.addString("sep",separator);
        vv::Set& cols = params.addSet("columns");
        cols.addString("string");//pkg name
        cols.addString("string");//vpz name
        cols.addString("string");//view name
        cols.addString("string");//col name
        cols.addString("int");//line index
        cols.addString("string");//expected double or string
        cols.addString("string");//precision for double or NA for string

        vle::reader::TableFileReader tfr(test_file_path);
        tfr.setParams(params);
        vv::Matrix resParsing;
        tfr.readFile(resParsing);

        if (tfr.hasError()) {
            tfr.printError(std::cout);
            fail = true;
            return fail;
        }

        std::string pkgtotest("NA");
        std::string vpzname("NA");
        std::string view;
        std::string colname;
        unsigned int lineIndex;
        std::string valExpected;
        std::string precision;

        TesterSimulation* tester_sim(0);
        vv::Map* sim_outputs(0);



        for (unsigned int i = 0; i < resParsing.rows(); i++) {
            bool fail_i = false;
            const std::string& newpkg = resParsing.getString(0,i);
            const std::string& newvpz = resParsing.getString(1,i);
            view = resParsing.getString(2,i);
            colname = resParsing.getString(3,i);
            lineIndex = resParsing.getInt(4,i);
            precision = resParsing.getString(5,i);
            valExpected = resParsing.getString(6,i);

            std::ostringstream report_line;
            report_line << "test_" << i;
            report_line << ": ";
            vv::Value* simulated_val = 0;

            if (not (newpkg == pkgtotest and newvpz == vpzname)) {

                delete tester_sim;
                delete sim_outputs;
                sim_outputs = 0;
                tester_sim = 0;

                try {
                    tester_sim = new TesterSimulation(newpkg, newvpz);
                } catch (const std::exception& e) {
                    report_line << "fail to open " << newpkg << "/"
                            << newvpz;
                    fail_i = true;
                }
                if (!fail_i){
                    try {
                        sim_outputs = tester_sim->simulates();
                    } catch (const std::exception& e){
                        report_line << "running during simulation "
                                << newpkg << "/" << newvpz << ": ";
                        fail_i = true;
                    }
                }
                if (!fail_i && tester_sim->getError().code) {
                    report_line << "running error of "
                            << newpkg << "/" << newvpz << ": "
                            << tester_sim->getError().message;
                    fail_i = true;
                }
                pkgtotest.assign(newpkg);
                vpzname.assign(newvpz);

            }
            if (!fail_i && sim_outputs == 0) {
                report_line << "sim_outputs null of "
                        << newpkg << "/" << newvpz;
                fail_i = true;
            }
            if (!fail_i) {
                try {
                    simulated_val =  tester_sim->getColElt(*sim_outputs,
                            view, colname, lineIndex);
                } catch (const vu::ArgError&) {
                    fail_i = true;
                    report_line << "test fail of " << newpkg << "/" << newvpz
                            << ": error in getting " << lineIndex
                            <<"th value of col '"<< colname << "' from view '"
                            << view << "' ";
                }
                if (simulated_val == 0) {
                    fail_i = true;
                    report_line << "test fail of " << newpkg << "/" << newvpz
                            << ": " << lineIndex << "th value of col '"
                            << colname << "' from view '"
                            << view << "' is null ";
                }
            }
            if (!fail_i && !performs_one_test(precision, valExpected,
                    *simulated_val)) {
                report_line << "test fail of " << newpkg << "/"
                        << newvpz << ": expected=" << valExpected
                        << "; got= " << *simulated_val;
                fail_i = true;
            }
            if (!fail_i) {
                report_line << "test ok of " << newpkg << "/" << newvpz
                        << ": view=" << view << "; col="<< colname
                        << "; expected=" << valExpected
                        << "; got=" << *simulated_val;
            }
            test_report.push_back(report_line.str());
            fail = fail or fail_i;
        }
        if (tester_sim != 0) {
            delete tester_sim;
            delete sim_outputs;
        }

        for (unsigned int i=0; i< test_report.size(); i++) {
            std::cout << test_report[i] << std::endl;
        }
        return fail;
    }
Ejemplo n.º 14
0
void
IsoMonitor_c::processMsg( const CanPkg_c& arc_data )
{
#if DEBUG_ISOMONITOR
  INTERNAL_DEBUG_DEVICE << INTERNAL_DEBUG_DEVICE_ENDL << "IsoMonitor_c::processMsg()-BEGIN" << INTERNAL_DEBUG_DEVICE_ENDL;
  debugPrintNameTable();
#endif

  CanPkgExt_c pkg( arc_data, getMultitonInst() );

  const IsoName_c cc_dataIsoName (pkg.getDataUnionConst());

  // Special NETWORK-MANAGEMENT Handling of ADDRESS_CLAIM_PGN
  // don't do the generic "valid-resolving" check here!
  if( (pkg.isoPgn() & 0x3FF00LU) == ADDRESS_CLAIM_PGN )
  {
    const int32_t ci32_time = pkg.time();
    const uint8_t cui8_sa = pkg.isoSa();

    IsoItem_c *pc_itemSameISOName = item( cc_dataIsoName );
    if( pc_itemSameISOName != NULL )
    {
      if (pc_itemSameISOName->itemState(IState_c::PreAddressClaim))
        // no need to check here for LostAddress, as it's only about the ISOName,
        // and that's correct in all other cases!
      { // this item is still in PreAddressClaim, so don't consider its
        // ISOName as final, it may be able to adapt it when switching to AddressClaim
        // Note: Only LOCAL Items can be in state PreAddressClaim
        pc_itemSameISOName = NULL;
      }
    }

    IsoItem_c *pc_itemSameSa = item( cui8_sa );
    if( pc_itemSameSa != NULL )
    {
      if (pc_itemSameSa->itemState(IState_c::PreAddressClaim)
       || pc_itemSameSa->itemState(IState_c::AddressLost) )
      { // this item has no valid address, as it's not (anymore) active.
        // so don't consider it as item with the same SA as the received one.
        pc_itemSameSa = NULL;
      }
    }

    /// Receiving REMOTE Address-Claim
    /// ##############################

    if (NULL == pc_itemSameISOName)
    { // We have NO item with this IsoName
      /// Insert this new remote node (new isoname). Just check before if it steals a SA from someone
      if (NULL == pc_itemSameSa)
      { // New remote node took a fresh SA. The way it should be. Insert it to the list.
        insertIsoMember (cc_dataIsoName, cui8_sa, IState_c::ClaimedAddress, NULL, true);
      }
      else
      { // New remote node stole a SA. Check if it stole from local or remote.
        if (pc_itemSameSa->itemState(IState_c::Local))
        { /// New remote node steals SA from Local node!
          // --> change address if it has lower PRIO
          if (pc_itemSameSa->isoName() < cc_dataIsoName)
          { // the LOCAL item has lower PRIO
            if (pc_itemSameSa->itemState(IState_c::AddressClaim))
            { // the LOCAL item was still in AddressClaim (250ms) phase
              pc_itemSameSa->setNr (unifyIsoSa (pc_itemSameSa, true));
              // No need to broadcast anything, we didn't yet even call AddToMonitorList...
              pc_itemSameSa->sendAddressClaim (false); // false: Address-Claim due to SA-change on conflict **while 250ms-phase** , so we can skip the "AddressClaim"-phase!
            }
            else
            { // the LOCAL item is already up and running, so simply change the SA, claim again and go on
              pc_itemSameSa->changeAddressAndBroadcast (unifyIsoSa (pc_itemSameSa, true));
              pc_itemSameSa->sendAddressClaim (true); // true: Address-Claim due to SA-change on conflict **after 250ms-phase**, so we can skip the "AddressClaim"-phase!
            }

            if (pc_itemSameSa->nr() == 254)
            { // Couldn't get a new address -> remove the item and let IdentItem go to OffUnable!
              if (pc_itemSameSa->getIdentItem())
              { // as it should be! as it's local!
                pc_itemSameSa->getIdentItem()->goOffline(false); // false: we couldn't get a new address for this item!
              }
            } else {
              updateSaItemTable( *pc_itemSameSa, true );
            }
            insertIsoMember (cc_dataIsoName, cui8_sa, IState_c::ClaimedAddress, NULL, true);
          }
          else
          { // let local IsoItem_c process the conflicting adr claim
            // --> the IsoItem_c::processMsg() will send an ADR CLAIM to indicate the higher prio
            pc_itemSameSa->processAddressClaimed (ci32_time, cui8_sa);
            insertIsoMember (cc_dataIsoName, 0xFE, IState_c::AddressLost, NULL, true);
            /// ATTENTION: We insert the IsoName WITHOUT a valid Address. (and even notify the registered clients about it!)
            /// But this may also happen anyway if you register your handler at a later time -
            /// then your handler will be called with "AddToMonitorList" for all yet known IsoItems -
            /// and those don't need to have a valid SA at this moment!!
          }
        }
        else
        { /// New remote node steals SA from Remote node!
          pc_itemSameSa->giveUpAddressAndBroadcast();
          insertIsoMember (cc_dataIsoName, cui8_sa, IState_c::ClaimedAddress, NULL, true);
        }
      }
    }
    else
    { // We already have an item with this IsoName
      if (pc_itemSameISOName->itemState(IState_c::Local))
      { // We have a local item with this IsoName
        isoaglib_assert( pc_itemSameISOName->getIdentItem() );
        pc_itemSameISOName->getIdentItem()->goOffline( false ); // false: we couldn't get a new address for this item!
        IsoAgLib::getILibErrInstance().registerNonFatal( IsoAgLib::iLibErr_c::MonitorNameRxConflict, getMultitonInst() );
        // now create a new node for the remote SA claim
        insertIsoMember (cc_dataIsoName, cui8_sa, IState_c::ClaimedAddress, NULL, true);
      }
      else
      { // We have a remote item with this IsoName
        /// Change SA of existing remote node. Just check before if it steals a SA from someone
        if (NULL == pc_itemSameSa)
        { // (A9) Existing remote node took a fresh SA. The way it should be. Just change its address.
          updateSaItemTable( *pc_itemSameISOName, false );
          pc_itemSameISOName->processAddressClaimed (ci32_time, cui8_sa);
          updateSaItemTable( *pc_itemSameISOName, true );
        }
        else
        { // Existing remote node took an already existing SA.
          if (pc_itemSameSa == pc_itemSameISOName)
          { // (A1) Existing remote node reclaimed its SA, so it's just a repeated address-claim.
            pc_itemSameISOName->processAddressClaimed (ci32_time, cui8_sa); // only call to update the timestamp basically
          }
          else if (pc_itemSameSa->itemState(IState_c::Local))
          { // (A5) Existing remote node steals SA from Local node!
            // --> change address if it has lower PRIO
            if (pc_itemSameSa->isoName() < cc_dataIsoName)
            { // the LOCAL item has lower PRIO
              if (pc_itemSameSa->itemState(IState_c::AddressClaim))
              { // the LOCAL item was still in AddressClaim (250ms) phase
                pc_itemSameSa->setNr (unifyIsoSa (pc_itemSameSa, true));
                // No need to broadcast anything, we didn't yet even call AddToMonitorList...
                pc_itemSameSa->sendAddressClaim (false); // false: Address-Claim due to SA-change on conflict **while 250ms-phase** , so we can skip the "AddressClaim"-phase!
              }
              else
              { // the LOCAL item is already up and running, so simply change the SA, claim again and go on
                pc_itemSameSa->changeAddressAndBroadcast (unifyIsoSa (pc_itemSameSa, true));
                pc_itemSameSa->sendAddressClaim (true); // true: Address-Claim due to SA-change on conflict **after 250ms-phase**, so we can skip the "AddressClaim"-phase!
              }

              if (pc_itemSameSa->nr() == 254)
              { // Couldn't get a new address -> remove the item and let IdentItem go to OffUnable!
                if (pc_itemSameSa->getIdentItem())
                { // as it should be! as it's local!
                  pc_itemSameSa->getIdentItem()->goOffline(false); // false: we couldn't get a new address for this item!
                }
              } else {
                /* we could change our SA -> update */
                updateSaItemTable( *pc_itemSameSa, true );
              }
              pc_itemSameISOName->processAddressClaimed (ci32_time, cui8_sa);
              updateSaItemTable( *pc_itemSameISOName, true );
            }
            else
            { // let local IsoItem_c process the conflicting adr claim
              // --> the IsoItem_c::processMsg() will send an ADR CLAIM to indicate the higher prio
              pc_itemSameSa->processAddressClaimed (ci32_time, cui8_sa);
              updateSaItemTable( *pc_itemSameISOName, false ); // update table before item get FE
              pc_itemSameISOName->giveUpAddressAndBroadcast();
            }
          }
          else
          { // (A3) Existing remote node steals other remote node's SA
            pc_itemSameSa->giveUpAddressAndBroadcast();
            pc_itemSameISOName->processAddressClaimed (ci32_time, cui8_sa); // will set the new SA and do broadcasting
            updateSaItemTable( *pc_itemSameISOName, true );
          }
        }
      }
    }
  }
  else
  {
    // for all following modules, we do the "typical" "valid-resolving"-check!
    if( !pkg.isValid() || (pkg.getMonitorItemForSA() == NULL) )
      return;

#ifdef USE_WORKING_SET
    // Handle NON-DESTINATION PGNs
    switch ((pkg.isoPgn() /* & 0x3FFFF */ )) // isoPgn is already "& 0x3FFFF" !
    {
      case WORKING_SET_MASTER_PGN:
        pkg.getMonitorItemForSA()->processMsgWsMaster (uint8_t(pkg.getUint8Data(1-1) - 1), pkg.time() );
      break;

      case WORKING_SET_MEMBER_PGN:
        pkg.getMonitorItemForSA()->processMsgWsMember (cc_dataIsoName, pkg.time());
      break;

      default:
        break;
    } // end switch for NON-DESTINATION pgn
#endif
  }

#if DEBUG_ISOMONITOR
  INTERNAL_DEBUG_DEVICE << "IsoMonitor_c::processMsg()-END" << INTERNAL_DEBUG_DEVICE_ENDL;
  debugPrintNameTable();
#endif
}