Subversion Repositories f9daq

Rev

Rev 154 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <windows.h>
  2. #include <cvirte.h>
  3. #include <utility.h>
  4. #include <stdio.h>
  5. #include <stdarg.h>
  6. #include "WIENER_SNMP.h"
  7.  
  8. int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  9.                        LPSTR lpszCmdLine, int nCmdShow) {
  10.  
  11.   double ret;
  12. //  double voltage;
  13.   double vSet=0;
  14.   int ch=0;
  15.   int iret;
  16. //  int i, j;
  17.  
  18. //  oid oidStr[MAX_OID_LEN];
  19. //  size_t lengthOidStr;
  20.  
  21.   HSNMP crate1;
  22.  
  23.   if (InitCVIRTE (hInstance, 0, 0) == 0)
  24.     return -1;    /* out of memory */
  25.  
  26.   if(!snmpInit()) return 1;                     // basic init
  27.   crate1 = snmpOpen("arich-mpod1.kek.jp");   // open TCP/IP socket
  28.   if(!crate1) return 1;
  29.  
  30.   printf("-----------------------------------------------------------------\n");
  31.  
  32.   iret=getMainSwitch(crate1);
  33.   printf("Main Switch = %i\n", iret);
  34.  
  35.  
  36. //  strcpy(oidStr,"moduleNumber.0");
  37. //  strcpy(oidStr,"fanNominalSpeed.0");
  38. //  iret=snmpGetInt(crate1, oidStr, strlen(oidStr));
  39. //  printf("Module Number = %i\n", iret);
  40.  
  41.   vSet = getOutputVoltage(crate1, ch);
  42.   printf("Output Voltage %i = %f.\n", ch, vSet);
  43.  
  44. //Test Channel Status
  45.   iret=getChannelSwitch(crate1, ch);
  46.   printf("Channel Status %i = %i\n", ch, iret);
  47.  
  48. //Test Reading the Sense Measurement
  49.   ret = getOutputSenseMeasurement(crate1, ch);
  50.   printf("Sense Voltage =  %f\n", ret);
  51.  
  52. //Test Reading the Current
  53.   ret = getCurrentMeasurement(crate1, ch);
  54.   printf("Current Measurement =  %f\n", ret);
  55.  
  56.   printf("Turning channel %i ON\n", ch);
  57.   setChannelSwitch(crate1, ch, 1);
  58.   Delay(1);
  59.  
  60. //Test Channel Status
  61.   iret=getChannelSwitch(crate1, ch);
  62.   printf("Channel Status %i = %i\n", ch, iret);
  63.  
  64. //Test Reading the Sense Measurement
  65.   ret = getOutputSenseMeasurement(crate1, ch);
  66.   printf("Sense Voltage =  %f\n", ret);
  67.  
  68. //Test Reading the Current
  69.   ret = getCurrentMeasurement(crate1, ch);
  70.   printf("Current Measurement =  %f\n", ret);
  71.  
  72.   getchar();
  73.  
  74.   printf("Turning channel %i OFF\n", ch);
  75.   setChannelSwitch(crate1, ch, 0);
  76.  
  77.   printf("-----------------------------------------------------------------\n");
  78.  
  79.   snmpClose(crate1);
  80.   snmpCleanup();                              // finish
  81.  
  82.   return 0;
  83. }
  84.