Esempio n. 1
0
static void OnBallastData(DataField *Sender, DataField::DataAccessKind_t Mode){
  static double lastRead = -1;

  switch(Mode){
  case DataField::daSpecial:
    if (BALLAST>0.01) {
      BallastTimerActive = !BallastTimerActive;
    } else {
      BallastTimerActive = false;
    }
    ((WndButton *)wf->FindByName(TEXT("buttonDumpBallast")))->SetVisible(!BallastTimerActive);
    ((WndButton *)wf->FindByName(TEXT("buttonStopDump")))->SetVisible(BallastTimerActive);
    break;
  case DataField::daGet:
    lastRead = BALLAST;
    Sender->Set(BALLAST*100);
    break;
  case DataField::daChange:
  case DataField::daPut:
    if (fabs(lastRead-Sender->GetAsFloat()/100.0) >= 0.005){
      lastRead = CheckSetBallast(Sender->GetAsFloat()/100.0);
      SetBallast(true);
    }
    break;
  case DataField::daInc:
  case DataField::daDec:
    break;
  }
}
Esempio n. 2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// Parses LXWP2 sentence.
///
/// @param d         device descriptor
/// @param sentence  received NMEA sentence
/// @param info      GPS info to be updated
///
/// @retval true if the sentence has been parsed
///
//static
bool DevLXV7_EXP::LXWP2(PDeviceDescriptor_t, const TCHAR* sentence, NMEA_INFO*)
{
  // $LXWP2,mccready,ballast,bugs,polar_a,polar_b,polar_c, audio volume
  //   *CS<CR><LF>
  //
  // Mccready: float in m/s
  // Ballast: float 1.0 ... 1.5
  // Bugs: 0 - 100%
  // polar_a: float polar_a=a/10000 w=a*v2+b*v+c
  // polar_b: float polar_b=b/100 v=(km/h/100) w=(m/s)
  // polar_c: float polar_c=c
  // audio volume 0 - 100%
//float fBallast,fBugs, polar_a, polar_b, polar_c, fVolume;


double fTmp;
int iTmp;
if(LXV7_EXP_MacCreadyUpdateTimeout > 0)
{
	LXV7_EXP_MacCreadyUpdateTimeout--;
}
else
  if (ParToDouble(sentence, 0, &fTmp))
  {
	iTmp =(int) (fTmp*100.0+0.5f);
	fTmp = (double)(iTmp)/100.0;
	LXV7_EXP_bValid = true;
	if(fabs(MACCREADY - fTmp)> 0.001)
	{
	  CheckSetMACCREADY(fTmp);
	  iLXV7_EXP_RxUpdateTime =5;
	}
  }


if(LXV7_EXP_BallastUpdateTimeout > 0)
{
	LXV7_EXP_BallastUpdateTimeout--;
}
else
  if (ParToDouble(sentence, 1, &fTmp))
  {
	fTmp -= 1.0;
	if(  fabs(fTmp -BALLAST) >= 0.05)
    {
      CheckSetBallast(fTmp);
      iLXV7_EXP_RxUpdateTime = 5;
    }
  }

if(LXV7_EXP_BugsUpdateTimeout > 0)
{
  LXV7_EXP_BugsUpdateTimeout--;
}
else
  if(ParToDouble(sentence, 2, &fTmp))
  {
	int iTmp2 = 100-(int)(fTmp+0.5);
	fTmp =  (double)iTmp2/100.0;
	if(  fabs(fTmp -BUGS) >= 0.03)
    {
      CheckSetBugs(fTmp);
      iLXV7_EXP_RxUpdateTime = 5;
    }
  }
/*
  if (ParToDouble(sentence, 3, &fTmp))
    fPolar_a = fTmp;
  if (ParToDouble(sentence, 4, &fTmp))
    fPolar_b = fTmp;
  if (ParToDouble(sentence, 5, &fTmp))
    fPolar_c = fTmp;
  if (ParToDouble(sentence, 6, &fTmp))
  {
    fVolume = fTmp;
  }
*/
  return(true);
} // LXWP2()
Esempio n. 3
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// Parses LXWP2 sentence.
///
/// @param d         device descriptor
/// @param sentence  received NMEA sentence
/// @param info      GPS info to be updated
///
/// @retval true if the sentence has been parsed
///
//static
bool DevLX16xx::LXWP2(PDeviceDescriptor_t, const TCHAR* sentence, NMEA_INFO*)
{
  // $LXWP2,mccready,ballast,bugs,polar_a,polar_b,polar_c, audio volume
  //   *CS<CR><LF>
  //
  // Mccready: float in m/s
  // Ballast: float 1.0 ... 1.5
  // Bugs: 0 - 100%
  // polar_a: float polar_a=a/10000 w=a*v2+b*v+c
  // polar_b: float polar_b=b/100 v=(km/h/100) w=(m/s)
  // polar_c: float polar_c=c
  // audio volume 0 - 100%
//float fBallast,fBugs, polar_a, polar_b, polar_c, fVolume;


double fTmp;
int iTmp;
if(MacCreadyUpdateTimeout > 0)
{
	MacCreadyUpdateTimeout--;
}
else
  if (ParToDouble(sentence, 0, &fTmp))
  {
	iTmp =(int) (fTmp*100.0+0.5f);
	fTmp = (double)(iTmp)/100.0;
	bValid = true;
	if(fabs(MACCREADY - fTmp)> 0.001)
	{
	  CheckSetMACCREADY(fTmp);
	  iLX16xx_RxUpdateTime =5;
	}
  }


if(BallastUpdateTimeout > 0)
{
  BallastUpdateTimeout--;
}
else
  if (ParToDouble(sentence, 1, &fTmp))
  {
    double newBallast = CalculateBalastFromLX(fTmp);
    if(fabs(newBallast- BALLAST) > 0.01 )
    {
      CheckSetBallast(newBallast);
      iLX16xx_RxUpdateTime = 5;
    }
  }

if(BugsUpdateTimeout > 0)
{
  BugsUpdateTimeout--;
}
else {
  if(ParToDouble(sentence, 2, &fTmp))
  {
    double newBug = CalculateBugsFromLX(fTmp);
	if(  fabs(newBug -BUGS) >= 0.03)
    {
      CheckSetBugs(newBug);
      iLX16xx_RxUpdateTime = 5;
    }
  }
}
  if (ParToDouble(sentence, 3, &fTmp))
    fPolar_a = fTmp;
  if (ParToDouble(sentence, 4, &fTmp))
    fPolar_b = fTmp;
  if (ParToDouble(sentence, 5, &fTmp))
    fPolar_c = fTmp;
  if (ParToDouble(sentence, 6, &fTmp))
  {
    fVolume = fTmp;
  }
  return(true);
} // LXWP2()
Esempio n. 4
0
bool DevLXMiniMap::LXWP2(PDeviceDescriptor_t, const TCHAR* sentence, NMEA_INFO* info)
{
  // $LXWP2,mccready,ballast,bugs,polar_a,polar_b,polar_c, audio volume
  //   *CS<CR><LF>
  //
  // Mccready: float in m/s
  // Ballast: float 1.0 ... 1.5
  // Bugs: 0 - 100%
  // polar_a: float polar_a=a/10000 w=a*v2+b*v+c
  // polar_b: float polar_b=b/100 v=(km/h/100) w=(m/s)
  // polar_c: float polar_c=c
  // audio volume 0 - 100%

	if(McReadyTimeout>0)
	{
		McReadyTimeout--;
	}
	else
	{
		ParToDouble(sentence, 0, &info->MacReady);
		CheckSetMACCREADY(info->MacReady);
	}

	if(BallastTimeout>0)
	{
		BallastTimeout--;
	}
	else
	{
		double tempBallastFactor;

		ParToDouble(sentence, 1, &tempBallastFactor);

		double newBallast = CalculateBalast(tempBallastFactor);

		if(fabs(newBallast- BALLAST) > 0.01 )
		{
			CheckSetBallast(newBallast);
		}

	}


	if(BugsTimeout>0)
	{
		BugsTimeout--;
	}
	else
	{

		double tempBugs;
		ParToDouble(sentence, 2, &tempBugs);

		tempBugs = (100.0 - tempBugs)/100;

		if(fabs(tempBugs -BUGS) > 0.01)
		{
			CheckSetBugs(tempBugs);
		}

	}



  return(true);
} // LXWP2()