Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 259 | f9daq | 1 | #include <ansi_c.h> |
| 2 | #include <utility.h> |
||
| 3 | #include "hm7044ui.h" |
||
| 4 | #include "hm7044.h" |
||
| 5 | |||
| 6 | static int panelHandle; |
||
| 7 | |||
| 8 | int test(){ |
||
| 9 | char result[MAX_CMD] ; |
||
| 10 | char cmd[MAX_CMD] ; |
||
| 11 | float data[4]; |
||
| 12 | int port; |
||
| 13 | int err; |
||
| 14 | int i,ch=1; |
||
| 15 | GetCtrlVal(panelHandle,PANEL_PORT,&port); |
||
| 16 | GetCtrlVal(panelHandle,PANEL_CMD ,cmd); |
||
| 17 | |||
| 18 | err=HM7044_Open (port); |
||
| 19 | HM7044_SendCmd("FUSE 1,2,3,4",result); |
||
| 20 | HM7044_FuseOff( ch); |
||
| 21 | HM7044_SetVoltage(ch,1); |
||
| 22 | HM7044_Enable_Output( ch); |
||
| 23 | for (i=0;i<10;i++){ |
||
| 24 | HM7044_SwitchOff(ch); |
||
| 25 | HM7044_SetCurrent(ch,i/1000.); |
||
| 26 | //HM7044_SetVoltage(ch,i/100.); |
||
| 27 | |||
| 28 | HM7044_SwitchOn(ch); |
||
| 29 | |||
| 30 | Delay(0.5); |
||
| 31 | HM7044_Read(data); |
||
| 32 | |||
| 33 | } |
||
| 34 | |||
| 35 | HM7044_Disable_Output(ch); |
||
| 36 | err= HM7044_Close() ; |
||
| 37 | printf ( "[%d] Port closed.\n" ,err) ; |
||
| 38 | return 0; |
||
| 39 | } |
||
| 40 | |||
| 41 | int mymain(){ |
||
| 42 | |||
| 43 | char result[MAX_CMD] ; |
||
| 44 | char cmd[MAX_CMD] ; |
||
| 45 | float data[4]; |
||
| 46 | int port; |
||
| 47 | int err; |
||
| 48 | GetCtrlVal(panelHandle,PANEL_PORT,&port); |
||
| 49 | GetCtrlVal(panelHandle,PANEL_CMD ,cmd); |
||
| 50 | |||
| 51 | err=HM7044_Open (port); |
||
| 52 | printf ( "[%d] Port %d opened \n",err,port) ; |
||
| 53 | |||
| 54 | |||
| 55 | HM7044_SendCmd (cmd, result ); |
||
| 56 | printf ( "\nRecieved response:#%s#\n",result ) ; |
||
| 57 | SetCtrlVal(panelHandle,PANEL_READ ,result); |
||
| 58 | SetCtrlVal(panelHandle,PANEL_READ ,"\n"); |
||
| 59 | err= HM7044_Close() ; |
||
| 60 | printf ( "[%d] Port closed.\n" ,err) ; |
||
| 61 | return 0; |
||
| 62 | } |
||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
||
| 67 | LPSTR lpszCmdLine, int nCmdShow) |
||
| 68 | { |
||
| 69 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
||
| 70 | return -1; /* out of memory */ |
||
| 71 | if ((panelHandle = LoadPanel (0, "hm7044ui.uir", PANEL)) < 0) |
||
| 72 | return -1; |
||
| 73 | DisplayPanel (panelHandle); |
||
| 74 | |||
| 75 | SetStdioPort (CVI_STDIO_WINDOW); |
||
| 76 | RunUserInterface (); |
||
| 77 | |||
| 78 | |||
| 79 | DiscardPanel (panelHandle); |
||
| 80 | return 0; |
||
| 81 | } |
||
| 82 | |||
| 83 | int CVICALLBACK Send (int panel, int control, int event, |
||
| 84 | void *callbackData, int eventData1, int eventData2) |
||
| 85 | { |
||
| 86 | switch (event) |
||
| 87 | { |
||
| 88 | case EVENT_COMMIT: |
||
| 89 | mymain(); |
||
| 90 | break; |
||
| 91 | } |
||
| 92 | return 0; |
||
| 93 | } |
||
| 94 | int CVICALLBACK TestCB (int panel, int control, int event, |
||
| 95 | void *callbackData, int eventData1, int eventData2) |
||
| 96 | { |
||
| 97 | switch (event) |
||
| 98 | { |
||
| 99 | case EVENT_COMMIT: |
||
| 100 | test(); |
||
| 101 | break; |
||
| 102 | } |
||
| 103 | return 0; |
||
| 104 | } |
||
| 105 | int CVICALLBACK Exit (int panel, int control, int event, |
||
| 106 | void *callbackData, int eventData1, int eventData2) |
||
| 107 | { |
||
| 108 | switch (event) |
||
| 109 | { |
||
| 110 | case EVENT_COMMIT: |
||
| 111 | QuitUserInterface (0); |
||
| 112 | break; |
||
| 113 | } |
||
| 114 | return 0; |
||
| 115 | } |
||
| 116 | |||
| 117 |