Ejemplo n.º 1
0
    def load_config(self):

        # Load all the configuration
        config = Config(self.logger)
        self.config = config.data
        self.nodes = self.config["Nodes"]
        return
Ejemplo n.º 2
0
async def run():
    url = "opc.tcp://localhost:4840/Larouex-Industrial-Manufacturing/Server"

    map_telemetry_file = MapTelemetry(Log)
    map_telemetry_file.load_file()
    map_telemetry_data = map_telemetry_file.data

    config_file = Config(Log)
    config_file_data = config_file.data

    async with Client(url=url) as client:
        idx = await client.get_namespace_index(map_telemetry_data["NameSpace"])
        print(idx)

        while True:
            await asyncio.sleep(config_file_data["ClientFrequencyInSeconds"])

            for node in map_telemetry_data["Nodes"]:
                print(node["Name"])
                for variable in node["Variables"]:
                    print(variable["DisplayName"])
                    print(variable["TelemetryName"])
                    read_node = client.get_node(variable["NodeId"])
                    val = await read_node.get_value()
                    print(val)
Ejemplo n.º 3
0
 def __init__(self):
     self.config = Config.load_config_file()
     if self.config['lastUpdate'] == 'None':
         update_time = date_lib.now().timestamp() - float(
             self.config['periodInSec'])
         self.config['lastUpdate'] = date_lib.fromtimestamp(
             update_time).strftime(self.datetime_format)
Ejemplo n.º 4
0
    def load_config(self):
      
      # Load all the configuration
      config = Config(self.logger)
      self.config = config.data
      self.nodes = self.config["Nodes"]
      
      # These counters support looping through our bounded telemetry values
      for node in self.nodes:
        variable_dict = {}
        variable_dict_counter = {}
        for variable in node["Variables"]:
          variable_dict[variable["TelemetryName"]] = len(variable["RangeValues"])
          variable_dict_counter[variable["TelemetryName"]] = 0

        self.nodes_dict[node["Name"]] = copy.deepcopy(variable_dict)
        self.nodes_dict_counter[node["Name"]] = copy.copy(variable_dict_counter)
        log_msg = "[LOOP DICTIONARY] NAME: {n} COUNTER: {c}"
        self.logger.info(log_msg.format(n = self.nodes_dict[node["Name"]], c = self.nodes_dict_counter[node["Name"]]))
      
      self.logger.info("[NODES_DICT] %s" % self.nodes_dict)
      self.logger.info("[NODES_DICT_COUNTER] %s" % self.nodes_dict_counter)
Ejemplo n.º 5
0
    def load_config(self):

        config = Config(self.logger)
        self.config = config.data
        return
Ejemplo n.º 6
0
from Classes.api import Api
from Classes.config import Config
from Classes.dataframe import Dataframe
from datetime import datetime
import time

if __name__ == "__main__":
    while True:
        apiClass = Api()
        i = 0
        mechine = ["st3", "st7"]
        len_mechine = len(mechine)
        for i in range(len_mechine):
            nodes_array = apiClass.get_data(mechine[i], i, len_mechine - 1)
            config = Config.load_config_file()
            data = Dataframe.transform_nodes_to_csv(nodes_array)
            print("!!!!!!!!!!!!!!!time runing: ")
            print(i + 1)
            if data.all:
                data.to_csv(config['dataFolderPath'] + '//data-' +
                            str(datetime.now().timestamp()) + '.csv',
                            index=True)
                print("done")
        time.sleep(300)