tape/tape.h

Go to the documentation of this file.
00001 
00005 #ifndef _TAPE_H
00006 #define _TAPE_H
00007 
00008 #include "gridlabd.h"
00009 #include "object.h"
00010 #include "aggregate.h"
00011 #include "memory.h"
00012 
00013 /* tape global controls */
00014 static char timestamp_format[32]="%Y-%m-%d %H:%M:%S";
00015 typedef enum {VT_INTEGER, VT_DOUBLE, VT_STRING} VARIABLETYPE;
00016 typedef enum {TS_INIT, TS_OPEN, TS_DONE, TS_ERROR} TAPESTATUS;
00017 typedef enum {FT_FILE, FT_ODBC, FT_MEMORY} FILETYPE;
00018 
00019 typedef struct s_tape_operations {
00020     int (*open)(void *my, char *fname, char *flags);
00021     char *(*read)(void *my,char *buffer,unsigned int size);
00022     int (*write)(void *my, char *timestamp, char *value);
00023     int (*rewind)(void *my);
00024     void (*close)(void *my);
00025 } TAPEOPS;
00026 
00027 typedef struct s_tape_funcs {
00028     char256 mode;
00029     void *hLib;
00030     TAPEOPS *player;
00031     TAPEOPS *shaper;
00032     TAPEOPS *recorder;
00033     TAPEOPS *collector;
00034     struct s_tape_funcs *next;
00035 } TAPEFUNCS;
00036 
00037 TAPEFUNCS *get_ftable(char *mode);
00038 
00039 typedef struct {
00040     char *name;
00041     VARIABLETYPE type;
00042     void *addr;
00043     double min, max;
00044 } VARMAP;
00045 
00049 struct player {
00050     /* public */
00051     char1024 file; 
00052     char8 filetype; 
00053     char32 property; 
00054     int32 loop; 
00055     /* private */
00056     FILETYPE type;
00057     union {
00058         FILE *fp;
00059         MEMORY *memory;
00060         void *tsp;
00062     };
00063     TAPESTATUS status;
00064     int32 loopnum;
00065     struct {
00066         TIMESTAMP ts;
00067         char32 value;
00068     } next;
00069     PROPERTY *target;
00070     TAPEOPS *ops;
00071 }; 
00076 typedef struct s_shapertarget {
00077     double *addr; 
00078     TIMESTAMP ts; 
00079     double value; 
00080 } SHAPERTARGET; 
00082 struct shaper {
00083     /* public */
00084     char1024 file; 
00085     char8 filetype; 
00086     char32 property; 
00087     char256 group; 
00088     double magnitude;   
00089     double events;      /* the number of queue events per interval (\p events = 0 => direct shape)*/
00090     /* private */
00091     TAPEOPS *ops;
00092     FILETYPE type;
00093     union {
00094         FILE *fp;
00095         MEMORY *memory;
00096         void *tsp;
00098     };
00099     TAPESTATUS status;
00100     int16 interval; /* the interval over which events is counted (usually 24) */
00101     int16 step;     /* the duration of a single step in the shape integral (usually 3600s) */
00102     double scale;   /* the scaling of the shape over the interval */
00103     int32 loopnum;
00104     unsigned char shape[12][31][7][24];
00105 #define SHAPER_QUEUE 0x0001
00106     unsigned int n_targets;
00107     SHAPERTARGET *targets;
00108 };
00113 struct recorder {
00114     /* public */
00115     char1024 file;
00116     char8 filetype;
00117     int16 format; /* 0=YYYY-MM-DD HH:MM:SS; 1=timestamp */
00118     TIMESTAMP interval;
00119     int32 limit;
00120     char1024 property;
00121     char32 trigger;
00122     /* private */
00123     TAPEOPS *ops;
00124     FILETYPE type;
00125     union {
00126         FILE *fp;
00127         MEMORY *memory;
00128         void *tsp;
00130     };
00131     TAPESTATUS status;
00132     char8 delim;
00133     struct {
00134         TIMESTAMP ts;
00135         char1024 value;
00136     } last;
00137     int32 samples;
00138     PROPERTY *target;
00139 };
00144 struct collector {
00145     /* public */
00146     char1024 file;
00147     char8 filetype;
00148     int16 format; /* 0=YYYY-MM-DD HH:MM:SS; 1=timestamp */
00149     TIMESTAMP interval;
00150     int32 limit;
00151     char1024 property;
00152     char32 trigger;
00153     char256 group;
00154     /* private */
00155     TAPEOPS *ops;
00156     FILETYPE type;
00157     union {
00158         FILE *fp;
00159         MEMORY *memory;
00160         void *tsp;
00162     };
00163     TAPESTATUS status;
00164     char8 delim;
00165     struct {
00166         TIMESTAMP ts;
00167         char1024 value;
00168     } last;
00169     int32 samples;
00170     AGGREGATION *aggr;
00171 };
00173 #endif

GridLAB-DTM Version 1.0
An open-source project initiated by the US Department of Energy