VXi VT1529A/B 사용자 설명서

다운로드
페이지 529
Creating and Running Algorithms   185
Accessing the VT1422A's Resources
This section describes how algorithms access hardware and software 
resources provided by the VT1422A. The resources are listed below:
I/O channels.
Remote Scan Status variables.
Global variables defined before algorithms are defined.
The constant ALG_NUM which the VT1422A makes available to the 
algorithms. ALG_NUM = 1 for ALG1, 2 for ALG2, etc.
User defined functions defined with the ALG:FUNC:DEF command. 
The Current Value Table (CVT) and the data FIFO buffer (FIFO) to 
output algorithm data to the application program.
VXIbus Interrupts.
/* GLOBALS you define with ALG:DEF GLOBALS...  go here */
/* global variable First_loop equals 1 until all algorithms called  */
static float First_loop; /* global value set to 1 at each INIT */
/**************************** function main() ****************************/
/*The VT1422A driver creates main() at INIT time. This example 
shows a main created after 2 algorithms have been defined. */
main()
{
/********* declaration of variables local to main() ********/
static float State_1, Ratio_1, Count_1;  /* created if alg1 defined */
static float State_2, Ratio_2, Count_2;  /* created if alg2 defined */
/********* this section created if ALG1 is defined ********/
Count_1 = Count_1 - 1; /* Count_1 used for ALG:SCAN:RATIO */
if (Count_1 <= 0) {         /* test for ratio met (<=0 means execute)*/ 
Count_1 = Ratio_1;   /* Count_1 = ALG:SCAN:RATIO setting  */
if (State_1) alg1();     /* if ALG:STATE ALG1,ON, call alg1       */
}
/********* this section created if ALG2 is defined ********/
Count_2 = Count_2 - 1; /* Count_2 used for ALG:SCAN:RATIO */
if (Count_2 <= 0) {         /* test for ratio met (<=0 means execute)*/ 
Count_2 = Ratio_2;   /* Count_2 = ALG:SCAN:RATIO setting  */
if (State_2) alg2();     /* if ALG:STATE ALG2,ON, call alg2        */
}
First_loop = 0;   /* reset First_loop after last alg has been called */
}
/* ************************ end function main() *************************/
ALG1()  /* this function shell created by ALG:DEF 'ALG1'....    */
{
const int ALG_NUM = 1; /* created by driver to ID this algorithm */
/********* Your algorithm code goes here **********/
}
ALG2()  /* this function shell created by ALG:DEF 'ALG2'....    */
{
const int ALG_NUM = 2; /* created by driver to ID this algorithm */
/********* Your algorithm code goes here **********/
}
Begin algorithm "shells"
(built by VT1422A's driver)
End main() function
Begin main() function
(built by VT1422A's driver)
Global variables area
First_loop declared by
VT1422A's driver
Figure 6-1. Source Listing of Function main( )
Your algorithms go here