Beispiel #1
0
//-----------------------------------------------------------------------------
// 描述: 将字符串转换成 DateTime
// 注意: dateTimeStr 的格式必须为 YYYY-MM-DD HH:MM:SS
//-----------------------------------------------------------------------------
DateTime& DateTime::operator = (const std::string& dateTimeStr)
{
	int year, month, day, hour, minute, second;

	if (dateTimeStr.length() == 19)
	{
		year = strToInt(dateTimeStr.substr(0, 4), 0);
		month = strToInt(dateTimeStr.substr(5, 2), 0);
		day = strToInt(dateTimeStr.substr(8, 2), 0);
		hour = strToInt(dateTimeStr.substr(11, 2), 0);
		minute = strToInt(dateTimeStr.substr(14, 2), 0);
		second = strToInt(dateTimeStr.substr(17, 2), 0);

		encodeDateTime(year, month, day, hour, minute, second);
		return *this;
	}
	else
	{
		ThrowException(SEM_INVALID_DATETIME_STR);
		return *this;
	}
}
Beispiel #2
0
uint32_t TelemetrySimulator::GPSEmulator::getNextPacketData(uint32_t packetType)
{
  switch (packetType) {
  case GPS_LONG_LATI_FIRST_ID:
    sendLat = !sendLat;
    return sendLat ? encodeLatLon(lat, TRUE) : encodeLatLon(lon, FALSE);
    break;
  case GPS_TIME_DATE_FIRST_ID:
    sendDate = !sendDate;
    return sendDate ? encodeDateTime(dt.date().year() - 2000, dt.date().month(), dt.date().day(), true) : encodeDateTime(dt.time().hour(), dt.time().minute(), dt.time().second(), false);
    break;
  case GPS_ALT_FIRST_ID:
    return (uint32_t) (altitude * 100);
    break;
  case GPS_SPEED_FIRST_ID:
    return speedKNTS * 1000;
    break;
  case GPS_COURS_FIRST_ID:
    return course * 100;
    break;
  }
  return 0;
}