예제 #1
0
    def sendData(self):

        factoryId = 'factory-{0}'.format(random.randint(0, 999))

        t = Telemetry()
        t.voltage = random.uniform(10, 100)
        t.amperage = random.uniform(10, 100)
        t.ambient_temp = random.uniform(10, 100)
        t.ambient_humidity = random.uniform(10, 100)
        t.flux_capacitance = random.uniform(10, 100)
        t.time_stamp = datetime.datetime.utcnow()

        w = Widget()
        w.serial_number = uuid.uuid4().hex
        w.factory_id = factoryId
        w.line_id = random.choice(["L1", "L2", "L3"])
        w.telemetry = [t]
        w_json = w.to_json()

        headers = dict(self.headers)
        brokerProperties = {'PartitionKey': factoryId}
        headers["BrokerProperties"] = json.dumps(brokerProperties)
        self.client.post(self.endpoint,
                         data=w_json,
                         verify=False,
                         headers=headers)
def generate_widget() -> Widget:
    w = Widget()
    w.serial_number = "devserial1"
    w.factory_id = "kitty hawk"
    w.line_id = "1"
    w.telemetry = [generate_telemetry() for i in range(0, 202)]
    return w
예제 #3
0
def generate_widget() -> Widget:
    w = Widget()
    w.serial_number = "devserial1"
    w.factory_id = "kitty hawk"
    w.line_id = "1"
    w.classification = generate_classification()
    return w
def generate_widget(is_anomaly=False) -> Widget:
    w = Widget()
    w.serial_number = str(uuid.uuid4())
    factories = ["kitty hawk", "nags head", "seattle", "miami"]
    w.factory_id = random.choice(factories)
    line_ids = ["1", "2", "3"]
    w.line_id = random.choice(line_ids)
    w.telemetry = generate_telemetry_list(10, is_anomaly=is_anomaly)
    w.classification = generate_classification()
    return w
예제 #5
0
def widget_from_row(row) -> Widget:
    w_class = Widget_Classification()
    w_class.classified_time = row.classified_time
    w_class.threshold = row.threshold
    w_class.mean = row.mean
    w_class.std = row.std
    w_class.std_dist = row.std_dist

    wid = Widget()
    wid.classification = w_class
    wid.serial_number = row.serial_number
    wid.line_id = row.line_id
    wid.factory_id = row.factory_id
    return wid