def test_t1_lte_t2_string(self): """ t1_lte_t2_string test """ self.assertTrue(t1_lte_t2_string('2005-12-02T00:00:00.000','2021-12-01T00:00:00.000')) self.assertFalse(t1_lte_t2_string('2021-12-02T00:00:00.000','2021-12-01T00:55:00.555')) self.assertFalse(t1_lte_t2_string('2021-12-02T00:00:00.500','2019-12-01T12:00:00.000')) self.assertTrue(t1_lte_t2_string('2021-12-02T00:00:00.5','2035-12-01T12:00:00.000'))
def test_t1_lte_t2_string(self): """ t1_lte_t2_string tests """ self.assertFalse( orekit_utils.t1_lte_t2_string('2020-12-03T00:00:00.000', '2020-12-02T00:00:00.000')) self.assertTrue( orekit_utils.t1_lte_t2_string('2020-12-03T00:00:00.000', '2020-12-03T00:00:00.0'))
async def cubesat_state(message, nats_handler, shared_storage, logger): """ Update the state of a cubesat in the shared dictionary Args: message (natsmessage): message message.data dictionary with structure as described in message_structure.json message.data["state"] is a dictionary containing telematry data of a satellite nats_handler (natsHandler): distributes callbacks according to the message subject shared_storage: dictionary containing information on on the entire swarm, the time, and the particular satellites phonebook """ state = message.data["state"] target_sat_id = list(state.keys())[0] if orekit_utils.t1_lte_t2_string(shared_storage["swarm"][target_sat_id]["last_update_time"], state[target_sat_id]["last_update_time"]): shared_storage["swarm"][target_sat_id] = state[target_sat_id]
async def cubesat_X_attitude_provider(message, nats_handler, shared_storage, logger): """ Update the attitude law for a satellite (satellite ID given in the subject of the message) in the shared dictionary Args: message (natsmessage): message message.data dictionary with structure as described in message_structure.json message.data["data"]["attitude"] is a dictionary containing what the satellite will point at nats_handler (natsHandler): distributes callbacks according to the message subject shared_storage: dictionary containing information on on the entire swarm, the time, and the particular satellites phonebook """ attitude = message.data["attitude"] satellite_id = message.data["id"] new_time = message.data["time"] old_attitude_provider_time = shared_storage["swarm"][satellite_id]["last_update_time"] if orekit_utils.t1_lte_t2_string(old_attitude_provider_time, new_time): shared_storage["swarm"][satellite_id]["orbit"]["attitude"] = attitude