Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 153 → Rev 154

/cvi/instr/MPOD/MPOD.c
3,8 → 3,66
#include <utility.h>
#include <stdio.h>
#include <stdarg.h>
#include "WIENER_SNMP.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) {
 
15,29 → 73,26
int iret;
// int i, j;
 
// oid oidStr[MAX_OID_LEN];
// size_t lengthOidStr;
 
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];
if(!snmpInit()) return 1; // basic init
crate1 = snmpOpen("arich-mpod1.kek.jp"); // open TCP/IP socket
if(!crate1) return 1;
 
printf("-----------------------------------------------------------------\n");
 
iret=getMainSwitch(crate1);
printf("Main Switch = %i\n", iret);
 
// strcpy(oidStr,"moduleNumber.0");
// strcpy(oidStr,"fanNominalSpeed.0");
// iret=snmpGetInt(crate1, oidStr, strlen(oidStr));
// printf("Module Number = %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);
76,8 → 131,12
 
printf("-----------------------------------------------------------------\n");
 
snmpClose(crate1);
snmpCleanup(); // finish
Delay(1);
MPOD_Close(0);
MPOD_End();
 
return 0;
}
 
#endif /* MPOD_MAIN */