#include
"Radiotelescopio.h"
#include <utility.h>
#include <Dataacq.h>
#include <formatio.h>
#include <ansi_c.h>
#include <cvirte.h> /* Needed if linking in external
compiler; harmless otherwise */
#include <userint.h>
#include "d:\WORKS\Radiotelescopio\Radiotelescopio.h"
#include <NIDAQEx.h>
#include <time.h>
//LAB-PC Variables:
i16
iStatus = 0;
i16
iRetVal = 0;
i16
iDevice = 1;
i16
iChan = 1;
i16
iGain = 1;
f64
dVoltage = 0.0;
i16
iIgnoreWarning = 0;
static int panelHandle;
int controllo, stop, stop2;
time_t CurrentTime;
int tempo, prov;
int main (int
argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0) //Needed if
linking in external compiler; harmless otherwise
return
-1; /*
out of memory */
if ((panelHandle = LoadPanel (0,
"Radiotelescopio.uir", PANEL)) < 0)
return
-1;
DisplayPanel
(panelHandle);
RunUserInterface
();
return 0;
}
int CVICALLBACK Start (int
panel, int control, int
event,
void
*callbackData, int eventData1, int eventData2)
{
int i;
FILE
*filep;
char path[280];
switch (event)
{
case
EVENT_COMMIT:
DeleteGraphPlot (PANEL, PANEL_GRAPH,
-1, VAL_IMMEDIATE_DRAW);
FileSelectPopup ("", "*.dat", "*.dat", //mi viene fuori la finestra
"Salvataggio dati acquisiti in...", VAL_SAVE_BUTTON,
0, 1, 0, 1, path);
while
(controllo==0
&& stop2==0) {
//stop2 = KeyHit ();
time (&CurrentTime); //leggo l'ora( secondi trascorsi dal 1-1-1900)
CurrentTime = (CurrentTime%86400);
tempo = CurrentTime - 79200 ; //pongo le 23 come punto zero iniziale
//
per le 17000 misure che è 79200
SetCtrlVal (PANEL, PANEL_SECOND,
tempo); //fa
il conto alla rovescia
//per la partenza
if ((tempo < 3) && (tempo > 0)) controllo=1;
if (controllo==1) {
filep = fopen (path, "a"); //mi apre il file
i=0;
while (i<17000 && stop==0) {
stop
= KeyHit ();
iStatus
= AI_VRead(iDevice, iChan, iGain, &dVoltage);
iRetVal = NIDAQErrorHandler(iStatus,
"AI_VRead",
iIgnoreWarning);
fprintf(filep,
"%lf\n", dVoltage); //ordino di
scrivere nel file
i++;
PlotPoint
(PANEL, PANEL_GRAPH, (double)i, (double)dVoltage,
VAL_SOLID_SQUARE, VAL_BLUE);
Delay ( 1 );
}
if (i=16999) controllo=0;
fprintf(filep,"\n\n\n ********************** FINE ACQUISIZIONE
******************** \n\n\n");
fclose (filep); //chiudo il file
}
}
break;
}
return 0;
}
int CVICALLBACK Quit (int
panel, int control, int
event,
void
*callbackData, int eventData1, int eventData2)
{
switch (event)
{
case
EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
int CVICALLBACK Tasto (int panel, int control, int
event,
void
*callbackData, int eventData1, int eventData2)
{
f64 radio[17000];
char path1[280];
int Status;
switch (event)
{
case EVENT_COMMIT:
FileSelectPopup ("",
"*.dat", "*.dat", "Carica File ...",VAL_LOAD_BUTTON, 0, 1, 0, 1,
path1);
Status = FileToArray (path1, radio,
VAL_DOUBLE, 17000, 1,
VAL_GROUPS_TOGETHER,
VAL_GROUPS_AS_ROWS, VAL_ASCII);
PlotY (PANEL, PANEL_GRAPH, radio,
17000, VAL_DOUBLE, VAL_SCATTER,
VAL_SOLID_SQUARE, VAL_SOLID, 1, VAL_DK_BLUE);
break;
}
return 0;
}