Blame |
Last modification |
View Log
| RSS feed
#include <ansi_c.h>
#include <utility.h>
#include "hm7044ui.h"
#include "hm7044.h"
static int panelHandle
;
int test
(){
char result
[MAX_CMD
] ;
char cmd
[MAX_CMD
] ;
float data
[4];
int port
;
int err
;
int i
,ch
=1;
GetCtrlVal
(panelHandle
,PANEL_PORT
,&port
);
GetCtrlVal
(panelHandle
,PANEL_CMD
,cmd
);
err
=HM7044_Open
(port
);
HM7044_SendCmd
("FUSE 1,2,3,4",result
);
HM7044_FuseOff
( ch
);
HM7044_SetVoltage
(ch
,1);
HM7044_Enable_Output
( ch
);
for (i
=0;i
<10;i
++){
HM7044_SwitchOff
(ch
);
HM7044_SetCurrent
(ch
,i
/1000.
);
//HM7044_SetVoltage(ch,i/100.);
HM7044_SwitchOn
(ch
);
Delay
(0.5);
HM7044_Read
(data
);
}
HM7044_Disable_Output
(ch
);
err
= HM7044_Close
() ;
printf ( "[%d] Port closed.\n" ,err
) ;
return 0;
}
int mymain
(){
char result
[MAX_CMD
] ;
char cmd
[MAX_CMD
] ;
float data
[4];
int port
;
int err
;
GetCtrlVal
(panelHandle
,PANEL_PORT
,&port
);
GetCtrlVal
(panelHandle
,PANEL_CMD
,cmd
);
err
=HM7044_Open
(port
);
printf ( "[%d] Port %d opened \n",err
,port
) ;
HM7044_SendCmd
(cmd
, result
);
printf ( "\nRecieved response:#%s#\n",result
) ;
SetCtrlVal
(panelHandle
,PANEL_READ
,result
);
SetCtrlVal
(panelHandle
,PANEL_READ
,"\n");
err
= HM7044_Close
() ;
printf ( "[%d] Port closed.\n" ,err
) ;
return 0;
}
int __stdcall WinMain
(HINSTANCE hInstance
, HINSTANCE hPrevInstance
,
LPSTR lpszCmdLine
, int nCmdShow
)
{
if (InitCVIRTE
(hInstance
, 0, 0) == 0)
return -1; /* out of memory */
if ((panelHandle
= LoadPanel
(0, "hm7044ui.uir", PANEL
)) < 0)
return -1;
DisplayPanel
(panelHandle
);
SetStdioPort
(CVI_STDIO_WINDOW
);
RunUserInterface
();
DiscardPanel
(panelHandle
);
return 0;
}
int CVICALLBACK Send
(int panel
, int control
, int event
,
void *callbackData
, int eventData1
, int eventData2
)
{
switch (event
)
{
case EVENT_COMMIT
:
mymain
();
break;
}
return 0;
}
int CVICALLBACK TestCB
(int panel
, int control
, int event
,
void *callbackData
, int eventData1
, int eventData2
)
{
switch (event
)
{
case EVENT_COMMIT
:
test
();
break;
}
return 0;
}
int CVICALLBACK Exit
(int panel
, int control
, int event
,
void *callbackData
, int eventData1
, int eventData2
)
{
switch (event
)
{
case EVENT_COMMIT
:
QuitUserInterface
(0);
break;
}
return 0;
}