예제 #1
0
def readCSV(filename):
    netLog.speedLog("readCSV")
    list = {}
    count = 0
    try:
        file1 = open(filename, 'r')
        line1 = file1.readline()
        line1 = line1.replace("\"", "")
        headers = line1.split(";")

        for h in headers:
            list[h] = []

        print(headers)
        #print(list)
        while True:
            count += 1
            # Get next line from file
            line = file1.readline()
            line.replace("\n", "")
            # if line is empty
            # end of file is reached
            if not line:
                break
            #print("Line{}: {}".format(count, line.strip()))
            data = line.split(";")
            i = 0
            for d in data:
                try:
                    list[headers[i]].append(float(d))
                except ValueError:
                    list[headers[i]].append(float(0))
                i = i + 1
        file1.close()
        print("close")
    except Exception as err:
        print(err)
        print(count)
        exception_type = type(err).__name__
        print(exception_type)
        print(traceback.format_exc())
    netLog.speedLog("readCSV klart")

    return list, headers
예제 #2
0
    def run(self):
        netLog.speedLog("started udpThread")

        #print(array)
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.settimeout(1.0)
        s.bind(('', self.localPort))

        clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.counter = 0

        now = datetime.now()

        current_time = now.strftime("%Y-%m-%d_%H%M%S")

        filename = "output" + current_time + ".csv"
        print("creating file :", filename)
        outfile = open(filename, "w")
        for key, item in dataDict.items():
            outfile.write("\"" + key + "\"" + ";")
        outfile.write("\n")

        while self.running:
            try:
                message, address = s.recvfrom(1024)
            except socket.timeout:
                print("no data")
                continue
            for key, item in dataDict.items():
                (value, ) = struct.unpack_from(item["type"],
                                               message,
                                               offset=item["offset"])
                item["value"] = value

            for key, item in dataDict.items():
                #print(key, item["value"] )
                outfile.write(str(item["value"]) + ";")
                continue
            outfile.write("\n")
            self.counter += 1
        outfile.close()
        clientSock.close()
        s.close()
        self.parent.wait = False
예제 #3
0
    def __init__(self):
        super(Graph,self).__init__()
        netLog.speedLog("Graph init")
        self.axisItems = {'bottom': pg.DateAxisItem()}
        self.plotList = {}
        self.placeList = []
        self.colorRotation = 0
        self.varList = []
        self.varList.append("status")
        self.varList.append("clock(1)")
        self.varList.append("clock(2)")
        self.varList.append("clock(3)")
        self.varList.append("clock(4)")
        self.themeBack = "k"
        self.themeFore = "w"
        self.firstPlot = None
        #dafo211kd411da1

        ip = os.environ.get('ICE_SERVER_IP', "localhost")
        port = os.environ.get('ICE_SERVER_PORT', 1431)
예제 #4
0
    def run(self):
        netLog.speedLog("started udpThread")

        #print(array)
        #s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        #s.settimeout(1.0)
        #s.bind(('', self.localPort))

        #clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.update = True
        self.counter = 110
        while self.running:
            if self.update:
                self.counter = 0
                self.update = False
                try:
                    clientSock.close()
                    s.close()
                except UnboundLocalError:
                    print("hej")
                s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                s.settimeout(1.0)
                s.bind(('', self.localPort))

                clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            try:
                message, address = s.recvfrom(1024)
                #print(data)
                self.counter = self.counter + 1
                for out in self.outputList:
                    if (out["check"]):
                        try:
                            clientSock.sendto(message,
                                              (out["ip"], int(out["port"])))
                        except socket.gaierror:
                            print("Can not connect to:", out["ip"])
                            continue

            except socket.timeout:
                print('no data')
예제 #5
0
#!/usr/bin/python3
import sys
import os

SRC_PATH = os.path.dirname(os.path.abspath(__file__))
sys.path.append(SRC_PATH + os.sep + '../common')
import netLog
from PyQt5 import QtWidgets, uic

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

netLog.speedLog("import klart qt")
import sys
import socket
import json
import os
import traceback
#from pathlib import Path
#from functools import partial
netLog.speedLog("import klart sys")
import pyqtgraph as pg

netLog.speedLog("import klart pyqtgraph")
#Egna saker
import graphWidget
import mapWidget

netLog.speedLog("import klart eget")
netLog.speedLog("import klart nl")
예제 #6
0
#!/usr/bin/python3
import sys
import os
SRC_PATH = os.path.dirname(os.path.abspath(__file__))
sys.path.append(SRC_PATH + os.sep + '../common')

import netLog
from PyQt5 import QtWidgets, uic

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
netLog.speedLog("import klart qt")

import socket
from pathlib import Path
import traceback
import json
#from pathlib import Path
#from functools import partial
netLog.speedLog("import klart sys")
#Egna saker

netLog.speedLog("import klart eget")
#netLog.speedLog("started")

SRC_PATH = os.path.dirname(os.path.abspath(__file__))

NR_OUTPUTS = 8

import time