Пример #1
0
void watchdog::feed_dog()
{
    static int time_count = 0;
    int fd;
    int ret;
    static int last_fd;

    //qDebug() << "feed!@@@@@@@@@@@";
    ++time_count;
    //qDebug("sleep %d sec", time_count);
    if (time_count < FEED_DOG_TIMER) {
        ;
    } else {
        time_count = 0;
        count++;
        qDebug("now the watchdog count is %d", count);
        if (count < WATDOG_CYCLE) {
            fd = open(WATCH_DOG_PATH, O_RDWR);
            if (fd < 0)
            {
                perror("~~~~~~~~~~~~~~~open watchdog fail~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
                qDebug("last watdog fd is %d", last_fd);
                recordLog(3, 17, (char*)"~open watchdog fail(feed dog)");
                return;
                //exit(1);
            }
            ret = ioctl(fd, WDIOC_KEEPALIVE, NULL);
            if (ret < 0)
            {
                perror("~~~~~~~~~~~~~~~~~~~~ioctl watchdog fail~~~~~~~~~~~~~~~~~~");
                recordLog(3, 35, (char*)"ioctl watchdog fail~~~(feed dog)");
                //exit(1);
            }

            last_fd = fd;
            if (close(fd) < 0) {
                perror("~~~~~close watdog fd fail~~~~~~~");
                qDebug() << "\n!!!!!!!!!!!!!!!!close watdog fd fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
                recordLog(3, 35, (char*)"close watdog fd fail~~~(feed dog)");

            } else {
                qDebug("now the watdog fd is %d", fd);
            }
            //qDebug() << "feed the dog ok";

        } else {
            qDebug() << "not receive the count change!!! and will reboot";

        }
        if ((count > WATDOG_CYCLE - 2) && (ftpflag == 1)) {
            recordLog(3, 32, (char*)"the network maybe block kill ftpput and ftpget here");
            my_system("/usr/bin/killall ftpput");
            my_system("/usr/bin/killall ftpget");
            count = 0;
        }


    }
}
Пример #2
0
void read_status(const char *arg)
{

    char buf[BUF_SIZE] = {0};
    FILE *fp;
    char *p;

    fp = fopen(arg, "r");
    if (fp == NULL) {
        perror("open status file fail or did not has this file");
        return;
    }

    bzero(buf, BUF_SIZE);
    if ((p = fgets(buf,BUF_SIZE, fp)) == NULL) {
        perror("gets error");
    }
    buf[strlen(buf) - 1] = '\0';
    fclose(fp);

    printf("%s content is %s\n", arg, p);

    //status=00000000;
    strcpy(status, p+7);
    printf("############################now the status is %s########################\n", status);
    sprintf(buf, "read status:%s", status);
    recordLog(1, 49, buf);
    status[0] = '0';//not 0 but '0';
    status[1] = '0';

}
Пример #3
0
void funm(int signo) {
    qDebug("now signal is  %d\n", signo);

    qDebug() << "you are in sensor thread and receive error";
    char buf[100] = {0};
    snprintf(buf, 100, "/bin/echo 'receive %d signal in sensor thread' >> %s", signo, REBOOT_TIME);
    recordLog(1, 80, buf);
    my_system(buf);
    qDebug() << buf;
    if (signo == 11) {
        //sleep(3);
        qDebug() << "invalid memory error here !";
        //qDebug() << "sleep 1";
        //sleep(1);
        //while(1);
    }
    enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    // if (signo == 2) {
    if (ioctl (global_camfd, VIDIOC_STREAMOFF, &type) < 0) {          //
        fprintf(stderr, "\n~~~~~~~~~~~~~cannot stop stream~~~~~~~~~~~~~~~~\n");
        perror("stop fail?");
    } else {
        fprintf(stderr, "stop stream ok\n");
        perror("stop ok?");
    }

    write_to_status(NOW_ERROR_STATUS);

    exit(1);
}
Пример #4
0
void watchdog::set_watdog_time()
{
    int fd;
    int ret;
    int time_out;
    static int last_fd;

    fd = open(WATCH_DOG_PATH, O_RDWR);
    if (fd < 0)
    {
        perror("~~~~~~~~~~~~~~~open watchdog fail~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        qDebug("last watdog fd is %d", last_fd);
        recordLog(3, 17, (char*)"~~open watchdog fail~~~~~~");
        return;
        //exit(1);
    }

    time_out = SET_WATCHDOG_TIME_OUT;
    ret = ioctl(fd, WDIOC_SETTIMEOUT, &time_out);
    if (ret < 0)
    {
        perror("~~~~~~~~~~~~~~~~~~~~~~~~~read watchdog time out error~~~~~~~~~~~~~~~~~~~~");
        recordLog(3, 35, (char*)"read watchdog time out error~~~~~~~~");
        //exit(1);
    }
    qDebug("\n\nnow watchdog time out is %d second            \n", time_out);

    last_fd = fd;

    if (close(fd) < 0) {
        perror("~~~~~close watdog fd fail~~~~~~~");
        recordLog(3, 17, (char*)"close watdog fd fail~~~~~");
        qDebug() << "\n!!!!!!!!!!!!!!!!close watdog fd fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";

    } else {
        qDebug("now the watdog fd is %d", fd);
    }


    qDebug() << "\nset watchdog is ok!!!!!!!!!!!!!!!!!!!!!!!\n";
}
Пример #5
0
//获取自身ip的函数
char * get_ip(char * ipaddr)
{

    int sock_get_ip;
    struct   sockaddr_in *sin;
    struct   ifreq ifr_ip;
    char buf[BUF_SIZE] = {0};

    if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
    {
        recordLog(1, 2, (char*)"socket create fail...GetLocalIp!");
        printf("socket create failse...GetLocalIp!/n");
        strncpy(ipaddr, "socket create fail...GetLocalIp!", IPADDR_SIZE);
        return ipaddr;
    }

    memset(&ifr_ip, 0, sizeof(ifr_ip));
    strncpy(ifr_ip.ifr_name, "eth0", sizeof(ifr_ip.ifr_name) - 1);
    if( ioctl( sock_get_ip, SIOCGIFADDR, &ifr_ip) < 0 )
    {
        recordLog(1, 2, (char*)"ioctl fail...GetLocalIp!");
        perror("ioctl fail");
        strncpy(ipaddr, "ioctl fail to get ip", IPADDR_SIZE);
        return ipaddr;
    }


    sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;
    strcpy(ipaddr,inet_ntoa(sin->sin_addr));

    printf("ip:%s \n",ipaddr);
    snprintf(buf, BUF_SIZE, "ip:%s", ipaddr);
    strcpy(ipaddr, buf);
    close(sock_get_ip);



    return ipaddr;
}
Пример #6
0
void write_to_status(const char *arg)
{

    char buf[BUF_SIZE] = {0};
    FILE *fp;
    int ret;


    fp = fopen(arg, "w");
    if (fp == NULL) {
        perror("open status file fail");
        return;
    }

    if (strlen(status) != 8) {
        bzero(status, STATUS_SIZE);
        strncpy(status,"00000000", 8);
    }

    status[0] = '0';//not 0 but '0';
    status[1] = '0';

    bzero(buf, BUF_SIZE);
    snprintf(buf, BUF_SIZE, "status=%s\n", status);


    printf("now the content of %s is %s\n", arg, status);
    ret = fputs(buf, fp);
    if (ret < 0) {
        perror("puts error");
    }


    fclose(fp);


    sprintf(buf, "write status:%s", status);
    recordLog(1, 49, buf);

}
Пример #7
0
/**
* @brief Function creates a thread
*
* @details Function creates a thread according its cycle time, then
*          unblock the process
*
* @pre void* argument contains argument
*
* @post thread run for its time
*
* @return None
*
*/
   void* thread_perform( void* argument )
      {
       struct pcb_table* temp;   // temp argument
       int time = 0;   // init. time

       temp = ( ( struct pcb_table * ) argument );

       // calculate running time
       time = calcTime( *( temp->current ), *temp );

       // delay that long time
       delay( ( clock_t ) time );

       // print log
       clock_gettime( CLOCK_REALTIME, &endTime );
       totalTime = timeLap( startTime, endTime );
       interruptLog( temp->current, logComment );
       recordLog( &logList, &currentLog, totalTime, logComment );
       if( toMonitor )
          printLog( currentLog );

       // unblock process
       unblockProcess(temp->processNum);
      }   // end of func
Пример #8
0
//
// Main Function Implementation ///////////////////////////////////
//
   int main( int argc, char* argv[] )
      {
       struct pcb_table myPCB = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };   // pcb table
       struct pcb_table *pcbPtr = NULL;   //pcb pointer
       bool isThread = false;   // check if the meta a thread
       bool toFile = false;   // check if the log needs to output to file
       int currentProcess = 0;   // current running process
       pthread_t myThread;   // thread

       currentLog = logList;

       // read config file
       readConfig( argv[1], &myPCB );

       // check if need to print to monitor or file
       if(myPCB.logMode == 1 || myPCB.logMode == 2 )
          toMonitor = true;
       if(myPCB.logMode == 1 || myPCB.logMode == 3 )
          toFile = true;

       // read meta data file, update pointer
       readMeta( myPCB.dataFile, &pcbList, myPCB, &processCounter);
       pcbPtr = pcbList;

       // start timer
       clock_gettime( CLOCK_REALTIME, &startTime ); 

       // print start log
       clock_gettime( CLOCK_REALTIME, &endTime );
       totalTime = timeLap( startTime, endTime );
       recordLog( &logList, &currentLog, totalTime, "Simulator program starting" );
       if( toMonitor )
          printLog( currentLog );

       // print log
       clock_gettime( CLOCK_REALTIME, &endTime );
       totalTime = timeLap( startTime, endTime );
       recordLog( &logList, &currentLog, totalTime, "OS: preparing all processes" );
       if( toMonitor )
          printLog( currentLog );

       // loop around processes
       while( processCounter > 0 )
          {
          // if the process hasn't finished
          if( pcbPtr -> current != NULL )
             {
              // print log
              clock_gettime( CLOCK_REALTIME, &endTime );
              totalTime = timeLap( startTime, endTime );
              recordLog( &logList, &currentLog, totalTime, "OS: seleting next process" );
              if( toMonitor )
                 printLog( currentLog );

              // print log
              clock_gettime( CLOCK_REALTIME, &endTime );
              totalTime = timeLap( startTime, endTime );
              metaStartLog( pcbPtr -> current, pcbPtr, logComment );
              recordLog( &logList, &currentLog, totalTime, logComment );
              if( toMonitor )
                 printLog( currentLog );

              // if the current meta is process
              if( pcbPtr -> current -> component == 'P' )
                 {
                  runProcess( pcbPtr -> current, &pcbPtr );
                  if( pcbPtr -> currentLeft == 0 )
                     {
                      clock_gettime( CLOCK_REALTIME, &endTime );
                      totalTime = timeLap( startTime, endTime );
                      interruptLog(pcbPtr -> current, logComment);
                      recordLog( &logList, &currentLog, totalTime, logComment );
                      if( toMonitor )
                         printLog( currentLog );

                      pcbPtr -> current = pcbPtr -> current -> next;
                      if( pcbPtr -> current != NULL && pcbPtr -> current -> component == 'P' )
                         pcbPtr -> currentLeft = pcbPtr -> current -> cyc_time;
                      if(pcbPtr -> current == NULL)
                         processCounter --;
                     }
                 }

              // if the current meta needs spawn thread
              else
                 {
                  // spawn thread
                  pthread_create( &myThread, NULL, thread_perform, (void*) pcbPtr );

                  // print log
                  clock_gettime( CLOCK_REALTIME, &endTime );
                  totalTime = timeLap( startTime, endTime );
                  blockLog(pcbPtr->current, logComment);
                  recordLog( &logList, &currentLog, totalTime, logComment );
                  if( toMonitor )
                     printLog( currentLog );

                  // block process
                  blockProcess(&pcbList, pcbPtr, &blockQueue);
                 }
             }

          // select next process in queue
          if(pcbPtr -> next == NULL)
             pcbPtr = pcbList;
          else
             pcbPtr = pcbPtr -> next;
          }

       // print ending log
       clock_gettime( CLOCK_REALTIME, &endTime );
       totalTime = timeLap( startTime, endTime );
       recordLog( &logList, &currentLog, totalTime, "Simulator program ending" );
       if( toMonitor )
          printLog( currentLog );

       // output to file
       if( toFile )
          outputToFile( logList, myPCB );

       return 0;
      }   // end of main
Пример #9
0
//-----------------------------------------------------------------------------
void LLEmotionProcessor::update(float elapsedTime)
{
	// suspended?
	if (!m_bActive)
		return;
	
	// iterlate all current active stimulus and sum them up
	// to determine current emotonal state
	// evaluateEmotion() will account for personality values
	iPADIter it, itend;
	itend = m_lPADList.end();

	float p(0.0f), a(0.0f), d(0.0f), ratio(0.0f);
    int numActive = 0;
	for (it = m_lPADList.begin(); it != itend;)
    {
        sPAD* src = *it;

		src->elapsed += elapsedTime;

		// is it alive?
		if (src->lifetime > src->elapsed)
		{
			// any way to smooth in / out of new stimulus?
			// at least, each pad vector should decay over lifetime
			ratio = 1.0f - (src->elapsed / src->lifetime);
			p += src->p * ratio;
			a += src->a * ratio;
			d += src->d * ratio;

			numActive++;
		}
		else
		{
			// delete this one!
			delete src;
			it = m_lPADList.erase(it++);
			continue;
		}

		it++;
	}

	// update current value: may need some normalization here
	if (numActive)
	{
		//m_sPAD.p = p / (float)numActive;
		//m_sPAD.a = a / (float)numActive;
		//m_sPAD.d = d / (float)numActive;
		m_sPAD.p = p;
		m_sPAD.a = a;
		m_sPAD.d = d;
	}

	// convert PAD value to conventional emtotion category
	// -1: Neutral, 0: Angry, 1:Contempt, 2:Disgust, 3:Fear, 4:Happy, 5:Sadness, 6:Surprise
	// compute m_iEmotion (most dominant one) and m_fEmotions (intensity for each categories)
	evaluateMood(elapsedTime);
	
	// Mood = Personality + Averaged Sum of active emotions
	// in fact, we need some blending/smoothing here
	// when new stimulus comes in, Mood gets a sudden change
	// therefore, here we set the target point and interpolate it from current mood
	// let's try 5 second delay style interpolation to minimize discreet change at the moment of new stimulus entry
	m_sTargetMood.p = m_sPAD.p + m_sPersonality.p;
	m_sTargetMood.a = m_sPAD.a + m_sPersonality.a;
	m_sTargetMood.d = m_sPAD.d + m_sPersonality.d;

	// update current mood: interpolation
	// as this is aka dealyed method, it may never catch up to target point
	// because each active emotions change over time based on its lifetime 
	// (refer to the beginning of this func)
	m_sMood.p += (m_sTargetMood.p - m_sMood.p)*elapsedTime*0.2f;
	m_sMood.a += (m_sTargetMood.a - m_sMood.a)*elapsedTime*0.2f;
	m_sMood.d += (m_sTargetMood.d - m_sMood.d)*elapsedTime*0.2f;


	// need some logging file for testing
	// timestamp (sec)	PAD		p	a	d
	// timestamp		EMO		id	value
	m_fLogTimer += elapsedTime;
	recordLog();
	//sprintf(m_cDebugString, "Target Mood: P(%f) A(%f) D(%f)", m_sTargetMood.p, m_sTargetMood.a, m_sTargetMood.d);
	//LLScreenLog::getSingleton().addText(m_cDebugString);
	//sprintf(m_cDebugString, "Emotion Mood: P(%f) A(%f) D(%f)", m_sMood.p, m_sMood.a, m_sMood.d);
	//LLScreenLog::getSingleton().addText(m_cDebugString);

}
Пример #10
0
//-----------------------------------------------------------------------------
void LLEmotionProcessor::processStimulus(int& emotion, float& intensity, float& lifetime)
{
	// convert given an emotion value to PAD vector
	// how to determine lifetime for this stimulus?
	// internal emotion engine does not have any reference for lifetime
	// so, caller must decide how long it should last.
	// reference: Russel & Mehrabian 1977, Asano 2008 (IVA08)
	
	// center of emotional category

	// 0:Angry(-80,80,100), 1:Contempt, 2:Disgust, 3:Fear(-80,80,-100), 4:Happy(80,80,+/-100)(50,0,+/-100), 5:Annoyed/Sadness(-50,0,+/-100), 6:Surprise(10,80,+/-100)
	// missing 1,2 in Ekman's category

	// Zhang(2010)
	// 0:Angry(-59,8,47), 1:Contempt, 2:Disgust(-59,-1,40), 3:Fear(-8,18,-39), 4:Happy(63,40,29), 5:Sadness(-28,-12,-37), 6:Surprise(41,55,19)

	// a few more things need attention here
	// if we use unit vector for each emotion category, what happen in reality?
	// accumulated effect, may never get to the right emotion
	// for example, one whos personality is happy, cannot be sad because there is no unit vector that has negative arousal
	// therefore, we may need to use relative vector from personality in PAD space to given category center
	// in above example, sad stimulus translated to (-P-A-D) instead of (-P00)
	// what if give emotonal stimulus is the same as personality in PAD? zero PAD vector?
	// i.e. happy person got one happy and one sad, then? still should be happy.
	// however, if use zero vector for happy stimulus, it goes close to sad state!!!
	
	// range check just in case
	if (emotion < 0 || emotion > 8)
		return;

	// some exception for contempt and disgust (missing values)
	if (emotion == 1)// || emotion == 2)
		return;

	// for control case
	float oldintensity = intensity;

	// create new PAD vecotor
	sPAD* stimul = new sPAD;
	stimul->emotion = emotion;

	float p,a,d;

	// set vector value
	// nothing fancy here. just use standard emotion PAD vector (center of each emotion in PAD space)
	// may need some complicate alogrithm later
	stimul->intensity = intensity;
	stimul->p = p = m_sEmotion[emotion].p * intensity;
	stimul->a = a = m_sEmotion[emotion].a * intensity;
	stimul->d = d = m_sEmotion[emotion].d * intensity;
	
	// lifetime?
	stimul->lifetime = lifetime;
	stimul->elapsed = 0.0f;
	
	// add stimulus to active list
	m_lPADList.push_back(stimul);
	
	// some consideration for short-term emtoion processing
	// according to ALMA model, he defines short-term emotion as instant stimulus
	// with some factors associated.
	// then, it is used to determine facial expression
	// in my work, i believe it should take current mood into account even though
	// its short-term definition
	// for instance, if a person is very happy mood, he should show higher degree 
	// of happiness on his face in some degree
	// otherwise, its facial expression will be same all the time regardless of
	// current mood
	// therefore, this function should modify input emotion accordingly
	// pseudo equation for this is following
	// EmotionOut = Emotion + c1 x Personality x |Emotion| + c2 x Sum (active emotions)
	// the second term is augmentation by Personality
	// the third term is current mood factor

	
	// should we convert this p,a,d back to emotion category?
	// or somehow compute intensity changing factor out of this?
	//   project p,a,d to stimulus vector: project u onto v  = (v dot u)*v    v is unit vector
	//   determine polarity & length (same direction -> intensify by length, opposite -> decrease by length)
	//   calculate changing factor
	// a bit of issue in this model is all emotioanl categories PAD vector has zero or positive Arousal value in 
	// Mehrabian's paper. therefore, mood vector will always have positive affect to momentary emotion vector
	sPAD v,u;
	v.p = p;
	v.a = a;
	v.d = d;
	v.normalise();

	u.p = m_fPrimaryFactor * m_sPersonality.p + m_fSecondaryFactor * m_sPAD.p;
	u.a = m_fPrimaryFactor * m_sPersonality.a + m_fSecondaryFactor * m_sPAD.a;
	u.d = m_fPrimaryFactor * m_sPersonality.d + m_fSecondaryFactor * m_sPAD.d;
	float moodLength = u.length();

	float dot = (v.p * u.p + v.a * u.a + v.d * u.d);
	v.p *= dot;
	v.a *= dot;
	v.d *= dot;

	float projectLength = v.length();

	// just in case if mood value is all zero
	// or it's perpendicular to emotion
	if (moodLength==0 || projectLength==0.0f)
	{
		// avatar is in very neutral mood status
		// let's cut the intensity by half
		intensity *= 0.5f;

		sprintf(m_cDebugString, "Emotion Value: %d intensityA(%.3f) intensityB(%.3f) PAD(%.2f %.2f %.2f) factor=1.0f", emotion, 0.0f, intensity, p, a, d);
		LLScreenLog::getSingleton().addText(m_cDebugString);

		// thesis
		sprintf(m_cDebugString, "*** Emotion Value0: %f %d %f", m_fLogTimer, emotion, intensity);
		LLScreenLog::getSingleton().addText(m_cDebugString);

		return;
	}

	// apply augmented emotion intensity
	// note that this will only affect current momentary emotion for facial expression and else
	// however, in mood computation, only original emotion stimulus value will be store
	// as mood itself has accumulated augmentation factors in its calculation
	// range of mood factor to the original intensity is 0.25 ~ 1.5
	float factor = projectLength / moodLength;	// 0 ~ 1.0f

	// same direction or opposite?
	if ((v.p * p)  < 0.0f || (v.a * a)  < 0.0f || (v.d * d)  < 0.0f)
	{
		// this is opposite direction
		// larger factor, lesser intensity
		// decrease intensity upto by 75% (0.25)
		// (1.0 - factor) * 0.5 + 0.25    => 0.25 ~ 0.75
		factor = (1.0f - factor) * 0.5f + 0.25f;
		intensity = CLAMP(intensity*factor, 0.0f, 1.0f);
	}
	else
	{
		// increase intensity
		// however double check if it's vector is within a centain range (angle 45 degree) => length > 0.7
		if (factor > 0.7f)
		{
			// upto 50% increase of intensity by mood factor
			// (factor - 0.7)*0.5/0.3 + 1.0   => 1.0 ~ 1.5
			factor = (factor - 0.7f)*1.67f + 1.0f;
			intensity = CLAMP(intensity*factor, 0.0f, 1.0f);
		}
		else
		{
			// about same direction with angle > 45 degree
			// slightly decrease upon its length
			// decrease intensity upto by 25%
			// (factor/0.7)*0.25 + 0.75    => 0.75 ~ 1.0
			factor = factor * 0.357f + 0.75f;
			intensity = CLAMP(intensity*factor, 0.0f, 1.0f);
		}
	}
	
	// the final factor may be considered
	// accumulated same emotions. i.e. happy, happy, happy => creater happy
	// does it matter if it's alive or not?
	// if matters, need to use active emotion list instead
	// using active list
	factor = 1.0f;
	int counter = 0;
	iPADRIter it, itrend;
	it = m_lPADList.rbegin(); 
	it++;		// skip the one just added
	itrend = m_lPADList.rend();
	for (; it != itrend;)
	{
		sPAD* src = *it;
		if (src->emotion == emotion)
			//factor *= 1.1f;
			factor *= 1.05f;		// 2013.7.6
		else
			break;

		// only for the three latest active emotions
		counter++;
		if (counter > 2)
			break;

		it++;
	}
	// apply repeated emotion factor: upto 33% increase in addition to mood factor
	intensity = CLAMP(intensity*factor, 0.0f, 1.0f);

//#ifdef _DEBUG
	//sprintf(m_cDebugString, "Emotion Value: %d intensityA(%f) intensityB(%f) PAD(%f %f %f) factor=%f", emotion, oldintensity, intensity, p, a, d, factor);
	//LLScreenLog::getSingleton().addText(m_cDebugString);
//#endif

	recordLog(emotion, intensity, lifetime);

	// for control case: emotion does not alter the original intensity value for facial expression
	//if (!m_bUseEmotionalExpression)
	//	intensity = 0.5f;	// strictly uniform expression

	// manual control: thesis testing purpose (0.5 or commented out)
	sprintf(m_cDebugString, "*** Emotion Value1: %f %d %f %f", m_fLogTimer, emotion, oldintensity, intensity);
	LLScreenLog::getSingleton().addText(m_cDebugString);
	//intensity = 0.5f;
}
Пример #11
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    char buf[400];

    global_app = &a;
    //enable the watchdog
    global_wdg->start(QThread::HighPriority);
    //global_wdg->watchdog_timer.start(45*1000);

    //drawPrimitive();
    // QWSServer::setCursorVisible(false);
    //no valid
    //a.setOverrideCursor(Qt::BlankCursor);

    //system("/bin/rm /var/log/eth0-setting.log");
    //system("/bin/rm /etc/rebootTime");
    //register segment default
    signal(SIGSEGV,func);

    //my_system("ps");

    arg_main = argv[0];
    //camThread camera;
    //camera.start(QThread::LowPriority);

    setting_timezone();
    
    dealLog(0, 0, 0, 0);
    
    sprintf(buf, "\n**************Cartvu:VERSION:%4.2f**********************\n", CARTVU_NOW_VERSION);
    qDebug() << buf;
    recordLog(1, 1, buf);

    sprintf(buf, "df >>%s", filename);
    my_system(buf);


    recordLog(1, 1, (char*)"reboot time here!!!");

    sprintf(buf, "%s size is %ld", argv[0], read_self_size(argv[0]));
    printf("%s\n", buf);
    recordLog(1, 1, buf);


    global_buffer = (unsigned char *)malloc(CAMERA_WIDTH * CAMERA_HEIGHT * CAM_LINELEN);   // allocate memory for camera
    if (!global_buffer) {
        perror("shmat shm_buffer fail");
        recordLog(1, 1, (char*)"malloc camera buffer fail!!");
        //exit(1);
    }

    global_camera = new camThread(global_buffer);              // instance of a camera class
    //global_camera->start(QThread::LowPriority);
    qDebug() << "camera start";
    qDebug() << global_camera;


    //global_sensor->start();




    global_rsys = new read_sys(config_sys);
    //download config.sys file  read local server ip
    //读取当前的config.sys的信息
    global_rsys->sys_decode(CFG_SYS, config_sys);
    //读取eth0-setting中的mac及lane number
    global_rsys->read_eth0(ETH0SETTING); //read mac  and lane number
    //程序启动后的随机延时,延时后进去登陆下载等步骤

    //显示登陆窗口
    //cartvu *w = new cartvu(global_camera);
    global_log = new login(global_camera);
    //系统开机的随机延时
    global_rsys->get_file_delay();//need local server ip
    //解码    将user密码与接收到的加密的密码比较
    global_rsys->decode_passwd("car1998", CONFIG_ADMIN);


    // QTranslator translator;
    // translator.load("zh_CN",".");
    // a.installTranslator(&translator);


#if 1
    //global_log->show();
    ;
#else
    w->showFullScreen();
#endif
    return a.exec();
}