rllib  1
rldataacquisitionprovider.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                 rldataacquisitionprovider.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_PROVIDER_H_
00017 #define _RL_DAQ_PROVIDER_H_
00018 
00019 #include "rldefine.h"
00020 #include "rlsharedmemory.h"
00021 
00027 class rlDataAcquisitionProvider
00028 {
00029 public:
00030   // shared memory header
00031   typedef struct
00032   {
00033     char ident[4];          // must be "daq"
00034     int  maxItemNameLength; // maximum length of an item name
00035     int  maxNameLength;     // maximum length of the item value
00036     int  numItems;          // number of items in shared memory
00037     int  readErrorCount;    // 0...65536 incremented by each read error
00038     int  writeErrorCount;   // 0...65536 incremented by each write error
00039     int  lifeCounter;       // 0...65536 incremented each cycle
00040     int  spare[7];          // for future use
00041     char cspare[32];        // for future use
00042   }SHM_HEADER;
00043   
00044   enum DAQ_PROVIDER_ENUM
00045   {
00046     DAQ_PROVIDER_ERROR = 256*256*128
00047   };
00048 
00049 #ifdef RLWIN32  
00050   rlDataAcquisitionProvider(int maxNameLength=31, const char *shared_memory="c:\\automation\\shm\\dataacquisition.shm", long shared_memory_size=65536);
00051 #else
00052   rlDataAcquisitionProvider(int maxNameLength=31, const char *shared_memory="/srv/automation/shm/dataacquisition.shm", long shared_memory_size=65536);
00053 #endif
00054   virtual    ~rlDataAcquisitionProvider();
00055   int         readItemList(const char *filename); // return DAQ_PROVIDER_ERROR | num_items
00056   const char *firstItem();
00057   const char *nextItem();
00058   const char *stringValue(const char *variable);
00059   int         intValue(const char *variable);
00060   float       floatValue(const char *variable);
00061   int         setStringValue(const char *variable, const char *value);
00062   int         setIntValue(const char *variable, int value);
00063   int         setFloatValue(const char *variable, float value);
00064   int         readErrorCount();
00065   int         writeErrorCount();
00066   int         lifeCounter();
00067   int         setReadErrorCount(int count);
00068   int         setWriteErrorCount(int count);
00069   int         setLifeCounter(int count);
00070   int         shmStatus(); // 0 if shared memory is ok | DAQ_PROVIDER_ERROR if shared memory is not ok
00071   int         setAllowAddValues(int allow, int maxItemNameLength);
00072 
00073 private:
00074   SHM_HEADER     *shmheader;
00075   char           *shmvalues;
00076   int             current_item, allow_add_values;
00077   rlSharedMemory *shm;
00078   long            sharedMemorySize;
00079 };
00080 
00081 #endif
00082