def __init__(self):

        # System parameters
        self.nb_MB = 3
        self.state_size = 2 * self.nb_MB
        self.nb_actions = (Mobile.MAX_DATA + 1) ** self.nb_MB * (Mobile.MAX_ENERGY + 1) ** self.nb_MB

        self.action_space = ActionSpace((Discrete(Mobile.MAX_DATA + 1), Discrete(Mobile.MAX_ENERGY + 1),
                                         Discrete(Mobile.MAX_DATA + 1), Discrete(Mobile.MAX_ENERGY + 1),
                                         Discrete(Mobile.MAX_DATA + 1), Discrete(Mobile.MAX_ENERGY + 1)
                                         ))

        self.observation_space = StateSpace((Discrete(Mobile.MAX_CPU), Discrete(Mobile.MAX_ENERGY),
                                             Discrete(Mobile.MAX_CPU), Discrete(Mobile.MAX_ENERGY),
                                             Discrete(Mobile.MAX_CPU), Discrete(Mobile.MAX_ENERGY)))

        # initialize Second Transmitters
        self.MB1 = Mobile()
        self.MB2 = Mobile()
        self.MB3 = Mobile()

        self.max_data = self.nb_MB * Mobile.MAX_DATA
        self.max_energy = self.nb_MB * Mobile.MAX_ENERGY
        self.max_latency = Mobile.MAX_LATENCY

        self.training_time = 0
        self.training_data = 0

        self.viewer = None
        self.state = None
        self.steps_beyond_done = None
예제 #2
0
    def __init__(self, config):
        self.config = config

        gps = GPS(config)
        measure = Measure()

        self.mobile = Mobile(gps, measure, config)

        self.step = config['step']
예제 #3
0
def modify():
    mod_no = input("Enter the model number:")
    mobile = get("MX" + mod_no)
    if mobile:
        data = {}
        data['name'] = input("Enter the model name :")
        data['price'] = int(input("Enter the price:"))
        data['year'] = input("Enter the Year:")
        data['sold'] = int(input("Enter the number of items sold:"))
        data['rating'] = float(input("Enter the rating:"))
        mob = Mobile(number=mod_no, **data)
        prev = []
        with open(FILE_NAME, "rb") as fp:
            prev = pickle.load(fp)
        for i in range(len(prev)):
            if prev[i].getNumber() == mob.getNumber():
                prev[i] = mob
        with open(FILE_NAME, "wb") as fp:
            pickle.dump(prev, fp)
        print("Successfully modified details of " + mob.getNumber())
    else:
        print("No mobile exists with the model number " + mod_no)
def addMobile():
    data = {}

    data['name'] = input("Enter the model name :")
    data['number'] = input("Enter the model number :")
    data['price'] = int(input("Enter the price:"))
    data['year'] = input("Enter the Year")
    data['sold'] = int(input("Enter the number of items sold:"))
    data['rating'] = float(input("Enter the rating"))
    mob = None
    try:
        mob = Mobile(**data)
    except (NameException, NumberException, NegativeException,
            YearException) as e:
        print(e.msg)
    else:
        try:
            mob.save()
        except MobileExists:
            print("Already an mobile exists with the model number " +
                  mob.getNumber())
        else:
            print("Mobile successfully created")
예제 #5
0
    # Continue receiving for 10 seconds
    rx.startListening()
    startTime = received = 0
    while time.monotonic() - startTime < endTime or startTime == 0:
        hasPayload, pipeNo = rx.available_pipe()
        if hasPayload:
            print("Receiving packages...")
            if startTime == 0: startTime = time.monotonic()
            received += 1
            buffer = rx.read(rx.payloadSize)
            mobile.payload[1] = struct.unpack("<f", buffer[:4])[0]
    endTime = time.monotonic()
    finalTime = endTime - startTime
    avg = (received * rx.payloadSize * 8) / finalTime

    print("Transmission time: {}\n"
          "Packages Received: {}\n"
          "Average bits per second (BPS): {}\n".format(finalTime, received,
                                                       avg))

    rx.stopListening()


if __name__ == '__main__':
    mobile = Mobile([RF24(17, 0), RF24(27, 10)])
    rx = mobile.radios[1]

    measure(mobile, rx)

    mobile.shutDown()
    sys.exit()
예제 #6
0
# importing entire module named person
import person

p1 = person.Person('person1', 45)
print(p1)

import car

c1 = car.Car('i20')
print(c1)

c2 = car.MyCar()
print(c2)

# from mobile module only Mobile class will get imported
# from mobile import Mobile
# from mobile import MyMobile
from mobile import Mobile, MyMobile

m1 = Mobile('Galaxy S10 plus')
print(m1)

m2 = MyMobile()
print(m2)