Subversion Repositories f9daq

Compare Revisions

Regard whitespace Rev 154 → Rev 153

/cvi/instr/MPOD/MPOD.c
3,66 → 3,8
#include <utility.h>
#include <stdio.h>
#include <stdarg.h>
#include "MPOD.h"
#include "WIENER_SNMP.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) {
 
73,14 → 15,17
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");
 
87,11 → 32,11
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);
// strcpy(oidStr,"moduleNumber.0");
// strcpy(oidStr,"fanNominalSpeed.0");
// iret=snmpGetInt(crate1, oidStr, strlen(oidStr));
// printf("Module Number = %i\n", iret);
 
vSet = getOutputVoltage(crate1, ch);
printf("Output Voltage %i = %f.\n", ch, vSet);
131,12 → 76,8
 
printf("-----------------------------------------------------------------\n");
 
Delay(1);
snmpClose(crate1);
snmpCleanup(); // finish
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 = 7
Number of Files = 5
Target Type = "Executable"
Flags = 2064
Copied From Locked InstrDrv Directory = False
19,6 → 19,7
 
[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"
25,8 → 26,6
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"
59,8 → 58,8
Res Id = 3
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "MPOD.h"
Path = "/c/SAMO/Programi/NI/cvi/instr/MPOD/MPOD.h"
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"
71,18 → 70,6
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
90,9 → 77,9
Folder = "Include Files"
Folder Id = 1
 
[File 0006]
[File 0005]
File Type = "Library"
Res Id = 6
Res Id = 5
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../../../../../../usr/lib/netsnmp.lib"
102,18 → 89,6
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
 
144,7 → 119,7
Stack Commit = 4096
Image Base Address = 4194304
Image Base Address x64 = 4194304
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DMPOD_MAIN"
Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
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);
double snmpGetDouble(HSNMP session, const SnmpObject *object);
static double snmpGetDouble(HSNMP session, const SnmpObject *object);
static int snmpSetInt(HSNMP session, const SnmpObject *object, int value);
int snmpGetInt(HSNMP session, const SnmpObject *object);
static int snmpGetInt(HSNMP session, const SnmpObject *object);
static char *snmpGetString(HSNMP session, const SnmpObject *object);
 
char snmpStringBuffer[1024];
183,8 → 183,7
* @param object the resolved OID
* @return true on success, false otherwise
*/
//static int getNode(const char * const node, SnmpObject *object)
int getNode(const char * const node, SnmpObject *object)
static int getNode(const char * const node, SnmpObject *object)
{
object->len = MAX_OID_LEN;
if (!get_node(node, object->id, &object->len)) {
1744,7 → 1743,7
return pdu;
}
 
int snmpGetInt(HSNMP session, const SnmpObject *object)
static int snmpGetInt(HSNMP session, const SnmpObject *object)
{
int value = 0;
 
1790,7 → 1789,7
return result;
}
 
double snmpGetDouble(HSNMP session, const SnmpObject *object)
static double snmpGetDouble(HSNMP session, const SnmpObject *object)
{
double value = 0.0;
 
/cvi/instr/MPOD/WIENER_SNMP.h
3,17 → 3,21
#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
 
//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-config.h>
#include "net-snmp-config.h"
//#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 : ne dela z LabWindows CVI?
/* SAMO
enum {
netsnmp_compile_time_uintptr_t_size_check
= sizeof(struct netsnmp_compile_time_uintptr_t_size_check_s { int:-!(sizeof(uintptr_t) == sizeof(void*)); })