12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdarg.h>
- #include <syslog.h>
- #include <unistd.h>
- #include "appl.h"
- #include "tool.h"
- static void sim_init( void )
- {
- STA.uab = 400.1;
- STA.ubc = 400.2;
- STA.uca = 400.3;
- }
- int DAEMON = 0;
- int RUNTYPE = -1;
- int VERSION[3] = {2, 0, 5}; /* ONLY VERSION[0] is used */
- static char* s_optstr = "a:b:cdep:s:t:";
- int main(int argc, char *argv[])
- {
- int ret = 0;
- int i = 0;
- int ch;
- opterr = 0;
- openlog(argv[0], LOG_CONS | LOG_PID, 0);
- syslog(LOG_INFO, "%s,++",__func__);
- for( i = 0; i < argc; i++ ){
- syslog(LOG_INFO, "%s,arg list,argv[%d]:%s",__func__,i,argv[i]);
- }
- strcpy(STA.szdev,"Enjoy-100kW");
- while ((ch = getopt(argc,argv,s_optstr))!=-1){
- switch(ch){
- case 'a':
- STA.adr = atoi(optarg);
- syslog(LOG_INFO, "option a: %s \n",optarg);
- break;
- case 'b':
- strcpy(STA.szser, optarg);
- syslog(LOG_INFO,"option b: %s\n", optarg);
- break;
- case 'd':
- DAEMON = 1;
- syslog(LOG_INFO,"option d\n");
- break;
- case 'p':
- STA.mqtt_servport= atoi(optarg);
- syslog(LOG_INFO,"option p : %s\n", optarg);
- break;
- case 's':
- strcpy(STA.szmqtt_servip, optarg);
- syslog(LOG_INFO,"option s : %s\n", optarg);
- break;
- case 't':
- if(strcmp("appl", optarg)==0){
- RUNTYPE = 0;
- }else if(strcmp("tool", optarg)==0){
- RUNTYPE = 2;
- }else{
- RUNTYPE = -1;
- }
- break;
- default:
- syslog(LOG_INFO, "other option :%c\n",ch);
- }
- }
- sim_init();
- if( RUNTYPE == 0 ){
- appl_main();
- }else if( RUNTYPE == 2 ){
- tool_main();
- }else{
- syslog(LOG_INFO, "%s, unknown runtype:%d",__func__, RUNTYPE);
- }
- syslog(LOG_INFO, "%s, --",__func__);
- closelog();
- return 0;
- }
|