Example #1
0
 def test_latitude(self):
     self.assertEqual(util.latitude_to_ddm(0), "0000.00N")
     self.assertEqual(util.latitude_to_ddm(45), "4500.00N")
     self.assertEqual(util.latitude_to_ddm(90), "9000.00N")
     self.assertEqual(util.latitude_to_ddm(0.5), "0030.00N")
     self.assertEqual(util.latitude_to_ddm(0.55), "0033.00N")
     self.assertEqual(util.latitude_to_ddm(0.555), "0033.30N")
     self.assertEqual(util.latitude_to_ddm(0.5555), "0033.33N")
     self.assertEqual(util.latitude_to_ddm(0.9999), "0059.99N")
     self.assertEqual(util.latitude_to_ddm(0.99999), "0060.00N")
Example #2
0
 def test_latitude(self):
     self.assertEqual(util.latitude_to_ddm(0), "0000.00N")
     self.assertEqual(util.latitude_to_ddm(45), "4500.00N")
     self.assertEqual(util.latitude_to_ddm(90), "9000.00N")
     self.assertEqual(util.latitude_to_ddm(0.5), "0030.00N")
     self.assertEqual(util.latitude_to_ddm(0.55), "0033.00N")
     self.assertEqual(util.latitude_to_ddm(0.555), "0033.30N")
     self.assertEqual(util.latitude_to_ddm(0.5555), "0033.33N")
     self.assertEqual(util.latitude_to_ddm(0.9999), "0059.99N")
     self.assertEqual(util.latitude_to_ddm(0.99999), "0060.00N")
Example #3
0
 def test_latitude_negative(self):
     self.assertEqual(util.latitude_to_ddm(-45), "4500.00S")
     self.assertEqual(util.latitude_to_ddm(-90), "9000.00S")
     self.assertEqual(util.latitude_to_ddm(-0.5), "0030.00S")
     self.assertEqual(util.latitude_to_ddm(-0.55), "0033.00S")
     self.assertEqual(util.latitude_to_ddm(-0.555), "0033.30S")
     self.assertEqual(util.latitude_to_ddm(-0.5555), "0033.33S")
     self.assertEqual(util.latitude_to_ddm(-0.9999), "0059.99S")
     self.assertEqual(util.latitude_to_ddm(-0.99999), "0060.00S")
Example #4
0
 def test_latitude_negative(self):
     self.assertEqual(util.latitude_to_ddm(-45), "4500.00S")
     self.assertEqual(util.latitude_to_ddm(-90), "9000.00S")
     self.assertEqual(util.latitude_to_ddm(-0.5), "0030.00S")
     self.assertEqual(util.latitude_to_ddm(-0.55), "0033.00S")
     self.assertEqual(util.latitude_to_ddm(-0.555), "0033.30S")
     self.assertEqual(util.latitude_to_ddm(-0.5555), "0033.33S")
     self.assertEqual(util.latitude_to_ddm(-0.9999), "0059.99S")
     self.assertEqual(util.latitude_to_ddm(-0.99999), "0060.00S")
Example #5
0
    def _serialize_body(self):

        if self.timestamp is None:
            timestamp = ''
        elif isinstance(self.timestamp, str):
            timestamp = self.timestamp
        else:
            timestamp = datetime.utcfromtimestamp(self.timestamp).strftime("%d%H%M") + 'z'

        body = [
            '/' if self.timestamp else '!',  # packet type
            timestamp,
            latitude_to_ddm(self.latitude),
            self.symbol_table,
            longitude_to_ddm(self.longitude),
            self.symbol,
            comment_altitude(self.altitude) if self.altitude is not None else '',
            self.comment,
        ]

        return "".join(body)
Example #6
0
    def _serialize_body(self):

        if self.timestamp is None:
            timestamp = ''
        elif isinstance(self.timestamp, str):
            timestamp = self.timestamp
        else:
            timestamp = datetime.utcfromtimestamp(
                self.timestamp).strftime("%d%H%M") + 'z'

        body = [
            '/' if self.timestamp else '!',  # packet type
            timestamp,
            latitude_to_ddm(self.latitude),
            self.symbol_table,
            longitude_to_ddm(self.longitude),
            self.symbol,
            comment_altitude(self.altitude)
            if self.altitude is not None else '',
            self.comment,
        ]

        return "".join(body)
Example #7
0
def SendAPRS(tempCall, tempLat, tempLong, tempPayLoad):
    if tetraprs_useaprs != "True":
        return ()
    # create floats
    tempLat = float(tempLat)
    tempLong = float(tempLong)
    tempSymbol = GetAPRSSymbol(tempCall, 'CALL')
    tempPayLoad = tempPayLoad + GetAPRSText(tempCall, 'CALL')
    if tempCall != None and tempLat != 0 and tempLong != 0:
        # get timestamp for APRS
        timestamp = datetime.utcfromtimestamp(
            time.time()).strftime("%d%H%M") + 'z'
        APRSString = tempCall + '>APRS,TCPIP*:@' + timestamp + latitude_to_ddm(
            tempLat) + tempSymbol[0] + longitude_to_ddm(
                tempLong) + tempSymbol[1] + tempPayLoad
        aprs_logger.info(APRSString)
        try:
            AIS.connect()
            AIS.sendall(APRSString)
            logger.debug('SendAPRS - APRS string sent - ' + APRSString)
            return ()
        except:
            logger.error('SendAPRS - Failed to send APRS string')
            return ()
Example #8
0
    phg = encodePHG(float(mytx['power']),
                    float(mytx['antennaAboveGroundLevel']),
                    float(mytx['antennaGainDbi']), direction)
    if active == '_':
        pgh = ''

    #put all variables in the correct order in a list
    body = [
        aprsissourcecallsign,
        '>APRS,TCPIP*:',
        ';',
        'PS-',
        callsign,
        active,
        timestamp,
        latitude_to_ddm(latitude),
        symbol_table,
        longitude_to_ddm(longitude),
        symbol,
        phg,
        comment,
        timeSlots,
        status,
    ]

    #create the complete message string out of all components
    data = "".join(body)

    #transmitters with status ERROR are ignored
    if mytx['status'] != "ERROR":
        try: