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 */
/cvi/instr/MPOD/MPOD.prj
9,7 → 9,7
VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt"
IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
Number of Files = 5
Number of Files = 7
Target Type = "Executable"
Flags = 2064
Copied From Locked InstrDrv Directory = False
19,7 → 19,6
 
[Folders]
User Interface Files Folder Not Added Yet = True
Instrument Files Folder Not Added Yet = True
Folder 0 = "Source Files"
FolderEx 0 = "Source Files"
Folder 1 = "Include Files"
26,6 → 25,8
FolderEx 1 = "Include Files"
Folder 2 = "Library Files"
FolderEx 2 = "Library Files"
Folder 3 = "Instrument Files"
FolderEx 3 = "Instrument Files"
 
[File 0001]
File Type = "CSource"
58,8 → 59,8
Res Id = 3
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "net-snmp-config.h"
Path = "/c/SAMO/Programi/NI/cvi/instr/MPOD/net-snmp-config.h"
Path Rel Path = "MPOD.h"
Path = "/c/SAMO/Programi/NI/cvi/instr/MPOD/MPOD.h"
Exclude = False
Project Flags = 0
Folder = "Include Files"
70,6 → 71,18
Res Id = 4
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "net-snmp-config.h"
Path = "/c/SAMO/Programi/NI/cvi/instr/MPOD/net-snmp-config.h"
Exclude = False
Project Flags = 0
Folder = "Include Files"
Folder Id = 1
 
[File 0005]
File Type = "Include"
Res Id = 5
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "WIENER_SNMP.h"
Path = "/c/SAMO/Programi/NI/cvi/instr/MPOD/WIENER_SNMP.h"
Exclude = False
77,9 → 90,9
Folder = "Include Files"
Folder Id = 1
 
[File 0005]
[File 0006]
File Type = "Library"
Res Id = 5
Res Id = 6
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../../../../../../usr/lib/netsnmp.lib"
89,6 → 102,18
Folder = "Library Files"
Folder Id = 2
 
[File 0007]
File Type = "Function Panel"
Res Id = 7
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "MPOD.fp"
Path = "/c/SAMO/Programi/NI/cvi/instr/MPOD/MPOD.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
Folder Id = 3
 
[Custom Build Configs]
Num Custom Build Configs = 0
 
119,7 → 144,7
Stack Commit = 4096
Image Base Address = 4194304
Image Base Address x64 = 4194304
Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DMPOD_MAIN"
Sign = False
Sign Store = ""
Sign Certificate = ""
/cvi/instr/MPOD/WIENER_SNMP.c
127,9 → 127,9
 
//static double snmpSetDouble(HSNMP session, const SnmpObject &object, double value);
static double snmpSetDouble(HSNMP session, const SnmpObject *object, double value);
static double snmpGetDouble(HSNMP session, const SnmpObject *object);
double snmpGetDouble(HSNMP session, const SnmpObject *object);
static int snmpSetInt(HSNMP session, const SnmpObject *object, int value);
static int snmpGetInt(HSNMP session, const SnmpObject *object);
int snmpGetInt(HSNMP session, const SnmpObject *object);
static char *snmpGetString(HSNMP session, const SnmpObject *object);
 
char snmpStringBuffer[1024];
183,7 → 183,8
* @param object the resolved OID
* @return true on success, false otherwise
*/
static int getNode(const char * const node, SnmpObject *object)
//static int getNode(const char * const node, SnmpObject *object)
int getNode(const char * const node, SnmpObject *object)
{
object->len = MAX_OID_LEN;
if (!get_node(node, object->id, &object->len)) {
1743,7 → 1744,7
return pdu;
}
 
static int snmpGetInt(HSNMP session, const SnmpObject *object)
int snmpGetInt(HSNMP session, const SnmpObject *object)
{
int value = 0;
 
1789,7 → 1790,7
return result;
}
 
static double snmpGetDouble(HSNMP session, const SnmpObject *object)
double snmpGetDouble(HSNMP session, const SnmpObject *object)
{
double value = 0.0;
 
/cvi/instr/MPOD/WIENER_SNMP.h
3,21 → 3,17
#ifndef WIENER_SNMP_H
#define WIENER_SNMP_H
 
//#include "netsnmplib.h"
/*
#ifdef _MSC_VER
#define EXPORT extern "C" _declspec(dllexport)
#else
#define EXPORT extern "C"
#endif
*/
#define EXPORT
 
#define WIN32_LEAN_AND_MEAN
 
//#include <net-snmp/net-snmp-config.h>
#include "net-snmp-config.h"
//#define NET_SNMP_SNMPV3_H // we don't need SNMPV3 (one include file is missing)
//SAMO #include <net-snmp/net-snmp-config.h>
#include "net-snmp-config.h" // SAMO
//SAMO #define NET_SNMP_SNMPV3_H // we don't need SNMPV3 (one include file is missing)
#include <net-snmp/net-snmp-includes.h>
 
typedef void *HSNMP; // SNMP handle (like FILE)
/cvi/instr/MPOD/net-snmp-config.h
1622,7 → 1622,7
#pragma warning(push)
#pragma warning(disable: 4804) // '-' : unsafe use of type 'bool' in operation
#endif
/* SAMO
/* SAMO : ne dela z LabWindows CVI?
enum {
netsnmp_compile_time_uintptr_t_size_check
= sizeof(struct netsnmp_compile_time_uintptr_t_size_check_s { int:-!(sizeof(uintptr_t) == sizeof(void*)); })