Subversion Repositories f9daq

Rev

Rev 151 | Rev 155 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 151 Rev 154
Line 1... Line 1...
1
#include <windows.h>
1
#include <windows.h>
2
#include <cvirte.h>
2
#include <cvirte.h>
3
#include <utility.h>
3
#include <utility.h>
4
#include <stdio.h>
4
#include <stdio.h>
5
#include <stdarg.h>
5
#include <stdarg.h>
6
#include "WIENER_SNMP.h"
6
#include "MPOD.h"
7
 
7
 
-
 
8
static mpodInit=1;
-
 
9
HSNMP crateHsnmp[MAX_CRATES];
-
 
10
 
-
 
11
int _VI_FUNC MPOD_Start (void)
-
 
12
{
-
 
13
  int i;
-
 
14
  if (mpodInit) {
-
 
15
    for (i=0;i<MAX_CRATES;i++) crateHsnmp[i]=NULL;
-
 
16
    if(!snmpInit()) return -1;                     // basic init
-
 
17
    mpodInit=0;
-
 
18
  }
-
 
19
  return 0;
-
 
20
}
-
 
21
 
-
 
22
int _VI_FUNC MPOD_Open (int mpodn, char *address)
-
 
23
{
-
 
24
  if (crateHsnmp[mpodn]) {
-
 
25
    printf("Crate number %i already in use!\n",mpodn);
-
 
26
    return -2;
-
 
27
  }
-
 
28
  crateHsnmp[mpodn] = snmpOpen(address);   // open TCP/IP socket
-
 
29
  if(!crateHsnmp[mpodn]) return -1;
-
 
30
  return 0;
-
 
31
}
-
 
32
 
-
 
33
int _VI_FUNC MPOD_GetInt (int mpodn, char *oidstr)
-
 
34
{
-
 
35
  SnmpObject tmpObject;
-
 
36
 
-
 
37
  getNode(oidstr, &tmpObject);
-
 
38
  return snmpGetInt(crateHsnmp[mpodn], &tmpObject);
-
 
39
}
-
 
40
 
-
 
41
double _VI_FUNC MPOD_GetDouble (int mpodn, char *oidstr)
-
 
42
{
-
 
43
  SnmpObject tmpObject;
-
 
44
 
-
 
45
  getNode(oidstr, &tmpObject);
-
 
46
  return snmpGetDouble(crateHsnmp[mpodn], &tmpObject);
-
 
47
}
-
 
48
 
-
 
49
int _VI_FUNC MPOD_Close (int mpodn)
-
 
50
{
-
 
51
  snmpClose(crateHsnmp[mpodn]);
-
 
52
  crateHsnmp[mpodn]=NULL;
-
 
53
  return 0;
-
 
54
}
-
 
55
 
-
 
56
int _VI_FUNC MPOD_End (void)
-
 
57
{
-
 
58
  if (!mpodInit) {
-
 
59
    snmpCleanup();  // finish
-
 
60
    mpodInit=1;
-
 
61
  }
-
 
62
  return 0;
-
 
63
}
-
 
64
 
-
 
