Example #1
0
void XRayTube::CoolDnXTube() { //run this func whenstatus != PreOpen, Opening, StandBy, Closed
	double actionLast;
	switch(m_status) {
		case Ready:
		case WarmingUp:
		case Sleep:
			SetMA(0.0);
			m_MaTarget = 0.0;
		    m_status=CoolingDnMA;
		    actionStart=getTimerTicks();
			break;
		case CoolingDnMA:
		    actionLast=0.055*(getTimerTicks()-actionStart);
			if(actionLast>3){
				SetHV(0.0);
				m_HvTarget = 0.0;
				m_status=CoolingDnHV;
				actionStart=getTimerTicks();
			}
			break;
		case CoolingDnHV:
			actionLast=0.055*(getTimerTicks()-actionStart);
			if(actionLast>3){
		        SetDioBit(DrvPort,DrvBit,FALSE);
		        m_status=Closed;   
		    }
		    break;
		}
	}
Example #2
0
void XRayTube::WarmUpXTube() // switchingToTubeReady, switchingToSampling
{
    switch(m_status) {
		case Closed:
			if(CanOpen()){ // change m_status to 'PreOpen', then change to 'Opening', 'StandBy' in function ::Update()
			    Open();
			    m_status = PreOpen;
			} 
			break;
		case StandBy:
		case Ready:
		case CoolingDnHV:
		case CoolingDnMA:
		//case WarmingUp:
			CalculateWarmUpSteps(); // 1.0kv, 10ma
			m_HvTarget += m_HvStep;
			if(m_HvTarget>m_WorkingHV) m_HvTarget=m_WorkingHV;
			m_MaTarget += m_MaStep;
			if(m_MaTarget>m_WorkingMA) m_MaTarget=m_WorkingMA;
			SetHV(m_HvTarget); SetMA(m_MaTarget);
			actionStart=getTimerTicks();
			m_status=WarmingUp;
			break;
	}
}
Example #3
0
void XRayTube::Open(){
    //m_HvTarget=0;m_MaTarget=0;
	//SetHV(-1.0);SetMA(-1.0);
	SetDioBit(DrvPort,DrvBit,TRUE);
	actionStart=getTimerTicks();
	//m_status=PreOpen;
}
/*----------------------------------------------------------------------------------------------------------------------------------
** Function Name : SetTimerEvent
** Description   : Init timer tick event
** Input         : Event and desired time
** Output        : Nothing
** Notes         : 
----------------------------------------------------------------------------------------------------------------------------------*/
void setTimerEvent( tTimerTime *event, dword miliSeconds ) {
	dword Tics = ( miliSeconds * TIMER_TICKS_PER_SECOND ) / MSECS_PER_SECOND;

	/* The largest accepted timer event is 24 hours */
	if( Tics > TICS_PER_DAY )   {
		Tics = TICS_PER_DAY;
	}

	event->Start = getTimerTicks();
	event->Expiration = event->Start + Tics;
}
/*----------------------------------------------------------------------------------------------------------------------------------
** Function Name : TimerHasExpired
** Description   : Check if one timer has expired
** Input         : The timer
** Output        : TRUE is timer has expired
** Notes         : 
----------------------------------------------------------------------------------------------------------------------------------*/
bool TimerHasExpired( tTimerTime *Event ) {
	dword CurrentTics;

	/* get current tics; assume timer has expired */
	CurrentTics = getTimerTicks();

	/* Check normal expiration */
	if ( CurrentTics > Event->Expiration )  {
		return( TRUE );
	}

	/* Check wrapped CurrentTics */
	if (( CurrentTics < Event->Start ) && (( CurrentTics + TICS_PER_DAY ) > Event->Expiration ))  {
		return( TRUE );
	}

	return ( FALSE );
}
/*----------------------------------------------------------------------------------------------------------------------------------
** Function Name : getMillis
** Description   : Return the number of milliseconds since the program started (unsigned long)
** Input         : Nothing
** Output        : milliseconds since the program started 
** Notes         : 
----------------------------------------------------------------------------------------------------------------------------------*/
dword getMillis(void) {
	return ((getTimerTicks() * MSECS_PER_SECOND) / TIMER_TICKS_PER_SECOND);
}
Example #7
0
void XRayTube::Update(){
	double actionLast;
    AnalogUpdate();   
    ReadHV(); ReadMA();
    ReadPower24Vol(); ReadPower5Vol(); ReadPower12Vol();
    ReadH2500HV();
    ReadStdHV();
    if(bH2500VolDaout)
    {
        SetH2500HV(m_H2500WorkingHV);
    }
    switch(m_status){
    case Closed:
        break;
    case PreOpen:
        actionLast=0.055*(getTimerTicks()-actionStart);
		if(actionLast>3.0) {
			m_HvTarget=m_SafeHV;m_MaTarget=m_SafeMA;
			SetHV(m_HvTarget); SetMA(m_MaTarget);
			actionStart=getTimerTicks();
			m_status=Opening;
		}
        break;
    case Opening:
        if((m_HvTarget-m_CurrHV<1.0) && (m_MaTarget-m_CurrMA<10)) 
            m_status=StandBy; 
        /*
        else {
		    actionLast=0.055*(getTimerTicks()-actionStart);
		    if(actionLast>5.0) {
			    gotoxy(70,1);textattr(0x1f);cprintf("TubeError#1");
			    Close();
			}
		}*/
        break;
    case StandBy:
        break;
    case Ready:
        break;
    case Sleep:
        actionLast=0.055*(getTimerTicks()-actionStart);
		if(actionLast>m_delaySeconds){ 
			//if((m_HvTarget==m_WorkingHV)&&(m_MaTarget==m_WorkingMA)) {
			if((fabs(m_WorkingHV-m_HvTarget)<0.1) &&
			    (fabs(m_WorkingMA-m_MaTarget)<1.0)){
				//m_HvAdjustStart=getTimerTicks();
				//m_MaAdjustStart=getTimerTicks();
				m_status=Ready; //reach 50kv, 100ma !
			}
			else{
				m_HvTarget+=m_HvStep;
				if(m_HvTarget>m_WorkingHV) m_HvTarget=m_WorkingHV;
				m_MaTarget+=m_MaStep;
				if(m_MaTarget>m_WorkingMA) m_MaTarget=m_WorkingMA;
				SetHV(m_HvTarget); SetMA(m_MaTarget);
				actionStart=getTimerTicks();
				m_status=WarmingUp;
			}
		}
        break;
    case WarmingUp: //WarmUpXTube() will change XRayTube::m_status to 'WarmingUp'
        actionStart=getTimerTicks(); //HVDEBUG, delete this row in release version
        m_status=Sleep; //HVDEBUG, delete this row in release version

        /* 
		if((m_HvTarget-m_CurrHV<2.0) && (m_MaTarget-m_CurrMA<10.0)) {
			actionStart=getTimerTicks();
			m_status=Sleep;
		}
		else {
			actionLast=0.055*(getTimerTicks()-actionStart);
			if(actionLast>5) {
				gotoxy(70,1);textattr(0x1f);cprintf("TubeError#2");
				CoolDnXTube();
			}
  		} */
		break;
    }
}
Example #8
0
void XInstrument::Update() {
    m_pSampleLid->Update();
    m_pSampleLid->Show();
    m_pBeamStop->Update();
    m_pBeamStop->Show();
    m_pXRayTube->Update();
    m_pXRayTube->Show();
    m_pShamber->Update();
    m_pShamber->Show();
    m_pLight->Show();
    m_pKey->Show();
    pCh->Show();
    UpdateCommport();
    ShowComStatus();
	switch(m_status) {
	case Idle:
	case StandBy:
	case TubeReady:
	case Sampling:
		pCh->Update();
		if(SamplingStarted&&pCh->SampleFinished()) {
			gotoxy(70,1);textattr(0x1f);cprintf("Finished!  ");
			Running=FALSE;
			pause=FALSE;
			SamplingStarted=FALSE;
			// m_status = SwitchToTubeReady; //added by chen @ 05-23
		}
		break;
	case SwitchToSampling: 
		if(m_pXRayTube->m_status!=XRayTube::Ready) m_pXRayTube->WarmUpXTube();
		if(m_pBeamStop->ShutOpenedStatus!=TRUE) m_pBeamStop->Open();
		//if(CanStartSample())
		if(TRUE)
			StartSample();
		break;
	case SwitchToTubeReady: // receive E command
		if(SamplingStarted) {
			Running=FALSE;
			pCh->ReadyStart=FALSE;
			gotoxy(70,1);textattr(0x4e);cprintf("  Stoped!  ");
			SamplingStarted=FALSE;
		}
		if(m_pBeamStop->ShutOpenedStatus!=FALSE) m_pBeamStop->Close(); //@ 2012-06-11
		
	    if(m_pXRayTube->m_status==XRayTube::Closed) {
	        m_pXRayTube->Open();
			m_pXRayTube->m_status=XRayTube::PreOpen;
			m_pXRayTube->actionStart=getTimerTicks();
	    }
		//else if(m_pXRayTube->m_status!=XRayTube::Ready) m_pXRayTube->WarmUpXTube();
		else m_pXRayTube->WarmUpXTube();
		m_pXRayTube->CheckReady(); //newly added @ 2012.4.15
		if(CheckInstrumentStatus(TubeReady)) m_status=TubeReady;
		break; 
	case SwitchToStandBy: //receive e command
		if(SamplingStarted) {
			Running=FALSE;
			pCh->ReadyStart=FALSE;
			gotoxy(70,1);textattr(0x4e);cprintf("  Stoped!  ");
			SamplingStarted=FALSE;
		}
		if(m_pBeamStop->ShutOpenedStatus!=FALSE) m_pBeamStop->Close();//@ 2012-06-11
		if(m_pXRayTube->m_status==XRayTube::Closed) {      
			if(m_pXRayTube->CanOpen()) {
			    m_pXRayTube->Open();
			    m_pXRayTube->actionStart=getTimerTicks();
			    m_pXRayTube->m_status=XRayTube::PreOpen;
			}
		}
		else if(m_pXRayTube->m_status!=XRayTube::StandBy) {
		    m_pXRayTube->CoolDnXTube();
		}
		if(CheckInstrumentStatus(StandBy)) m_status=StandBy;
		break;
	case SwitchToIdle:  //receive e command
		if(SamplingStarted) {
			Running=FALSE;
			pCh->ReadyStart=FALSE;
			gotoxy(70,1);textattr(0x4e);cprintf("  Stoped!  ");
			SamplingStarted=FALSE;
		}
		//if(m_pBeamStop->CanClose()) m_pBeamStop->Close();
		if(m_pBeamStop->ShutOpenedStatus!=FALSE) m_pBeamStop->Close(); //@ 2012-06-11
		//if(m_pXRayTube->m_status == XRayTube::Closed) do nothing		
		if((m_pXRayTube->m_status == XRayTube::PreOpen) || (m_pXRayTube->m_status == XRayTube::Opening) || (m_pXRayTube->m_status == XRayTube::StandBy)){
		    m_pXRayTube->Close();
		}
		else if(m_pXRayTube->m_status != XRayTube::Closed){ // status=Ready or WarmingUp or CoolingDn or Sleep
		    m_pXRayTube->CoolDnXTube();
		}
		if(CheckInstrumentStatus(Idle)) m_status=Idle;
		break;
	} 
}
Example #9
0
void XInstrument::Run() {
	BOOL exit=FALSE;BYTE comCh;int i,key=0;
	ScreenLayOut();
	BOOL hasKey=FALSE,hasComCmd=FALSE;
	PrepairAdConv();
	StartComService(0,B28800,8,1,NONE);
	while(!exit)
	{
		while(!(hasKey=(BOOL)bioskey(1))&&!(hasComCmd=CheckComBuffer()))
		{
			Update();Show();
		}
		if(hasKey)
		{
			key=bioskey(0);
			switch(key)
			{
			case 0x11b:
				exit = TRUE;
				break;
			case 0x3b00: //F1
				m_status=SwitchToIdle;
				break;
			case 0x3c00: //F2
				//m_status=SwitchToStandBy;
				break;
			case 0x3d00: //F3
				m_status=SwitchToSampling;
				break;
			case 0x3e00: //F4
				if(!Running){
				    pCh->ShowCurve();
				    ScreenLayOut();
				}
				break;
			case 0x3f00:
				break;
			    /*
				DWORD crc;BYTE ret;
				OneChannel* p1Ch=NULL;
				p1Ch=pCh->GetChnAndMoveToNext();
				if(p1Ch==NULL)	{
					AddToSendBuffer(0xff);
					gotoxy(50,1);textattr(0x17);cprintf("Null      ",comCh);
				}
				crc=0xffffffff;
				ret=0x50;AddToSendBuffer(ret);UpdateCRC32(ret,crc);
				ret=p1Ch->Finished;AddToSendBuffer(ret);UpdateCRC32(ret,crc);
				Add2ToSendBuffer(p1Ch->CurrTimes,crc);
				DWORD chData;
				for(i=0;i<1024;i++)
				{
					chData=p1Ch->data[i];
					//chData=1024 - abs(i-512);//DEBUG
					Add4ToSendBuffer(chData,crc);
				}
				crc^=0xffffffff;
				AddToSendBuffer(crc>>24);
				AddToSendBuffer(crc>>16);
				AddToSendBuffer(crc>>8);
				AddToSendBuffer(crc);
				UpdateCommport();
				break;*/
			 /*
			 case 0x1910:
				Running=FALSE;
				pCh->ReadyStart=FALSE;
				pause=TRUE;
				gotoxy(70,1);textattr(0x16);cprintf(" Paused... ");
				break;
			case 0x1414:
				Running=FALSE;
				pCh->ReadyStart=FALSE;
				gotoxy(70,1);textattr(0x4e);cprintf("  Stoped!  ");
				break; */
			}
		}
		else if(hasComCmd)
		{
			DWORD crc,crcClip;BYTE ret;int len,curCh=0;
			if(ReceivingBxConfig)
			{
			    len=GetBufferLen();
			    if(len>=38)  // @2012-06-05
			    {
			        FloatByte floatByte;
			        ShortByte shortByte;
			        //set env param
					for(i=0;i<4;i++) {
						ret=floatByte.byte[i]=ReadComBuffer();
						UpdateCRC32(ret,crcBxConfig);
					}
					m_pXRayTube->m_WorkingHV=floatByte.real;
					//m_pXRayTube->SetHV(floatByte.real); //DEBUG


					for(i=0;i<4;i++) {
						ret=floatByte.byte[i]=ReadComBuffer();
						UpdateCRC32(ret,crcBxConfig);
					}
					m_pXRayTube->m_WorkingMA=floatByte.real;
					//m_pXRayTube->SetMA(floatByte.real); //DEBUG

					for(i=0;i<4;i++) {
						ret=floatByte.byte[i]=ReadComBuffer();
						UpdateCRC32(ret,crcBxConfig);
					}
					m_pXRayTube->m_H2500WorkingHV=floatByte.real;
					m_pXRayTube->bH2500VolDaout=TRUE;
					//m_pXRayTube->SetH2500HV(floatByte.real); //DEBUG

					ret=ReadComBuffer();
					//m_pLight->SetPanel1((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetPanel2((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetPanel3((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetPanel4((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetPanel5((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetLamp1((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetLamp2((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetLamp3((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer();
					//m_pLight->SetLamp4((BOOL)ret);
					UpdateCRC32(ret,crcBxConfig);

					ret=ReadComBuffer(); UpdateCRC32(ret,crcBxConfig);
					if(!ret){
						//if(m_pShamber->CanClose()) m_pShamber->Close(); //close fan
					}
					else{
						//if(m_pShamber->CanOpen()) m_pShamber->Open();   //open fan
					}
					
					ret=ReadComBuffer(); UpdateCRC32(ret,crcBxConfig);
					if(ret) {
					    //m_status=SwitchToTubeReady; //m_pXRayTube->WarmUpXTube();
					}
					else {
					    //m_status=SwitchToIdle; //m_pXRayTube->CoolDnXTube();
					}

					ret=ReadComBuffer(); UpdateCRC32(ret,crcBxConfig); 
					if(!ret){
						//if(m_pBeamStop->CanClose())
						//m_pBeamStop->Close();
					}
					else{
						//if(m_pBeamStop->CanOpen())
						//m_pBeamStop->Open();

					}

					for(i=0;i<2;i++) {
						ret=shortByte.byte[i]=ReadComBuffer();
						UpdateCRC32(ret,crcBxConfig);
					}
					pCh->SetChannelTimer(0,shortByte.real);
					
					for(i=0;i<4;i++) {
						ret=floatByte.byte[i]=ReadComBuffer();
						UpdateCRC32(ret,crcBxConfig);
					}
					m_pShamber->m_ULimitTemp=floatByte.real;
					
					for(i=0;i<4;i++) {
						ret=floatByte.byte[i]=ReadComBuffer();
						UpdateCRC32(ret,crcBxConfig);
					}
					m_pShamber->m_DLimitTemp=floatByte.real;

					crcBxConfig^=0xffffffff; 
					crcClip=ReadComBuffer();
					crc=crcClip<<24;
					crcClip=ReadComBuffer();
					crc+=crcClip<<16;
					crcClip=ReadComBuffer();
					crc+=crcClip<<8;
					crcClip=ReadComBuffer();
					crc+=crcClip;  

					if(crcBxConfig==crc)
					{
						AddToSendBuffer('*');
						//gotoxy(1,1);textattr(0x17);cprintf("0x%x,len=%2d,crc ok  ,",comCh,len+1); //debug
					}
					else
					{
						AddToSendBuffer(0xff);
						gotoxy(1,1);textattr(0x17);cprintf("0x78,len=%2d,crc err ,",len+1); //debug
					}
					UpdateCommport();
					ReceivingBxConfig=FALSE;
				}
			    else //receive time out
			    {
					if(getTimerTicks()-ReceivingBxConfigStart>4)
			        {
						gotoxy(1,1);textattr(0x17);cprintf("0x%x,len=%2d,Time out,",comCh,len+1); //debug
			            ClearReceiveBuff();
						AddToSendBuffer(0XFF);
						UpdateCommport();
						ReceivingBxConfig=FALSE;
			        }
			    }
			}
			else
			{	    
				DWORD crc,crcClip;BYTE ret;int len;
				FloatByte floatByte;	
				comCh=ReadComBuffer();
				
				switch(comCh) {
				case 'x': // 0x78, receive configuration
					ReceivingBxConfig=TRUE;
				    ReceivingBxConfigStart=getTimerTicks();
					crcBxConfig=0xffffffff;
					UpdateCRC32('x',crcBxConfig);
					break;
				case 'E': // 0x45, 
					AddToSendBuffer('*');
					UpdateCommport();
					m_status=SwitchToTubeReady;
				    break;
				case 'e': // 0x65, 
					AddToSendBuffer('*');
					UpdateCommport();
					m_status=SwitchToIdle;//SwitchToStandBy;
				    break;
				case 'L':
				    //open beam-shut
				    AddToSendBuffer('*');
					UpdateCommport();
				    m_pBeamStop->Open();
				    break;
				case 'l':
				    //close beam-shut
				    AddToSendBuffer('*');
					UpdateCommport();
				    m_pBeamStop->Close();
				    break;
				case 'B':
				    AddToSendBuffer('*');
					UpdateCommport();
				    m_pLight->SetLamp1(TRUE);
				    m_pLight->SetLamp2(TRUE);
				    m_pLight->SetLamp3(TRUE);
				    m_pLight->SetLamp4(TRUE);
				    break;
				case 'b':
				    AddToSendBuffer('*');
					UpdateCommport();
				    m_pLight->SetLamp1(FALSE);
				    m_pLight->SetLamp2(FALSE);
				    m_pLight->SetLamp3(FALSE);
				    m_pLight->SetLamp4(FALSE);
				    break;
				case 'S': // 0x53, start sampling
					AddToSendBuffer('*');
					UpdateCommport();
					m_status=SwitchToSampling;
					break;
				case 'P': // 0x50, upload sample data, 1034 Bytes, @2012-06-05
					OneChannel* p1Ch=NULL;
					p1Ch=pCh->GetChnAndMoveToNext();
					if(p1Ch==NULL)	{
						AddToSendBuffer(0xff);
						gotoxy(50,1);textattr(0x17);cprintf("Null      ",comCh);
					}
					else{
						crc=0xffffffff;
						ret=0x50;AddToSendBuffer(ret);UpdateCRC32(ret,crc);
						ret=p1Ch->Finished;AddToSendBuffer(ret);UpdateCRC32(ret,crc);
						Add2ToSendBuffer(p1Ch->CurrTimes,crc);
						Add2ToSendBuffer(p1Ch->SetRepeatTimes,crc); //added by Chen @2012-06-04
						DWORD chData;
						//for(i=0;i<1024;i++) //debug
						//{
							//chData=p1Ch->data[i];
							//chData^=0xaaaaaaaa;
							//p1Ch->data[i]=chData=512 - abs(i-512);//DEBUG
							//Add4ToSendBuffer(chData,crc);
						//}
						
						for(i=0;i<256;i++)
						{
						    chData=p1Ch->data[i*4]+
						        p1Ch->data[i*4+1]+
						        p1Ch->data[i*4+2]+
						        p1Ch->data[i*4+3];
						    //chData = chData/4;
						    Add4ToSendBuffer(chData,crc);
						}
						crc^=0xffffffff;
						AddToSendBuffer(crc>>24);
						AddToSendBuffer(crc>>16);
						AddToSendBuffer(crc>>8);
						AddToSendBuffer(crc);
					}
					UpdateCommport();    
					break;			
				case 'X': // 0x58,upload Environment, 52 Bytes, @2012-06-05
					crc=0xffffffff;
					ret=0x58; AddToSendBuffer(ret); UpdateCRC32(ret,crc);
					ret=m_status; AddToSendBuffer(ret); UpdateCRC32(ret,crc);
					
					//m_pXRayTube->ReadHV();    //(1)KV
					floatByte.real=m_pXRayTube->m_CurrHV; 
					//for(i=3;i>=0;i--){
					for(i=0;i<4;i++){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pXRayTube->ReadMA();
					floatByte.real=m_pXRayTube->m_CurrMA; //(2)MA
					for(i=0;i<4;i++){
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pXRayTube->ReadStdHV();
					floatByte.real=m_pXRayTube->m_StdCurrHV; //(3)Std KV
					for(i=0;i<4;i++) {
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pXRayTube->ReadH2500HV();
					floatByte.real=m_pXRayTube->m_H2500CurrentHV; //(4)H2500 Vol
					for(i=0;i<4;i++) {
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pXRayTube->ReadPower24Vol();
					floatByte.real=m_pXRayTube->Power24Vol; //(5)power 24v
					for(i=0;i<4;i++) {
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pXRayTube->ReadPower12Vol();
					floatByte.real=m_pXRayTube->Power12Vol; //(6)power 12v
					for(i=0;i<4;i++) {
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pXRayTube->ReadPower5Vol();
					floatByte.real=m_pXRayTube->Power5Vol; //(7)power 5v
					//for(i=0;i<4;i++) {
					for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pShamber->ReadAngle();
					floatByte.real=m_pShamber->CurrAngle; //(8)angle
					for(i=0;i<4;i++) {
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					//m_pShamber->ReadTemp();
					floatByte.real=m_pShamber->m_CurrTemp1; //(9) temperature 1
					for(i=0;i<4;i++) {
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					floatByte.real=m_pShamber->m_CurrTemp2; //(10) temperature 2
					for(i=0;i<4;i++) {
					//for(i=3;i>=0;i--){
						ret=floatByte.byte[i];
						AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					}

					m_pKey->ReadAllKeyStatus();
					ret=m_pKey->Key1OnStatus;
					AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					ret=m_pKey->Key2OnStatus;
					AddToSendBuffer(ret);UpdateCRC32(ret,crc);

					m_pBeamStop->ReadBeamStopPos();
					ret=m_pBeamStop->OpenPos; //shut open position 
					AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					
					ret=m_pBeamStop->ClosePos; //shut close position 
					AddToSendBuffer(ret);UpdateCRC32(ret,crc);
						
                    m_pSampleLid->ReadSampleLidPos();
					ret=m_pSampleLid->Lid1OpenedStatus; //lid1 status
					AddToSendBuffer(ret);UpdateCRC32(ret,crc);

					ret=m_pSampleLid->Lid2OpenedStatus; //lid2 status
					AddToSendBuffer(ret);UpdateCRC32(ret,crc);
					crc^=0xffffffff;
					AddToSendBuffer(crc>>24);
					AddToSendBuffer(crc>>16);
					AddToSendBuffer(crc>>8);
					AddToSendBuffer(crc);
					UpdateCommport();
					break;
				default:
					//len=GetBufferLen();
					//gotoxy(1,1);textattr(0x17);printf("unknow=%x,len=%d,",comCh,len);
					break;
				}//end switch
				//len = GetBufferLen();
				//gotoxy(1,1);textattr(0x17);printf("0x%x,len=%2d,         ",comCh,len+1);

		    }
		}
	}
	StopComService();
	_setcursortype(_NORMALCURSOR);
}