C_runtime/PLCObject.hpp
changeset 3945 d303aab8f68b
parent 3940 934bd46a7500
child 3949 f64dce4e2f62
equal deleted inserted replaced
3944:ebd25bbe5a73 3945:d303aab8f68b
     6 #if !defined(_PLCObject_hpp_)
     6 #if !defined(_PLCObject_hpp_)
     7 #define _PLCObject_hpp_
     7 #define _PLCObject_hpp_
     8 
     8 
     9 #include <map>
     9 #include <map>
    10 #include <vector>
    10 #include <vector>
       
    11 #include <mutex>
       
    12 #include <thread>
       
    13  
    11 #include "blob.hpp"
    14 #include "blob.hpp"
    12 
    15 
    13 #include "erpc_PLCObject_interface.hpp"
    16 #include "erpc_PLCObject_interface.hpp"
    14 
    17 
    15 using namespace erpcShim;
    18 using namespace erpcShim;
    34     int (*startPLC)(int argc,char **argv);
    37     int (*startPLC)(int argc,char **argv);
    35     int (*stopPLC)(void);
    38     int (*stopPLC)(void);
    36     void (*ResetDebugVariables)(void);
    39     void (*ResetDebugVariables)(void);
    37     int (*RegisterDebugVariable)(unsigned int idx, void* force, size_t force_size);
    40     int (*RegisterDebugVariable)(unsigned int idx, void* force, size_t force_size);
    38     void (*FreeDebugData)(void);
    41     void (*FreeDebugData)(void);
    39     int (*GetDebugData)(unsigned long *tick, unsigned long *size, void **buffer);
    42     int (*GetDebugData)(unsigned int *tick, unsigned int *size, void **buffer);
    40     int (*suspendDebug)(int disable);
    43     int (*suspendDebug)(int disable);
    41     void (*ResumeDebug)(void);
    44     void (*ResumeDebug)(void);
    42     void (*ResetLogCount)(void);
    45     void (*ResetLogCount)(void);
    43     uint32_t (*GetLogCount)(uint8_t level);
    46     uint32_t (*GetLogCount)(uint8_t level);
    44     int (*LogMessage)(uint8_t level, char* buf, uint32_t size);
    47     int (*LogMessage)(uint8_t level, char* buf, uint32_t size);
    62         uint32_t NewPLC(const char * md5sum, const binary_t * plcObjectBlobID, const list_extra_file_1_t * extrafiles, bool * success);
    65         uint32_t NewPLC(const char * md5sum, const binary_t * plcObjectBlobID, const list_extra_file_1_t * extrafiles, bool * success);
    63         uint32_t PurgeBlobs(void);
    66         uint32_t PurgeBlobs(void);
    64         uint32_t RepairPLC(void);
    67         uint32_t RepairPLC(void);
    65         uint32_t ResetLogCount(void);
    68         uint32_t ResetLogCount(void);
    66         uint32_t SeedBlob(const binary_t * seed, binary_t * blobID);
    69         uint32_t SeedBlob(const binary_t * seed, binary_t * blobID);
    67         uint32_t SetTraceVariablesList(const list_trace_order_1_t * orders, uint32_t * debugtoken);
    70         uint32_t SetTraceVariablesList(const list_trace_order_1_t * orders, int32_t * debugtoken);
    68         uint32_t StartPLC(void);
    71         uint32_t StartPLC(void);
    69         uint32_t StopPLC(bool * success);
    72         uint32_t StopPLC(bool * success);
    70 
       
    71         // 
       
    72 
    73 
    73     private:
    74     private:
    74         // A map of all the blobs
    75         // A map of all the blobs
    75         std::map<std::vector<uint8_t>, Blob*> m_mapBlobIDToBlob;
    76         std::map<std::vector<uint8_t>, Blob*> m_mapBlobIDToBlob;
    76 
    77 
    77         // PLC object library handle
    78         // PLC object library handle
    78         void * m_handle;
    79         void * m_handle;
       
    80 
       
    81         // Shared object mutex
       
    82         std::mutex m_PLClibMutex;
    79 
    83 
    80         // Symbols resolved from the PLC object
    84         // Symbols resolved from the PLC object
    81         PLCSyms m_PLCSyms;
    85         PLCSyms m_PLCSyms;
    82 
    86 
    83         // argc and argv for the PLC object
    87         // argc and argv for the PLC object
    88         PLCstatus m_status;
    92         PLCstatus m_status;
    89 
    93 
    90         // PLC ID
    94         // PLC ID
    91         PSKID m_plcID;
    95         PSKID m_plcID;
    92 
    96 
       
    97         // Debug token, used for consistency check of traces
       
    98         uint32_t m_debugToken;
       
    99 
       
   100         // Trace thread
       
   101         std::thread m_traceThread;
       
   102 
       
   103         // Trace thread mutex
       
   104         std::mutex m_tracesMutex;
       
   105 
       
   106         // Trace double buffer
       
   107         std::vector<trace_sample> m_traces;
       
   108 
    93         uint32_t BlobAsFile(const binary_t * BlobID, std::filesystem::path filename);
   109         uint32_t BlobAsFile(const binary_t * BlobID, std::filesystem::path filename);
    94         uint32_t LoadPLC(void);
   110         uint32_t LoadPLC(void);
    95         uint32_t UnLoadPLC(void);
   111         uint32_t UnLoadPLC(void);
    96         uint32_t LogMessage(uint8_t level, std::string message);
   112         uint32_t LogMessage(uint8_t level, std::string message);
    97  
   113         uint32_t PurgePLC(void);
    98 
   114         void TraceThreadProc(void);
    99 
       
   100 
       
   101 
       
   102     
       
   103 };
   115 };
   104 
   116 
   105 #endif
   117 #endif