Пример #1
0
 def getProfileGenerics(self):
     #pylint: disable=broad-except,too-many-nested-blocks
     cells = []
     profileGenerics = self.client.objects.getObjects(
         ObjectType.PROFILE_GENERIC)
     for it in profileGenerics:
         self.writeTrace(
             "-------- Reading " + str(it.objectType) + " " + str(it.name) +
             " " + it.description, TraceLevel.INFO)
         entriesInUse = self.read(it, 7)
         entries = self.read(it, 8)
         self.writeTrace(
             "Entries: " + str(entriesInUse) + "/" + str(entries),
             TraceLevel.INFO)
         pg = it
         if entriesInUse == 0 or not pg.captureObjects:
             continue
         try:
             cells = self.readRowsByEntry(pg, 1, 1)
             if self.trace > TraceLevel.WARNING:
                 for rows in cells:
                     for cell in rows:
                         if isinstance(cell, bytearray):
                             self.writeTrace(
                                 GXByteBuffer.hex(cell) + " | ",
                                 TraceLevel.INFO)
                         else:
                             self.writeTrace(
                                 str(cell) + " | ", TraceLevel.INFO)
                     self.writeTrace("", TraceLevel.INFO)
         except Exception as ex:
             self.writeTrace("Error! Failed to read first row: " + str(ex),
                             TraceLevel.ERROR)
             if not isinstance(ex, (GXDLMSException, TimeoutException)):
                 traceback.print_exc()
         try:
             start = datetime.datetime.now()
             end = start
             start.replace(hour=0, minute=0, second=0, microsecond=0)
             end.replace(minute=0, second=0, microsecond=0)
             cells = self.readRowsByRange(it, start, end)
             for rows in cells:
                 for cell in rows:
                     if isinstance(cell, bytearray):
                         print(GXByteBuffer.hexToBytes(cell) + " | ")
                     else:
                         self.writeTrace(str(cell) + " | ", TraceLevel.INFO)
                 self.writeTrace("", TraceLevel.INFO)
         except Exception as ex:
             self.writeTrace("Error! Failed to read last day: " + str(ex),
                             TraceLevel.ERROR)
Пример #2
0
 def getProfileGenerics(self):
     cells = []
     profileGenerics = self.client.objects.getObjects(
         ObjectType.PROFILE_GENERIC)
     for it in profileGenerics:
         self.writeTrace(
             "-------- Reading " + str(it.objectType) + " " + str(it.name) +
             " " + it.description, TraceLevel.INFO)
         entriesInUse = self.read(it, 7)
         entries = self.read(it, 8)
         self.writeTrace(
             "Entries: " + str(entriesInUse) + "/" + str(entries),
             TraceLevel.INFO)
         pg = it
         if entriesInUse == 0 or len(pg.captureObjects) == 0:
             continue
         try:
             cells = self.readRowsByEntry(pg, 1, 1)
             if self.Trace.value > TraceLevel.WARNING.value:
                 for rows in cells:
                     for cell in rows:
                         if isinstance(cell, bytearray):
                             self.writeTrace(
                                 GXByteBuffer.hex(cell) + " | ",
                                 TraceLevel.INFO)
                         else:
                             self.writeTrace(
                                 str(cell) + " | ", TraceLevel.INFO)
                     self.writeTrace("", TraceLevel.INFO)
         except Exception as ex:
             self.writeTrace(
                 "Error! Failed to read first row: " + ex.getMessage(),
                 TraceLevel.ERROR)
         try:
             start = datetime.datetime.now()
             end = start
             start.replace(hour=0, minute=0, second=0, microsecond=0)
             end.replace(minute=0, second=0, microsecond=0)
             cells = self.readRowsByRange(it, start, end)
             for rows in cells:
                 for cell in rows:
                     if isinstance(cell, bytearray):
                         print(GXByteBuffer.hexToBytes(cell) + " | ")
                     else:
                         self.writeTrace(str(cell) + " | ", TraceLevel.INFO)
                 self.writeTrace("", TraceLevel.INFO)
         except Exception as ex:
             self.writeTrace(
                 "Error! Failed to read last day: " + ex.getMessage(),
                 TraceLevel.ERROR)