gasclient_bak.cpp

来自「LINUX系统下基于ARM处理器的使用GPRS方式通过SOCKET数据包进行煤矿」· C++ 代码 · 共 128 行

CPP
128
字号
#include "CB_SysParam.h"
#include "CB_User.h"
#include "CB_Freal.h"
#include "CB_Tools.h"
#include "CB_GasCliInfo.h"
#include <sys/time.h>
#include <sys/timeb.h>
#include "Afx.h"
#include "CB_Info.h"
#include "CB_Unit.h"
#include "CB_Profile.h"
#include "CB_String.h"
#include "CB_Socket.h"

static char *DATATYPE[]={"KJF2000","KJF4"};
bool isSocketEnable = true;

int main(int argc,char *argv[])
{
  CB_GasCliInfo *pInfo = new CB_GasCliInfo();  
  //pInfo ->initalize();

  if(argc<2){
	printf(pInfo->getHelp());
	exit(1);
  }
  char *argv_1 = argv[1];
  CB_Unit::trim(argv_1);
  
  if(strcasecmp(argv_1,"--help")==0){
	printf(pInfo->getHelpDetail());
	exit(1);
  }else if(strcasecmp(argv_1,"--version")==0){
	printf(pInfo->getVersion());
	exit(1);
  }
  delete pInfo;

  CB_SysParam cSysParam;
  if(setSysParam(&cSysParam,argv_1)<0)
  {
    printf("setSysParam failed.\n");
	printf("The System will be restarted after 60 sec.\n");
	//sleep(60);
	//system("reboot");
  }
  printf("setSysParam success.\n");
  
  sleep(cSysParam.getDelay()); 
  
  if(setTimeStamp(&cSysParam)<0){
    printf("The System will be restarted after 60 sec.\n");
    //sleep(60);
    //system("reboot"); 
  }
  
  pid_t pid_real_run;  
  if((pid_real_run=fork())==0){
	isRealRun(&cSysParam);
  }else if(pid_real_run>0){
    
  }else{
    perror("pid_real_run error."); 
  } 
  
  CB_Socket::m_port = atoi(cSysParam.getPort());
  CB_Socket::m_ip = cSysParam.getHost();

  CB_User cUser;    
  cUser.setSocketEnable(isSocketEnable);
  if(setUserMsg(&cSysParam,&cUser)<0)
  {
    printf("setUserMsg failed.\n");
	printf("The System will be restarted after 60 sec. \n");
	//system("reboot");
  }
  printf("setUserMsg success.\n");
  
  pid_t pid_ip;
  if((pid_ip=fork())==0){
    processIP(&cUser);
  }else if(pid_ip>0){
    
  }else{
    perror("pid_ip error."); 
  }
  
  if(convertInitdata(&cSysParam,&cUser)<0){
    printf("convert initdata.txt error. \n");
	printf("The System will be restarted after 60 sec. \n");
	//system("reboot");
  }
  printf("convert initdata.txt success. \n");
  
  pid_t pid_chg_init;
  if((pid_chg_init=fork())==0){
	checkInitdataChange(&cSysParam,&cUser);
  }else if(pid_chg_init>0){
   
  }else{
    perror("pid_chg_init error."); 
  }

  pid_t pid_chg_real;
  if((pid_chg_real=fork())==0){
	checkRealdataChange(&cSysParam,&cUser);
  }else if(pid_chg_real>0){
    
  }else{
    perror("pid_chg_real error."); 
  }

  /*
  pid_t pid_real_stop;
  if( (pid_real_stop=fork())==0)
  {
     checkRealStop(&cSysParam,&cUser);
  }else if(pid_real_stop>0){ 
  
   }
   else{
    perror("pid_real_stop error.");
   }
  */
  return 0; 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?