| Example 1P | UDF PROGRAMMERS MANUAL | Example 1P |
|---|
The program below is an example of how to access data from within a PIDF.
#include "util_var.h"
#include "ret_codes.h"
#include "user_defs.h"
#include "libbase_udf.h"
#include "PidfAnsi.h"
int main ()
{
struct Pidf *P;
struct PidfSensor *Ps;
struct PidfUnit *Pu;
void *PIDF;
u_ByTe_4 Key;
ByTe_2 rV, L, L1;
ByTe_1 *Pr = "IMAGE", *M = "IMAGE-1", *E = "RPI";
ByTe_1 *I = "RPISCI", *SI = "IMRLTD";
/********************************************************************
Initialize the UDF structures
********************************************************************/
init_udf();
/********************************************************************
Create one instance of a PIDF data block and then set up a
structure pointer into the PIDF block.
********************************************************************/
CreatePidfStruc (&PIDF);
P = (struct Pidf *) PIDF;
/********************************************************************
Get the data key for the UDF containing the spin rate. If there
is an error then give error code and exit.
********************************************************************/
rV = get_data_key(Pr, M, E, I, SI, &Key);
if (rV != ALL_OKAY)
{
printf ("Encountered error %d in get_data_key\n", rV);
exit (-1);
}
/********************************************************************
Read the PIDF file. If error condition results then exit.
********************************************************************/
rV = ReadPidf(Key, PIDF);
if (rV != ALL_OKAY)
{
printf ("Encountered error %d in ReadPidf\n", rV);
exit (-1);
}
/********************************************************************
Set pointer to PIDF sensor structures and loop over them
printing out the sensor name, source, VIDF number and applicable
unit structure numbers.
********************************************************************/
printf (" SENSORS\n\n");
Ps = (struct PidfSensor *)P->Sensors;
for (L = 0; L < P->Ps.NSensors; ++L, ++Ps)
{
printf ("%-25s (SRC %c) Vnum %3d", Ps->Name, Ps->Src, Ps->VidfNum);
printf (" Units |");
for (L1 = 0; L1 < Ps->NUnits; ++L1)
printf ("%3d |", Ps->Units[L1]);
printf ("\n");
}
/********************************************************************
Set pointer to PIDF unit structure 25 and print out the
units label, the long description, the number of algorithm
steps, and the table and operation to use at each step.
********************************************************************/
printf ("\n\n\n UNIT 25 INFO\n\n");
Pu = (struct PidfUnit *)P->Units + 25;
printf ("UNIT LABEL %s\n", Pu->ULab);
printf ("DESCRIPTION %s\n", Pu->LDesc);
printf ("ALGORITHM STEPS %d\n", Pu->NTbls);
for (L = 0; L < Pu->NTbls; ++L, ++Ps)
printf (" STEP %2d TABLE %3d OPERATION %6d\n",
L, Pu->Tbls[L], Pu->Ops[L]);
exit(0);
}
| UDF V2.2 | July 31, 1999 | UDF V2.2 |
|---|