当前位置: 首页>>代码示例>>C++>>正文


C++ LogReader类代码示例

本文整理汇总了C++中LogReader的典型用法代码示例。如果您正苦于以下问题:C++ LogReader类的具体用法?C++ LogReader怎么用?C++ LogReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LogReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

void MyThread::run(){
    LogReader logreader;
    LogSender logsender;
    list<MatchedLogRec> matches=
    logreader.readLogs();
    /*准备发送数据*/
    logsender.initNetWork();
    char datastr[100]={0};
    /*循环发送数据*/
    while(matches.size()>0){
       sleep(1);
       bool f=logsender.sendMatche(*matches.begin());
      if(f){
          /*发射信号*/
          sprintf(datastr,"%s:%d:%s",matches.begin()->logname,
          matches.begin()->pid,matches.begin()->logip);
          emit  mySig(QString(datastr));
          /*删除这条数据*/
          matches.erase(matches.begin());
      }else{
          break;
      }
    }
    /*关闭fd*/
    logsender.saveSendFailed(&matches);
}
开发者ID:soplist,项目名称:study-c-cpp,代码行数:26,代码来源:mythread.cpp

示例2: main

int main(){
    LogReader  logreader;
    LogSender  logsender;
    list<MatchedLogRec>  matches=
    logreader.readLogs();
    logsender.sendMatches(&matches);
}
开发者ID:soplist,项目名称:study-c-cpp,代码行数:7,代码来源:testdmsclient.cpp

示例3:

	bool LogReader::StrEntry::process(LogReader &a_logReader, bool a_init)
	{
		if (m_resume < 0)
			return false;

		const __int64 l_fileSize = a_logReader.m_fileSize;

		const unsigned int l_maxFindSize = a_logReader.m_maxFindSize;
		while (true)
		{
			NewlineType l_newlineType;
			const __int64 l_found = a_logReader.findNewline(m_resume, l_fileSize, l_newlineType);
			if (l_found < 0)
			{
				const __int64 l_testClose = l_fileSize - l_maxFindSize;
				if (m_resume < l_testClose)
					m_resume = l_fileSize;

				m_next->m_resume = m_resume;
				a_logReader.m_maxClose = l_fileSize;
				a_logReader.m_findEntry = m_resume;
				if (m_resume >= l_fileSize)
					m_resume = _I64_MIN;
				else
					m_resume = l_fileSize;

				return true;

			}
			else
			{
				const __int64 l_testClose = l_found - l_maxFindSize;
				if (m_resume >= l_testClose)
				{
					m_next->m_resume = m_resume;
					a_logReader.m_maxClose = l_found;
					a_logReader.m_findEntry = m_resume;

					if (l_newlineType == nt_crlf)
						m_resume = l_found + 2;
					else
						m_resume = l_found + 1;

					return true;

				}

				if (l_newlineType == nt_crlf)
					m_resume = l_found + 2;
				else
					m_resume = l_found + 1;

			}

		}

		return false;

	}
开发者ID:rasim-valiullin,项目名称:d512388b-9b91-45f9-8f88-b6d4e252c270,代码行数:59,代码来源:logreader.cpp

示例4: main

int main()
{
	DMSClient client;
	LogReader reader;
	reader.setLogfile("wtmpx");
	
	LogNetSender sender;
	sender.setServerip("127.0.0.1");
	sender.setPort(9999);
	
	client.setReader(&reader);
	client.setSender(&sender);
	try
	{
		client.mine();	
	}catch(DMSException e)
	{
		cout<<e.what()<<endl;
	}	
	return 0;
}
开发者ID:hchtym,项目名称:Linux-C-Examples,代码行数:21,代码来源:main.cpp

示例5: run

