bool ioptronHC8406::updateTime(ln_date *utc, double utc_offset) { struct ln_zonedate ltm; if (isSimulation()) return true; ln_date_to_zonedate(utc, <m, utc_offset * 3600.0); JD = ln_get_julian_day(utc); DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %.2f", JD); // Set Local Time if (setLocalTime(PortFD, ltm.hours, ltm.minutes, ltm.seconds) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time."); return false; } if (setCalenderDate(PortFD, ltm.days, ltm.months, ltm.years) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting local date."); return false; } if (setioptronHC8406UTCOffset(utc_offset) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset."); return false; } return true; }
char *CreateMissionStatusJson(int distance) { cJSON *root = NULL; char *out = NULL; root = cJSON_CreateObject(); cJSON_AddStringToObject(root, "Type", "MissionStatusUpload"); cJSON_AddStringToObject(root, "CmdID", getCommandID()); cJSON_AddStringToObject(root, "Time", setLocalTime()); cJSON_AddStringToObject(root, "Broadcast", NONE); cJSON_AddStringToObject(root, "NeedAnswer", NO); cJSON_AddNumberToObject(root, "TeamID", status.TeamID); cJSON_AddNumberToObject(root, "AgentID", status.AgentID); cJSON_AddNumberToObject(root, "AirToAir", status.Equipment.AirToAir); cJSON_AddNumberToObject(root, "AirToGround", status.Equipment.AirToGround); cJSON_AddNumberToObject(root, "SupplyLife", status.Equipment.SupplyLife); cJSON_AddNumberToObject(root, "Distance", distance); //pc可根据此参数是否为0和下边的isAttack来判断是否开始攻击。 cJSON_AddStringToObject(root, "IsAttack", mission.IsAttack); cJSON_AddStringToObject(root, "Mission", status.TeamMission); cJSON_AddStringToObject(root, "TeamShape", status.TeamShape); out = cJSON_PrintUnformatted(root); cJSON_Delete(root); sResOutput("->->->StatusBuffer : ",out); return out; }
//After finish called , remember free memery char *CreateMultiplexJson(char *Type, char *cmdid) { cJSON *root = NULL; char *out = NULL; root = cJSON_CreateObject(); cJSON_AddStringToObject(root, "Type", Type); cJSON_AddStringToObject(root, "CmdID", cmdid); cJSON_AddStringToObject(root, "Time", setLocalTime()); cJSON_AddStringToObject(root, "Broadcast", NONE); cJSON_AddStringToObject(root, "NeedAnswer", NO); cJSON_AddNumberToObject(root, "TeamID", status.TeamID); cJSON_AddNumberToObject(root, "AgentID", status.AgentID); cJSON_AddStringToObject(root, "Character", status.Character); cJSON_AddStringToObject(root, "TeamShape", status.TeamShape); cJSON_AddNumberToObject(root, "FuleStatus", status.Fule); cJSON_AddStringToObject(root, "AliveStatus", status.AliveStatus); out = cJSON_PrintUnformatted(root); cJSON_Delete(root); sNetOutput("->->->StatusBuffer : ",out); return out; }
bool LX200SS2000PC::updateTime(ln_date * utc, double utc_offset) { bool result = true; // This method is largely identical to the one in the LX200Generic class. // The difference is that it ensures that updates that require planetary // data to be recomputed by the SkySensor2000PC are only done when really // necessary because this takes quite some time. if (!isSimulation()) { result = false; struct ln_zonedate ltm; ln_date_to_zonedate(utc, <m, static_cast<long>(utc_offset*3600.0+0.5)); DEBUGF(INDI::Logger::DBG_DEBUG, "New zonetime is %04d-%02d-%02d %02d:%02d:%06.3f (offset=%ld)", ltm.years, ltm.months, ltm.days, ltm.hours, ltm.minutes, ltm.seconds, ltm.gmtoff); JD = ln_get_julian_day(utc); DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %f", JD); if (setLocalTime(PortFD, ltm.hours, ltm.minutes, static_cast<int>(ltm.seconds+0.5)) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time."); } else if (!setCalenderDate(ltm.years, ltm.months, ltm.days)) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting local date."); } // Meade defines UTC Offset as the offset ADDED to local time to yield UTC, which // is the opposite of the standard definition of UTC offset! else if (!setUTCOffset(-static_cast<int>(utc_offset))) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset."); } else { DEBUG(INDI::Logger::DBG_SESSION, "Time updated."); result = true; } } return result; }
void AudioENF::setDefaultHeader() { enfHeader.formatID = FourCC("ENF"); enfHeader.locationID.NationID = FourCC("NORW"); enfHeader.locationID.RegionID = FourCC("OSLO"); setLocalTime(); enfHeader.sampleRate = 1000; enfHeader.bitsperSample = 16; enfHeader.dataSize = 0; }
bool LX200GPS::updateTime(ln_date *utc, double utc_offset) { ln_zonedate ltm; if (isSimulation()) return true; JD = ln_get_julian_day(utc); DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %f", (float)JD); ln_date_to_zonedate(utc, <m, utc_offset * 3600); DEBUGF(INDI::Logger::DBG_DEBUG, "Local time is %02d:%02d:%02g", ltm.hours, ltm.minutes, ltm.seconds); // Set Local Time if (setLocalTime(PortFD, ltm.hours, ltm.minutes, ltm.seconds) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time time."); return false; } if (setCalenderDate(PortFD, utc->days, utc->months, utc->years) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC date."); return false; } // Meade defines UTC Offset as the offset ADDED to local time to yield UTC, which // is the opposite of the standard definition of UTC offset! if (setUTCOffset(PortFD, (utc_offset * -1.0)) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset."); return false; } DEBUG(INDI::Logger::DBG_SESSION, "Time updated, updating planetary data..."); return true; }