Rev 151 |
Rev 155 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <windows.h>
#include <cvirte.h>
#include <utility.h>
#include <stdio.h>
#include <stdarg.h>
#include "MPOD.h"
static mpodInit
=1;
HSNMP crateHsnmp
[MAX_CRATES
];
int _VI_FUNC MPOD_Start
(void)
{
int i
;
if (mpodInit
) {
for (i
=0;i
<MAX_CRATES
;i
++) crateHsnmp
[i
]=NULL
;
if(!snmpInit
()) return -1; // basic init
mpodInit
=0;
}
return 0;
}
int _VI_FUNC MPOD_Open
(int mpodn
, char *address
)
{
if (crateHsnmp
[mpodn
]) {
printf("Crate number %i already in use!\n",mpodn
);
return -2;
}
crateHsnmp
[mpodn
] = snmpOpen
(address
); // open TCP/IP socket
if(!crateHsnmp
[mpodn
]) return -1;
return 0;
}
int _VI_FUNC MPOD_GetInt
(int mpodn
, char *oidstr
)
{
SnmpObject tmpObject
;
getNode
(oidstr
, &tmpObject
);
return snmpGetInt
(crateHsnmp
[mpodn
], &tmpObject
);
}
double _VI_FUNC MPOD_GetDouble
(int mpodn
, char *oidstr
)
{
SnmpObject tmpObject
;
getNode
(oidstr
, &tmpObject
);
return snmpGetDouble
(crateHsnmp
[mpodn
], &tmpObject
);
}
int _VI_FUNC MPOD_Close
(int mpodn
)
{
snmpClose
(crateHsnmp
[mpodn
]);
crateHsnmp
[mpodn
]=NULL
;
return 0;
}
int _VI_FUNC MPOD_End
(void)
{
if (!mpodInit
) {
snmpCleanup
(); // finish
mpodInit
=1;
}
return 0;
}
#ifdef MPOD_MAIN
int __stdcall WinMain
(HINSTANCE hInstance
, HINSTANCE hPrevInstance
,
LPSTR lpszCmdLine
, int nCmdShow
) {
double ret
;
// double voltage;
double vSet
=0;
int ch
=0;
int iret
;
// int i, j;
HSNMP crate1
;
if (InitCVIRTE
(hInstance
, 0, 0) == 0)
return -1; /* out of memory */
MPOD_Start
();
MPOD_Open
(0,"arich-mpod1.kek.jp");
crate1
= crateHsnmp
[0];
printf("-----------------------------------------------------------------\n");
iret
=getMainSwitch
(crate1
);
printf("Main Switch = %i\n", iret
);
iret
=MPOD_GetInt
(0,"moduleNumber.0");
printf("Module Number = %i\n", iret
);
ret
=MPOD_GetDouble
(0,"outputVoltage.1");
printf("Output Voltage = %f.\n", ret
);
vSet
= getOutputVoltage
(crate1
, ch
);
printf("Output Voltage %i = %f.\n", ch
, vSet
);
//Test Channel Status
iret
=getChannelSwitch
(crate1
, ch
);
printf("Channel Status %i = %i\n", ch
, iret
);
//Test Reading the Sense Measurement
ret
= getOutputSenseMeasurement
(crate1
, ch
);
printf("Sense Voltage = %f\n", ret
);
//Test Reading the Current
ret
= getCurrentMeasurement
(crate1
, ch
);
printf("Current Measurement = %f\n", ret
);
printf("Turning channel %i ON\n", ch
);
setChannelSwitch
(crate1
, ch
, 1);
Delay
(1);
//Test Channel Status
iret
=getChannelSwitch
(crate1
, ch
);
printf("Channel Status %i = %i\n", ch
, iret
);
//Test Reading the Sense Measurement
ret
= getOutputSenseMeasurement
(crate1
, ch
);
printf("Sense Voltage = %f\n", ret
);
//Test Reading the Current
ret
= getCurrentMeasurement
(crate1
, ch
);
printf("Current Measurement = %f\n", ret
);
getchar();
printf("Turning channel %i OFF\n", ch
);
setChannelSwitch
(crate1
, ch
, 0);
printf("-----------------------------------------------------------------\n");
Delay
(1);
MPOD_Close
(0);
MPOD_End
();
return 0;
}
#endif /* MPOD_MAIN */