Memory Tapes
[Players and recorders (tape)]


Detailed Description

The Memory tape type was originally created to provide a work buffer for Matlab in memory space that GridLAB-D could access.

It works by allocating a large block of memory as a global variable, which can be accessed at any time by any module. The tapes specifically wrap this allocated block with tape functionality.

The global variables referenced by a Memory tape MUST exist before the tape attempts to “open” them during the first sync call, and the user must include the size limits in the tape properties to prevent memory overflow. There does not appear to be any method to data-drive the data to or from files. The contents of a Memory tape must be set or retrieved programmatically.

Memory types are arranged as an interleaved array of double timestamps and double values within a malloc’ed block. Properly arranging these values, and not overrunning the buffer, is the responsibility of the user.


Defines

#define ISSET(X, B)   (((X)[(B)/8]&(1<<((B)&7)))==(1<<((B)&7)))
#define MAPSIZE(N)   ((N-1)/8+1)
#define SET(X, B)   ((X)[(B)/8]|=(1<<((B)&7)))

Functions

void close_collector (struct collector *my)
void close_player (struct player *my)
void close_recorder (struct recorder *my)
void close_shaper (struct shaper *my)
int open_collector (struct collector *my, char *fname, char *flags)
int open_player (struct player *my, char *fname, char *flags)
int open_recorder (struct recorder *my, char *fname, char *flags)
int open_shaper (struct shaper *my, char *fname, char *flags)
char * read_player (struct player *my, char *buffer, unsigned int size)
char * read_shaper (struct shaper *my, char *buffer, unsigned int size)
int rewind_player (struct player *my)
int rewind_shaper (struct shaper *my)
int write_collector (struct collector *my, char *timestamp, char *value)
int write_recorder (struct recorder *my, char *timestamp, char *value)

Variables

EXPORT CALLBACKScallback = NULL


Function Documentation

int open_shaper ( struct shaper my,
char *  fname,
char *  flags 
)

Todo:
finish write memory shaper -- it still uses files (no ticket)

Todo:
shape defaults should be read from the shape memory, or better yet, inferred from it (no ticket)

Definition at line 173 of file tape_memory.cpp.

References shaper::fp, FT_MEMORY, shaper::interval, ISSET, min, shaper::scale, shaper::shape, shaper::status, shaper::step, TS_DONE, TS_OPEN, and shaper::type.


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