Esempio n. 1
0
    def _read_load(self, data, n):
        """
        (4551, 61, 84) - the marker for Record 8
        .. todo:: add object
        """
        ntotal = 16  # 4*4
        nentries = (len(data) - n) // ntotal
        count = 0
        struct_i2fi = Struct('iffi')
        struct_fi = Struct('fi')
        while (len(data) - n) >= 16:
            edata = data[n:n+16]
            n += 16
            out = struct_i2fi.unpack(edata)
            (sid, s, si, l1) = out
            if self.is_debug_file:
                self.binary_debug.write('  LOAD=%s\n' % str(out))
            Si = [si]
            L1 = [l1]
            #print(Si, L1)
            while 1:
                edata = data[n:n+8]
                n += 8
                (si, l1) = struct_fi.unpack(edata)
                siTest, = self.struct_i.unpack(edata[0:4])
                #print(si,siTest, l1)
                #print(type(si))

                if [siTest, l1] == [-1, -1]:
                    break
                Si.append(si)
                L1.append(l1)
                if self.is_debug_file:
                    self.binary_debug.write('       [%s,%s]\n' % (si, l1))
                #print(Si, L1)

            data_in = [sid, s, Si, L1]
            load = LOAD(sid, s, Si, L1)
            self._add_load_combination_object(load)
            count += 1
            if count > 1000:
                raise RuntimeError('Iteration limit...probably have a bug.')
        self.card_count['LOAD'] = nentries
        return n
Esempio n. 2
0
    def _read_load(self, data: bytes, n: int) -> int:
        """
        (4551, 61, 84) - the marker for Record 8
        .. todo:: add object
        """
        ntotal = 16 * self.factor  # 4*4
        ntotal2 = 8 * self.factor
        #nentries = (len(data) - n) // ntotal
        #count = 0
        struct_i2fi = Struct(mapfmt(self._endian + b'iffi', self.size))
        struct_fi = Struct(mapfmt(self._endian + b'fi', self.size))

        nentries_actual = 0
        while (len(data) - n) >= ntotal:
            edata = data[n:n + ntotal]
            n += ntotal
            out = struct_i2fi.unpack(edata)
            (sid, s, si, l1) = out
            if self.is_debug_file:
                self.binary_debug.write('  LOAD=%s\n' % str(out))
            Si = [si]
            L1 = [l1]
            while 1:
                edata = data[n:n + ntotal2]
                n += ntotal2
                (si, l1) = struct_fi.unpack(edata)
                si_test, = self.struct_i.unpack(edata[0:4])

                if [si_test, l1] == [-1, -1]:
                    break
                Si.append(si)
                L1.append(l1)
                if self.is_debug_file:
                    self.binary_debug.write('       [%s,%s]\n' % (si, l1))

            load = LOAD(sid, s, Si, L1)
            self._add_load_combination_object(load)
            nentries_actual += 1
            #count += 1
            #if count > 1000:
            #raise RuntimeError('Iteration limit...probably have a bug.')
        self.card_count['LOAD'] = nentries_actual
        return n