65
#ifdef MPOD_MAIN
8
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
66
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
9
                       LPSTR lpszCmdLine, int nCmdShow) {
67
                       LPSTR lpszCmdLine, int nCmdShow) {
10
 
68
 
11
  double ret;
69
  double ret;
12
//  double voltage;
70
//  double voltage;
13
  double vSet=0;
71
  double vSet=0;
14
  int ch=0;
72
  int ch=0;
15
  int iret;
73
  int iret;
16
//  int i, j;
74
//  int i, j;
17
 
-
 
18
//  oid oidStr[MAX_OID_LEN];
-
 
19
//  size_t lengthOidStr;
-
 
20
 
75
 
21
  HSNMP crate1;
76
  HSNMP crate1;
22
 
77
 
23
  if (InitCVIRTE (hInstance, 0, 0) == 0)
78
  if (InitCVIRTE (hInstance, 0, 0) == 0)
24
    return -1;    /* out of memory */
79
    return -1;    /* out of memory */
25
 
80
 
26
  if(!snmpInit()) return 1;                     // basic init
81
  MPOD_Start();
27
  crate1 = snmpOpen("arich-mpod1.kek.jp");   // open TCP/IP socket
82
  MPOD_Open(0,"arich-mpod1.kek.jp");
28
  if(!crate1) return 1;
83
  crate1 = crateHsnmp[0];
29
 
84
 
30
  printf("-----------------------------------------------------------------\n");
85
  printf("-----------------------------------------------------------------\n");
31
 
86
 
32
  iret=getMainSwitch(crate1);
87
  iret=getMainSwitch(crate1);
33
  printf("Main Switch = %i\n", iret);
88
  printf("Main Switch = %i\n", iret);
34
 
89
 
35
 
-
 
36
//  strcpy(oidStr,"moduleNumber.0");
90
  iret=MPOD_GetInt(0,"moduleNumber.0");
37
//  strcpy(oidStr,"fanNominalSpeed.0");
91
  printf("Module Number = %i\n", iret);
-
 
92
 
38
//  iret=snmpGetInt(crate1, oidStr, strlen(oidStr));
93
  ret=MPOD_GetDouble(0,"outputVoltage.1");
39
//  printf("Module Number = %i\n", iret);
94
  printf("Output Voltage = %f.\n", ret);
40
 
95
 
41
  vSet = getOutputVoltage(crate1, ch);
96
  vSet = getOutputVoltage(crate1, ch);
42
  printf("Output Voltage %i = %f.\n", ch, vSet);
97
  printf("Output Voltage %i = %f.\n", ch, vSet);
43
 
98
 
44
//Test Channel Status
99
//Test Channel Status
45
  iret=getChannelSwitch(crate1, ch);
100
  iret=getChannelSwitch(crate1, ch);
46
  printf("Channel Status %i = %i\n", ch, iret);
101
  printf("Channel Status %i = %i\n", ch, iret);
47
 
102
 
48
//Test Reading the Sense Measurement
103
//Test Reading the Sense Measurement
49
  ret = getOutputSenseMeasurement(crate1, ch);
104
  ret = getOutputSenseMeasurement(crate1, ch);
50
  printf("Sense Voltage =  %f\n", ret);
105
  printf("Sense Voltage =  %f\n", ret);
51
 
106
 
52
//Test Reading the Current
107
//Test Reading the Current
53
  ret = getCurrentMeasurement(crate1, ch);
108
  ret = getCurrentMeasurement(crate1, ch);
54
  printf("Current Measurement =  %f\n", ret);
109
  printf("Current Measurement =  %f\n", ret);
Line 66... Line 121...
66
  printf("Sense Voltage =  %f\n", ret);
121
  printf("Sense Voltage =  %f\n", ret);
67
 
122
 
68
//Test Reading the Current
123
//Test Reading the Current
69
  ret = getCurrentMeasurement(crate1, ch);
124
  ret = getCurrentMeasurement(crate1, ch);
70
  printf("Current Measurement =  %f\n", ret);
125
  printf("Current Measurement =  %f\n", ret);
71
 
126
 
72
  getchar();
127
  getchar();
73
 
128
 
74
  printf("Turning channel %i OFF\n", ch);
129
  printf("Turning channel %i OFF\n", ch);
75
  setChannelSwitch(crate1, ch, 0);
130
  setChannelSwitch(crate1, ch, 0);
76
 
131
 
77
  printf("-----------------------------------------------------------------\n");
132
  printf("-----------------------------------------------------------------\n");
78
 
133
 
-
 
134
  Delay(1);
-
 
135
 
79
  snmpClose(crate1);
136
  MPOD_Close(0);
80
  snmpCleanup();                              // finish
137
  MPOD_End();
81
 
138
 
82
  return 0;
139
  return 0;
83
}
140
}
-
 
141
 
-
 
142
#endif /* MPOD_MAIN */