00001 /*************************************************************************** 00002 rldataacquisition.h - description 00003 ------------------- 00004 begin : Mon Sep 03 2007 00005 copyright : (C) 2007 by pvbrowser 00006 email : lehrig@t-online.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This library is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * 00013 * published by the Free Software Foundation * 00014 * * 00015 ***************************************************************************/ 00016 #ifndef _RL_DAQ_H_ 00017 #define _RL_DAQ_H_ 00018 00019 #include "rldefine.h" 00020 #include "rlmailbox.h" 00021 #include "rlsharedmemory.h" 00022 00028 class rlDataAcquisition 00029 { 00030 public: 00031 // shared memory header 00032 typedef struct 00033 { 00034 char ident[4]; // must be "daq" 00035 int maxItemNameLength; // maximum length of an item name 00036 int maxNameLength; // maximum length of the item value 00037 int numItems; // number of items in shared memory 00038 int readErrorCount; // 0...65536 incremented by each read error 00039 int writeErrorCount; // 0...65536 incremented by each write error 00040 int spare[8]; // for future use 00041 char cspare[32]; // for future use 00042 }SHM_HEADER; 00043 00044 enum DAQ_ENUM 00045 { 00046 DAQ_ERROR = 256*256*128 00047 }; 00048 00049 #ifdef RLWIN32 00050 rlDataAcquisition(const char *mailbox="c:\\automation\\mbx\\dataacquisition.mbx", const char *shared_memory="c:\\automation\\shm\\dataacquisition.shm", long shared_memory_size=65536); 00051 #else 00052 rlDataAcquisition(const char *mailbox="/srv/automation/mbx/dataacquisition.mbx", const char *shared_memory="/srv/automation/shm/dataacquisition.shm", long shared_memory_size=65536); 00053 #endif 00054 virtual ~rlDataAcquisition(); 00055 const char *stringValue(const char *variable); 00056 int intValue(const char *variable); 00057 float floatValue(const char *variable); 00058 int writeStringValue(const char *variable, const char *value); 00059 int writeIntValue(const char *variable, int value); 00060 int writeFloatValue(const char *variable, float value); 00061 int readErrorCount(); 00062 int writeErrorCount(); 00063 const char *firstVariable(); 00064 const char *nextVariable(); 00065 int shmStatus(); // 0 if shared memory is ok | DAQ_ERROR if shared memory is not ok 00066 00067 private: 00068 SHM_HEADER *shmheader; 00069 const char *shmvalues; 00070 rlMailbox *mbx; 00071 rlSharedMemory *shm; 00072 int iCurrent; 00073 }; 00074 00075 #endif 00076
1.6.3