define line for log-entry
This commit is contained in:
		
							
								
								
									
										69
									
								
								common/include/log_line_entry.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								common/include/log_line_entry.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
				
			|||||||
 | 
					#ifndef LOG_LINE_ENTRY_H_INCLUDED
 | 
				
			||||||
 | 
					#define LOG_LINE_ENTRY_H_INCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <algorithm>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct LogLineEntry {
 | 
				
			||||||
 | 
					    char receiver;      // 1    receiver can be: ISMAS
 | 
				
			||||||
 | 
					    char reason[5];     // 6    SW_UP
 | 
				
			||||||
 | 
					    char timestamp[19]; // 25   ISO-format: 1900-xx-xxT00:00:00
 | 
				
			||||||
 | 
					    char eventId;       // 26
 | 
				
			||||||
 | 
					    char event[5];      // 31
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					        Note:
 | 
				
			||||||
 | 
					        ! After U0002 immer ein CMD_SENDVERSION
 | 
				
			||||||
 | 
					        ! Only U0002 and U0003 finish the Update process.
 | 
				
			||||||
 | 
					        ! U0001: Update finished but not activated
 | 
				
			||||||
 | 
					        ! U0002: Update finished and activated
 | 
				
			||||||
 | 
					        ! U0003: Update finished but FAILed.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // #define _ISMAS_DONE                 "U0001" // 100%, Check: Resultcode: 0
 | 
				
			||||||
 | 
					    // #define _ISMAS_SET_WAIT_OK          "U0002" // empty WAIT-button (""), ResultCode: 0
 | 
				
			||||||
 | 
					    // #define _ISMAS_NO_UPDATE_NECESSARY  "M0100" // empty WAIT-button (""), ResultCode: 0
 | 
				
			||||||
 | 
					    // #define _ISMAS_FAILURE              "U0003" // FAIL
 | 
				
			||||||
 | 
					    // #define _ISMAS_CONTINUE             "U0010" // %-values: Update laeuft, Resultcodes entsprechend laufender Schritt
 | 
				
			||||||
 | 
					    // #define _ISMAS_RESET_WAIT           "ISMAS" // reset WAIT-button to "WAIT"
 | 
				
			||||||
 | 
					    // #define _ISMAS_TEST_TRIGGER         "U0099" // check the WAIT-button
 | 
				
			||||||
 | 
					    char eventState;    // 32
 | 
				
			||||||
 | 
					    char percent;       // 33   percent in progressbar of update-tool
 | 
				
			||||||
 | 
					    char resultCode;    // 34
 | 
				
			||||||
 | 
					    char step[40];      // 74   step executed
 | 
				
			||||||
 | 
					    char stepResult[40];// 114  result for step
 | 
				
			||||||
 | 
					    char version[13];   // 127
 | 
				
			||||||
 | 
					    char dummy;         // 128
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline static LogLineEntry initLogLineEntry(
 | 
				
			||||||
 | 
					    char const receiver,
 | 
				
			||||||
 | 
					    char const timestamp[19],
 | 
				
			||||||
 | 
					    char const event[5],
 | 
				
			||||||
 | 
					    char const eventState,
 | 
				
			||||||
 | 
					    char const percent,
 | 
				
			||||||
 | 
					    char const resultCode,
 | 
				
			||||||
 | 
					    char const step[40],
 | 
				
			||||||
 | 
					    char const stepResult[40],
 | 
				
			||||||
 | 
					    char const eventId = 0,
 | 
				
			||||||
 | 
					    char const reason[5] = "SW_UP",
 | 
				
			||||||
 | 
					    char const version[14] = "") {
 | 
				
			||||||
 | 
					    LogLineEntry e;
 | 
				
			||||||
 | 
					    memset(&e, 0, sizeof(e));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    e.receiver = receiver;
 | 
				
			||||||
 | 
					    std::memcpy(e.reason, reason, std::min(sizeof(e.reason), strlen(reason)));
 | 
				
			||||||
 | 
					    std::memcpy(e.timestamp, timestamp, std::min(sizeof(e.timestamp), strlen(timestamp)));
 | 
				
			||||||
 | 
					    e.eventId = eventId;
 | 
				
			||||||
 | 
					    std::memcpy(e.event, event, std::min(sizeof(e.event), strlen(event)));
 | 
				
			||||||
 | 
					    e.eventState = eventState;
 | 
				
			||||||
 | 
					    e.percent = percent;
 | 
				
			||||||
 | 
					    e.resultCode = resultCode;
 | 
				
			||||||
 | 
					    std::memcpy(e.step, step, std::min(sizeof(e.step), strlen(step)));
 | 
				
			||||||
 | 
					    std::memcpy(e.stepResult, stepResult, std::min(sizeof(e.stepResult), strlen(stepResult)));
 | 
				
			||||||
 | 
					    std::memcpy(e.version, version, std::min(sizeof(e.version), strlen(version)));
 | 
				
			||||||
 | 
					    e.dummy = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return e;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // LOG_LINE_ENTRY_H_INCLUDED
 | 
				
			||||||
		Reference in New Issue
	
	Block a user