void  MyThread::run(){
    /*把发送的数据 通知给界面*/ 
    LogReader   logreader;
    list<MatchedLogRec>  matches=logreader.readLogs();
    LogSender   logsender;
   // logsender.sendMatches(&matches);
    /*让界面显示具体发送了那些数据*/
    logsender.initNetWork();
    /*循环发送数据*/
    while(matches.size()>0){
         char  datastr[200]={0};
         if(!logsender.sendMatche(*(matches.begin()))){
              break; 
         }
         /*把发送成功的数据通知界面*/
         sprintf(datastr,"%s:%d:%s",matches.begin()->username,matches.begin()->pid,matches.begin()->logip); 
         emit   mySig(QString(datastr));    
         matches.erase(matches.begin()); 
         sleep(1);
    }    
   
}
开发者ID:dekai-wang,项目名称:TestCode,代码行数:22,代码来源:mythread.cpp

示例6: main

// Foreground waits for exit of the main persistent threads
// that are started here. The threads are created to manage
// UNIX domain client sockets for writing, reading and
// controlling the user space logger, and for any additional
// logging plugins like auditd and restart control. Additional
// transitory per-client threads are created for each reader.
int main(int argc, char *argv[]) {
    fdDmesg = open("/dev/kmsg", O_WRONLY);

    // issue reinit command. KISS argument parsing.
    if ((argc > 1) && argv[1] && !strcmp(argv[1], "--reinit")) {
        int sock = TEMP_FAILURE_RETRY(
            socket_local_client("logd",
                                ANDROID_SOCKET_NAMESPACE_RESERVED,
                                SOCK_STREAM));
        if (sock < 0) {
            return -errno;
        }
        static const char reinit[] = "reinit";
        ssize_t ret = TEMP_FAILURE_RETRY(write(sock, reinit, sizeof(reinit)));
        if (ret < 0) {
            return -errno;
        }
        struct pollfd p;
        memset(&p, 0, sizeof(p));
        p.fd = sock;
        p.events = POLLIN;
        ret = TEMP_FAILURE_RETRY(poll(&p, 1, 100));
        if (ret < 0) {
            return -errno;
        }
        if ((ret == 0) || !(p.revents & POLLIN)) {
            return -ETIME;
        }
        static const char success[] = "success";
        char buffer[sizeof(success) - 1];
        memset(buffer, 0, sizeof(buffer));
        ret = TEMP_FAILURE_RETRY(read(sock, buffer, sizeof(buffer)));
        if (ret < 0) {
            return -errno;
        }
        return strncmp(buffer, success, sizeof(success) - 1) != 0;
    }

    // Reinit Thread
    sem_init(&reinit, 0, 0);
    sem_init(&uidName, 0, 0);
    pthread_attr_t attr;
    if (!pthread_attr_init(&attr)) {
        struct sched_param param;

        memset(&param, 0, sizeof(param));
        pthread_attr_setschedparam(&attr, &param);
        pthread_attr_setschedpolicy(&attr, SCHED_BATCH);
        if (!pthread_attr_setdetachstate(&attr,
                                         PTHREAD_CREATE_DETACHED)) {
            pthread_t thread;
            reinit_running = true;
            if (pthread_create(&thread, &attr, reinit_thread_start, NULL)) {
                reinit_running = false;
            }
        }
        pthread_attr_destroy(&attr);
    }

    if (drop_privs() != 0) {
        return -1;
    }

    // Serves the purpose of managing the last logs times read on a
    // socket connection, and as a reader lock on a range of log
    // entries.

    LastLogTimes *times = new LastLogTimes();

    // LogBuffer is the object which is responsible for holding all
    // log entries.

    logBuf = new LogBuffer(times);

    signal(SIGHUP, reinit_signal_handler);

    {
        char property[PROPERTY_VALUE_MAX];
        property_get("ro.build.type", property, "");
        if (property_get_bool("logd.statistics",
                   !!strcmp(property, "user")
                && !property_get_bool("ro.config.low_ram", false))) {
            logBuf->enableStatistics();
        }
    }

    // LogReader listens on /dev/socket/logdr. When a client
    // connects, log entries in the LogBuffer are written to the client.

    LogReader *reader = new LogReader(logBuf);
    if (reader->startListener()) {
        exit(1);
    }

//.........这里部分代码省略.........
开发者ID:AOSP-JF,项目名称:platform_system_core,代码行数:101,代码来源:main.cpp

示例7: clienStatePointer

DWORD WINAPI LolSceneSwitch::MonitorThread(_In_ LPVOID lpParam)
{
	LolSceneSwitch * instance = static_cast<LolSceneSwitch *>(lpParam);
	unsigned int const INTERVALL = instance->settings.intervall;

	// Handles etc. for the client
	HANDLE clientProcess = nullptr;
	HWND clientWindow = nullptr;
	DWORD clientPid = 0;
	// Handles etc. for the game
	HANDLE gameProcess = nullptr;
	HWND gameWindow = nullptr;
	DWORD gamePid;
	FILETIME gameStartTime;
	// temp var for saving the exit code
	DWORD exitCode;

	// Used to read the log file
	LogReader * reader = nullptr;

	// Stuff for reading memory
	PointerPath32 clienStatePointer({ -0x658, 0x78, 0x610, 0x4, 0xe48 });
	PointerPath32 map1Pointer({ -0x9C0, 0x20 });
	PointerPath32 map2Pointer({ -0x9C4, 0x20 });
	DWORD clientStateAddress = 0;
	long clientState = 0;
	DWORD mapAddress = 0;

	// info variables of the state of LoL
	bool ingame = false;
	bool postGame = false;
	State state = State::CLIENTOUT;
	State oldState = State::CLIENTOUT;
	bool newMapInfo = false;

	// The main loop for monitoring LoL
	while (instance->runMonitoring)
	{
		// Try to get handles for the client and game process
		if (clientProcess == nullptr)
		{
			clientProcess = GetProcessByName(TEXT("LolClient.exe"), clientPid);
		}
		if (gameProcess == nullptr)
		{
			gameProcess = GetProcessByName(TEXT("League of Legends.exe"), gamePid);
			if (gameProcess != nullptr)
			{
				ingame = true; 
				FILETIME temp;
				GetProcessTimes(gameProcess, &gameStartTime, &temp, &temp, &temp);
			}
		}

		// We have a client handle
		if (clientProcess != nullptr)
		{
			// check if it's still running
			if (GetExitCodeProcess(clientProcess, &exitCode) && exitCode == STILL_ACTIVE)
			{
				if (clientWindow == nullptr)
				{
					clientWindow = GetWindowById(clientPid);
				}
				if (clientStateAddress == 0)
				{
					clientStateAddress = PointerPath32::GetThreadAddress(clientProcess, clientPid, 0);
				}

				if (!ingame)
				{
					if (instance->settings.scenes[State::CLIENTOUT].single.IsEmpty() ||
						(clientWindow != nullptr && HasFocus(clientWindow)))
					{
						if (clienStatePointer.Deref(clientProcess, clientStateAddress, clientState) && clientState == 1)
						{
							if (postGame)
							{
								state = State::POSTGAME;
							}
							else
							{
								state = State::CHAMPSELECT;
							}
						}
						else
						{
							postGame = false;
							state = State::CLIENT;
						}
					}
					else
					{
						state = State::CLIENTOUT;
					}
				}
			}
			else
			{
				Log("INFO  | LolSceneSwitch::MonitorThread | LoL client process exited!");
//.........这里部分代码省略.........
开发者ID:Hybris95,项目名称:LolSceneSwitch,代码行数:101,代码来源:LolSceneSwitch.cpp

示例8: if

	bool LogReader::Substit::process(LogReader &a_logReader, bool a_init)
	{
		if (m_resume < 0)
			return false;

		const __int64 l_fileSize = a_logReader.m_fileSize;
		const unsigned int l_maxFindSize = a_logReader.m_maxFindSize;
		__int64 &l_maxClose = a_logReader.m_maxClose;
		const __int64 l_testClose = l_fileSize - l_maxFindSize;
		if (m_prev == InvPtr)
		{
			if (m_resume >= l_testClose)
				l_maxClose = l_fileSize;
			else
				l_maxClose = m_resume + l_maxFindSize;

		}

		const __int64 l_maxEntry = l_maxClose - m_singles;
		if (m_resume > l_maxEntry)
			return false;

		if (m_anySeq)
		{
			if (m_next != InvPtr && m_next->type() == t_sample)
			{
				const Sample *const l_next = static_cast<const Sample *>(m_next);

				const char l_firstChar = l_next->m_data[0];
				const __int64 l_minClose = m_resume + m_singles;
				if (m_prev == InvPtr)
				{
					const __int64 l_found = a_logReader.find(l_minClose, l_fileSize, l_firstChar);
					if (a_logReader.m_status != s_ok || l_found < 0)
						return false;

					m_resume = l_found - m_singles;

					if (m_resume >= l_testClose)
						l_maxClose = l_fileSize;
					else
						l_maxClose = m_resume + l_maxFindSize;

				}
				else
				{
					const __int64 l_found = a_logReader.find(l_minClose, l_maxClose, l_firstChar);
					if (a_logReader.m_status != s_ok || l_found < 0)
						return false;

					m_resume = l_found - m_singles;

				}

			}

		}
		else if (!a_init)
			return false;

		const __int64 l_close = m_resume + m_singles;
		if (m_prev == InvPtr)
			a_logReader.m_findEntry = m_resume;

		if (m_next != InvPtr)
			m_next->m_resume = l_close;

		a_logReader.m_findClose = l_close;

		m_resume++;

		return true;

	}
开发者ID:rasim-valiullin,项目名称:d512388b-9b91-45f9-8f88-b6d4e252c270,代码行数:74,代码来源:logreader.cpp

示例9: main


//.........这里部分代码省略.........
        if (!pthread_attr_setdetachstate(&attr,
                                         PTHREAD_CREATE_DETACHED)) {
            pthread_t thread;
            reinit_running = true;
            if (pthread_create(&thread, &attr, reinit_thread_start, NULL)) {
                reinit_running = false;
            }
        }
        pthread_attr_destroy(&attr);
    }

    if (drop_privs() != 0) {
        return -1;
    }

    // Serves the purpose of managing the last logs times read on a
    // socket connection, and as a reader lock on a range of log
    // entries.

    LastLogTimes *times = new LastLogTimes();

    // LogBuffer is the object which is responsible for holding all
    // log entries.

    logBuf = new LogBuffer(times);

    signal(SIGHUP, reinit_signal_handler);

    if (property_get_bool("logd.statistics",
                          BOOL_DEFAULT_TRUE |
                          BOOL_DEFAULT_FLAG_PERSIST |
                          BOOL_DEFAULT_FLAG_ENG |
                          BOOL_DEFAULT_FLAG_SVELTE)) {
        logBuf->enableStatistics();
    }

    // LogReader listens on /dev/socket/logdr. When a client
    // connects, log entries in the LogBuffer are written to the client.

    LogReader *reader = new LogReader(logBuf);
    if (reader->startListener()) {
        exit(1);
    }

    // LogListener listens on /dev/socket/logdw for client
    // initiated log messages. New log entries are added to LogBuffer
    // and LogReader is notified to send updates to connected clients.

    LogListener *swl = new LogListener(logBuf, reader);
    // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value
    if (swl->startListener(600)) {
        exit(1);
    }

    // Command listener listens on /dev/socket/logd for incoming logd
    // administrative commands.

    CommandListener *cl = new CommandListener(logBuf, reader, swl);
    if (cl->startListener()) {
        exit(1);
    }

    // LogAudit listens on NETLINK_AUDIT socket for selinux
    // initiated log messages. New log entries are added to LogBuffer
    // and LogReader is notified to send updates to connected clients.

    bool auditd = property_get_bool("logd.auditd",
                                    BOOL_DEFAULT_TRUE |
                                    BOOL_DEFAULT_FLAG_PERSIST);
    LogAudit *al = NULL;
    if (auditd) {
        al = new LogAudit(logBuf, reader,
                          property_get_bool("logd.auditd.dmesg",
                                            BOOL_DEFAULT_TRUE |
                                            BOOL_DEFAULT_FLAG_PERSIST)
                          ? fdDmesg
                          : -1);
    }

    LogKlog *kl = NULL;
    if (klogd) {
        kl = new LogKlog(logBuf, reader, fdDmesg, fdPmesg, al != NULL);
    }

    readDmesg(al, kl);

    // failure is an option ... messages are in dmesg (required by standard)

    if (kl && kl->startListener()) {
        delete kl;
    }

    if (al && al->startListener()) {
        delete al;
    }

    TEMP_FAILURE_RETRY(pause());

    exit(0);
}
开发者ID:Lakshmipathi,项目名称:platform_system_core,代码行数:101,代码来源:main.cpp

示例10: main

// Foreground waits for exit of the main persistent threads
// that are started here. The threads are created to manage
// UNIX domain client sockets for writing, reading and
// controlling the user space logger, and for any additional
// logging plugins like auditd and restart control. Additional
// transitory per-client threads are created for each reader.
int main(int argc, char* argv[]) {
    // logd is written under the assumption that the timezone is UTC.
    // If TZ is not set, persist.sys.timezone is looked up in some time utility
    // libc functions, including mktime. It confuses the logd time handling,
    // so here explicitly set TZ to UTC, which overrides the property.
    setenv("TZ", "UTC", 1);
    // issue reinit command. KISS argument parsing.
    if ((argc > 1) && argv[1] && !strcmp(argv[1], "--reinit")) {
        return issueReinit();
    }

    static const char dev_kmsg[] = "/dev/kmsg";
    fdDmesg = android_get_control_file(dev_kmsg);
    if (fdDmesg < 0) {
        fdDmesg = TEMP_FAILURE_RETRY(open(dev_kmsg, O_WRONLY | O_CLOEXEC));
    }

    int fdPmesg = -1;
    bool klogd = __android_logger_property_get_bool(
        "logd.kernel", BOOL_DEFAULT_TRUE | BOOL_DEFAULT_FLAG_PERSIST |
                           BOOL_DEFAULT_FLAG_ENG | BOOL_DEFAULT_FLAG_SVELTE);
    if (klogd) {
        static const char proc_kmsg[] = "/proc/kmsg";
        fdPmesg = android_get_control_file(proc_kmsg);
        if (fdPmesg < 0) {
            fdPmesg = TEMP_FAILURE_RETRY(
                open(proc_kmsg, O_RDONLY | O_NDELAY | O_CLOEXEC));
        }
        if (fdPmesg < 0) android::prdebug("Failed to open %s\n", proc_kmsg);
    }

    // Reinit Thread
    sem_init(&reinit, 0, 0);
    sem_init(&uidName, 0, 0);
    sem_init(&sem_name, 0, 1);
    pthread_attr_t attr;
    if (!pthread_attr_init(&attr)) {
        struct sched_param param;

        memset(&param, 0, sizeof(param));
        pthread_attr_setschedparam(&attr, &param);
        pthread_attr_setschedpolicy(&attr, SCHED_BATCH);
        if (!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
            pthread_t thread;
            reinit_running = true;
            if (pthread_create(&thread, &attr, reinit_thread_start, nullptr)) {
                reinit_running = false;
            }
        }
        pthread_attr_destroy(&attr);
    }

    bool auditd =
        __android_logger_property_get_bool("ro.logd.auditd", BOOL_DEFAULT_TRUE);
    if (drop_privs(klogd, auditd) != 0) {
        return -1;
    }

    // Serves the purpose of managing the last logs times read on a
    // socket connection, and as a reader lock on a range of log
    // entries.

    LastLogTimes* times = new LastLogTimes();

    // LogBuffer is the object which is responsible for holding all
    // log entries.

    logBuf = new LogBuffer(times);

    signal(SIGHUP, reinit_signal_handler);

    if (__android_logger_property_get_bool(
            "logd.statistics", BOOL_DEFAULT_TRUE | BOOL_DEFAULT_FLAG_PERSIST |
                                   BOOL_DEFAULT_FLAG_ENG |
                                   BOOL_DEFAULT_FLAG_SVELTE)) {
        logBuf->enableStatistics();
    }

    // LogReader listens on /dev/socket/logdr. When a client
    // connects, log entries in the LogBuffer are written to the client.

    LogReader* reader = new LogReader(logBuf);
    if (reader->startListener()) {
        exit(1);
    }

    // LogListener listens on /dev/socket/logdw for client
    // initiated log messages. New log entries are added to LogBuffer
    // and LogReader is notified to send updates to connected clients.

    LogListener* swl = new LogListener(logBuf, reader);
    // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value
    if (swl->startListener(600)) {
        exit(1);
//.........这里部分代码省略.........
开发者ID:BenzoRoms,项目名称:system_core,代码行数:101,代码来源:main.cpp

示例11: main

// Foreground waits for exit of the three main persistent threads that
// are started here.  The three threads are created to manage UNIX
// domain client sockets for writing, reading and controlling the user
// space logger.  Additional transitory per-client threads are created
// for each reader once they register.
int main() {
    int fdDmesg = -1;
    char dmesg[PROPERTY_VALUE_MAX];
    property_get("logd.auditd.dmesg", dmesg, "1");
    if (atol(dmesg)) {
        fdDmesg = open("/dev/kmsg", O_WRONLY);
    }

    if (drop_privs() != 0) {
        return -1;
    }

    // Serves the purpose of managing the last logs times read on a
    // socket connection, and as a reader lock on a range of log
    // entries.

    LastLogTimes *times = new LastLogTimes();

    // LogBuffer is the object which is responsible for holding all
    // log entries.

    LogBuffer *logBuf = new LogBuffer(times);

    char dgram_qlen_statistics[PROPERTY_VALUE_MAX];
    property_get("logd.dgram_qlen.statistics", dgram_qlen_statistics, "");
    if (atol(dgram_qlen_statistics)) {
        logBuf->enableDgramQlenStatistics();
    }

    // LogReader listens on /dev/socket/logdr. When a client
    // connects, log entries in the LogBuffer are written to the client.

    LogReader *reader = new LogReader(logBuf);
    if (reader->startListener()) {
        exit(1);
    }

    // LogListener listens on /dev/socket/logdw for client
    // initiated log messages. New log entries are added to LogBuffer
    // and LogReader is notified to send updates to connected clients.

    LogListener *swl = new LogListener(logBuf, reader);
    // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value
    if (swl->startListener(300)) {
        exit(1);
    }

    // Command listener listens on /dev/socket/logd for incoming logd
    // administrative commands.

    CommandListener *cl = new CommandListener(logBuf, reader, swl);
    if (cl->startListener()) {
        exit(1);
    }

    // LogAudit listens on NETLINK_AUDIT socket for selinux
    // initiated log messages. New log entries are added to LogBuffer
    // and LogReader is notified to send updates to connected clients.

    // failure is an option ... messages are in dmesg (required by standard)
    LogAudit *al = new LogAudit(logBuf, reader, fdDmesg);
    if (al->startListener()) {
        delete al;
        close(fdDmesg);
    }

    pause();
    exit(0);
}
开发者ID:darkenk,项目名称:android-core,代码行数:74,代码来源:main.cpp

示例12: setup

void Replay::setup()
{
    ::printf("Starting\n");

    uint8_t argc;
    char * const *argv;

    hal.util->commandline_arguments(argc, argv);

    _parse_command_line(argc, argv);

    if (!check_generate) {
        logreader.set_save_chek_messages(true);
    }

    // _parse_command_line sets up an FPE handler.  We can do better:
    signal(SIGFPE, _replay_sig_fpe);

    hal.console->printf("Processing log %s\n", filename);

    // remember filename for reporting
    log_filename = filename;

    if (!find_log_info(log_info)) {
        printf("Update to get log information\n");
        exit(1);
    }

    hal.console->printf("Using an update rate of %u Hz\n", log_info.update_rate);

    if (!logreader.open_log(filename)) {
        perror(filename);
        exit(1);
    }

    _vehicle.setup();

    inhibit_gyro_cal();
    set_ins_update_rate(log_info.update_rate);

    feenableexcept(FE_INVALID | FE_OVERFLOW);


    plotf = fopen("plot.dat", "w");
    plotf2 = fopen("plot2.dat", "w");
    ekf1f = fopen("EKF1.dat", "w");
    ekf2f = fopen("EKF2.dat", "w");
    ekf3f = fopen("EKF3.dat", "w");
    ekf4f = fopen("EKF4.dat", "w");

    fprintf(plotf, "time SIM.Roll SIM.Pitch SIM.Yaw BAR.Alt FLIGHT.Roll FLIGHT.Pitch FLIGHT.Yaw FLIGHT.dN FLIGHT.dE FLIGHT.Alt AHR2.Roll AHR2.Pitch AHR2.Yaw DCM.Roll DCM.Pitch DCM.Yaw EKF.Roll EKF.Pitch EKF.Yaw INAV.dN INAV.dE INAV.Alt EKF.dN EKF.dE EKF.Alt\n");
    fprintf(plotf2, "time E1 E2 E3 VN VE VD PN PE PD GX GY GZ WN WE MN ME MD MX MY MZ E1ref E2ref E3ref\n");
    fprintf(ekf1f, "timestamp TimeMS Roll Pitch Yaw VN VE VD PN PE PD GX GY GZ\n");
    fprintf(ekf2f, "timestamp TimeMS AX AY AZ VWN VWE MN ME MD MX MY MZ\n");
    fprintf(ekf3f, "timestamp TimeMS IVN IVE IVD IPN IPE IPD IMX IMY IMZ IVT\n");
    fprintf(ekf4f, "timestamp TimeMS SV SP SH SMX SMY SMZ SVT OFN EFE FS DS\n");
}
开发者ID:uzzndw,项目名称:ardupilot,代码行数:57,代码来源:Replay.cpp

示例13: set_user_parameters

/*
  setup user -p parameters
 */
void Replay::set_user_parameters(void)
{
    for (uint8_t i=0; i<num_user_parameters; i++) {
        if (!logreader.set_parameter(user_parameters[i].name, user_parameters[i].value)) {
            ::printf("Failed to set parameter %s to %f\n", user_parameters[i].name, user_parameters[i].value);
            exit(1);
        }
    }
}
开发者ID:BellX1,项目名称:ardupilot,代码行数:12,代码来源:Replay.cpp

示例14: log_check_solution

/*
  check current solution against CHEK message
 */
void Replay::log_check_solution(void)
{
    const LR_MsgHandler::CheckState &check_state = logreader.get_check_state();
    Vector3f euler;
    Vector3f velocity;
    Location loc {};

    _vehicle.EKF.getEulerAngles(euler);
    _vehicle.EKF.getVelNED(velocity);
    _vehicle.EKF.getLLH(loc);

    float roll_error  = degrees(fabsf(euler.x - check_state.euler.x));
    float pitch_error = degrees(fabsf(euler.y - check_state.euler.y));
    float yaw_error = wrap_180_cd(100*degrees(fabsf(euler.z - check_state.euler.z)))*0.01f;
    float vel_error = (velocity - check_state.velocity).length();
    float pos_error = get_distance(check_state.pos, loc);

    check_result.max_roll_error  = MAX(check_result.max_roll_error,  roll_error);
    check_result.max_pitch_error = MAX(check_result.max_pitch_error, pitch_error);
    check_result.max_yaw_error   = MAX(check_result.max_yaw_error,   yaw_error);
    check_result.max_vel_error   = MAX(check_result.max_vel_error,   vel_error);
    check_result.max_pos_error   = MAX(check_result.max_pos_error,   pos_error);
}
开发者ID:BellX1,项目名称:ardupilot,代码行数:26,代码来源:Replay.cpp

示例15: loop

void Replay::loop()
{
    while (true) {
        char type[5];

        if (arm_time_ms >= 0 && AP_HAL::millis() > (uint32_t)arm_time_ms) {
            if (!hal.util->get_soft_armed()) {
                hal.util->set_soft_armed(true);
                ::printf("Arming at %u ms\n", (unsigned)AP_HAL::millis());
            }
        }

        if (!logreader.update(type)) {
            ::printf("End of log at %.1f seconds\n", AP_HAL::millis()*0.001f);
            fclose(plotf);
            break;
        }
        read_sensors(type);

        if (streq(type,"ATT")) {
            Vector3f ekf_euler;
            Vector3f velNED;
            Vector3f posNED;
            Vector3f gyroBias;
            float accelWeighting;
            float accelZBias1;
            float accelZBias2;
            Vector3f windVel;
            Vector3f magNED;
            Vector3f magXYZ;
            Vector3f DCM_attitude;
            Vector3f ekf_relpos;
            Vector3f velInnov;
            Vector3f posInnov;
            Vector3f magInnov;
            float    tasInnov;
            float velVar;
            float posVar;
            float hgtVar;
            Vector3f magVar;
            float tasVar;
            Vector2f offset;
            uint16_t faultStatus;

            const Matrix3f &dcm_matrix = _vehicle.ahrs.AP_AHRS_DCM::get_rotation_body_to_ned();
            dcm_matrix.to_euler(&DCM_attitude.x, &DCM_attitude.y, &DCM_attitude.z);
            _vehicle.EKF.getEulerAngles(ekf_euler);
            _vehicle.EKF.getVelNED(velNED);
            _vehicle.EKF.getPosNED(posNED);
            _vehicle.EKF.getGyroBias(gyroBias);
            _vehicle.EKF.getIMU1Weighting(accelWeighting);
            _vehicle.EKF.getAccelZBias(accelZBias1, accelZBias2);
            _vehicle.EKF.getWind(windVel);
            _vehicle.EKF.getMagNED(magNED);
            _vehicle.EKF.getMagXYZ(magXYZ);
            _vehicle.EKF.getInnovations(velInnov, posInnov, magInnov, tasInnov);
            _vehicle.EKF.getVariances(velVar, posVar, hgtVar, magVar, tasVar, offset);
            _vehicle.EKF.getFilterFaults(faultStatus);
            _vehicle.EKF.getPosNED(ekf_relpos);
            Vector3f inav_pos = _vehicle.inertial_nav.get_position() * 0.01f;
            float temp = degrees(ekf_euler.z);

            if (temp < 0.0f) temp = temp + 360.0f;
            fprintf(plotf, "%.3f %.1f %.1f %.1f %.2f %.1f %.1f %.1f %.2f %.2f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.2f %.2f %.2f %.2f %.2f %.2f\n",
                    AP_HAL::millis() * 0.001f,
                    logreader.get_sim_attitude().x,
                    logreader.get_sim_attitude().y,
                    logreader.get_sim_attitude().z,
                    _vehicle.barometer.get_altitude(),
                    logreader.get_attitude().x,
                    logreader.get_attitude().y,
                    wrap_180_cd(logreader.get_attitude().z*100)*0.01f,
                    logreader.get_inavpos().x,
                    logreader.get_inavpos().y,
                    logreader.get_ahr2_attitude().x,
                    logreader.get_ahr2_attitude().y,
                    wrap_180_cd(logreader.get_ahr2_attitude().z*100)*0.01f,
                    degrees(DCM_attitude.x),
                    degrees(DCM_attitude.y),
                    degrees(DCM_attitude.z),
                    degrees(ekf_euler.x),
                    degrees(ekf_euler.y),
                    degrees(ekf_euler.z),
                    inav_pos.x,
                    inav_pos.y,
                    inav_pos.z,
                    ekf_relpos.x,
                    ekf_relpos.y,
                    -ekf_relpos.z);
            fprintf(plotf2, "%.3f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f\n",
                    AP_HAL::millis() * 0.001f,
                    degrees(ekf_euler.x),
                    degrees(ekf_euler.y),
                    temp,
                    velNED.x, 
                    velNED.y, 
                    velNED.z, 
                    posNED.x, 
                    posNED.y, 
                    posNED.z, 
//.........这里部分代码省略.........
开发者ID:BellX1,项目名称:ardupilot,代码行数:101,代码来源:Replay.cpp


注:本文中的LogReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。