ekmmeters.py
def calculateFields(self):
        """Write calculated fields for read buffer."""
        pf1 = self.m_blk_b[Field.Cos_Theta_Ln_1][MeterData.StringValue]
        pf2 = self.m_blk_b[Field.Cos_Theta_Ln_2][MeterData.StringValue]
        pf3 = self.m_blk_b[Field.Cos_Theta_Ln_3][MeterData.StringValue]

        pf1_int = self.calcPF(pf1)
        pf2_int = self.calcPF(pf2)
        pf3_int = self.calcPF(pf3)

        self.m_blk_b[Field.Power_Factor_Ln_1][MeterData.StringValue] = str(pf1_int)
        self.m_blk_b[Field.Power_Factor_Ln_2][MeterData.StringValue] = str(pf2_int)
        self.m_blk_b[Field.Power_Factor_Ln_3][MeterData.StringValue] = str(pf3_int)

        self.m_blk_b[Field.Power_Factor_Ln_1][MeterData.NativeValue] = pf1_int
        self.m_blk_b[Field.Power_Factor_Ln_2][MeterData.NativeValue] = pf2_int
        self.m_blk_b[Field.Power_Factor_Ln_3][MeterData.NativeValue] = pf2_int

        rms_watts_1 = self.m_blk_b[Field.RMS_Watts_Ln_1][MeterData.NativeValue]
        rms_watts_2 = self.m_blk_b[Field.RMS_Watts_Ln_2][MeterData.NativeValue]
        rms_watts_3 = self.m_blk_b[Field.RMS_Watts_Ln_3][MeterData.NativeValue]

        sign_rms_watts_1 = 1
        sign_rms_watts_2 = 1
        sign_rms_watts_3 = 1

        direction_byte = self.m_blk_a[Field.State_Watts_Dir][MeterData.NativeValue]

        if direction_byte == DirectionFlag.ForwardForwardForward:
            # all good
            pass
        if direction_byte == DirectionFlag.ForwardForwardReverse:
            sign_rms_watts_3 = -1
            pass
        if direction_byte == DirectionFlag.ForwardReverseForward:
            sign_rms_watts_2 = -1
            pass
        if direction_byte == DirectionFlag.ReverseForwardForward:
            sign_rms_watts_1 = -1
            pass
        if direction_byte == DirectionFlag.ForwardReverseReverse:
            sign_rms_watts_2 = -1
            sign_rms_watts_3 = -1
            pass
        if direction_byte == DirectionFlag.ReverseForwardReverse:
            sign_rms_watts_1 = -1
            sign_rms_watts_3 = -1
            pass
        if direction_byte == DirectionFlag.ReverseReverseForward:
            sign_rms_watts_1 = -1
            sign_rms_watts_2 = -1
            pass
        if direction_byte == DirectionFlag.ReverseReverseReverse:
            sign_rms_watts_1 = -1
            sign_rms_watts_2 = -1
            sign_rms_watts_3 = -1
            pass

        net_watts_1 = rms_watts_1 * sign_rms_watts_1
        net_watts_2 = rms_watts_2 * sign_rms_watts_2
        net_watts_3 = rms_watts_3 * sign_rms_watts_3
        net_watts_tot = net_watts_1 + net_watts_2 + net_watts_3

        self.m_blk_b[Field.Net_Calc_Watts_Ln_1][MeterData.NativeValue] = net_watts_1
        self.m_blk_b[Field.Net_Calc_Watts_Ln_2][MeterData.NativeValue] = net_watts_2
        self.m_blk_b[Field.Net_Calc_Watts_Ln_3][MeterData.NativeValue] = net_watts_3
        self.m_blk_b[Field.Net_Calc_Watts_Tot][MeterData.NativeValue] = net_watts_tot

        self.m_blk_b[Field.Net_Calc_Watts_Ln_1][MeterData.StringValue] = str(net_watts_1)
        self.m_blk_b[Field.Net_Calc_Watts_Ln_2][MeterData.StringValue] = str(net_watts_2)
        self.m_blk_b[Field.Net_Calc_Watts_Ln_3][MeterData.StringValue] = str(net_watts_3)
        self.m_blk_b[Field.Net_Calc_Watts_Tot][MeterData.StringValue] = str(net_watts_tot)

        pass
def calculateFields(self):
        """Write calculated fields for read buffer."""
        pf1 = self.m_blk_b[Field.Cos_Theta_Ln_1][MeterData.StringValue]
        pf2 = self.m_blk_b[Field.Cos_Theta_Ln_2][MeterData.StringValue]
        pf3 = self.m_blk_b[Field.Cos_Theta_Ln_3][MeterData.StringValue]

        pf1_int = self.calcPF(pf1)
        pf2_int = self.calcPF(pf2)
        pf3_int = self.calcPF(pf3)

        self.m_blk_b[Field.Power_Factor_Ln_1][MeterData.StringValue] = str(pf1_int)
        self.m_blk_b[Field.Power_Factor_Ln_2][MeterData.StringValue] = str(pf2_int)
        self.m_blk_b[Field.Power_Factor_Ln_3][MeterData.StringValue] = str(pf3_int)

        self.m_blk_b[Field.Power_Factor_Ln_1][MeterData.NativeValue] = pf1_int
        self.m_blk_b[Field.Power_Factor_Ln_2][MeterData.NativeValue] = pf2_int
        self.m_blk_b[Field.Power_Factor_Ln_3][MeterData.NativeValue] = pf2_int

        rms_watts_1 = self.m_blk_b[Field.RMS_Watts_Ln_1][MeterData.NativeValue]
        rms_watts_2 = self.m_blk_b[Field.RMS_Watts_Ln_2][MeterData.NativeValue]
        rms_watts_3 = self.m_blk_b[Field.RMS_Watts_Ln_3][MeterData.NativeValue]

        sign_rms_watts_1 = 1
        sign_rms_watts_2 = 1
        sign_rms_watts_3 = 1

        direction_byte = self.m_blk_a[Field.State_Watts_Dir][MeterData.NativeValue]

        if direction_byte == DirectionFlag.ForwardForwardForward:
            # all good
            pass
        if direction_byte == DirectionFlag.ForwardForwardReverse:
            sign_rms_watts_3 = -1
            pass
        if direction_byte == DirectionFlag.ForwardReverseForward:
            sign_rms_watts_2 = -1
            pass
        if direction_byte == DirectionFlag.ReverseForwardForward:
            sign_rms_watts_1 = -1
            pass
        if direction_byte == DirectionFlag.ForwardReverseReverse:
            sign_rms_watts_2 = -1
            sign_rms_watts_3 = -1
            pass
        if direction_byte == DirectionFlag.ReverseForwardReverse:
            sign_rms_watts_1 = -1
            sign_rms_watts_3 = -1
            pass
        if direction_byte == DirectionFlag.ReverseReverseForward:
            sign_rms_watts_1 = -1
            sign_rms_watts_2 = -1
            pass
        if direction_byte == DirectionFlag.ReverseReverseReverse:
            sign_rms_watts_1 = -1
            sign_rms_watts_2 = -1
            sign_rms_watts_3 = -1
            pass

        net_watts_1 = rms_watts_1 * sign_rms_watts_1
        net_watts_2 = rms_watts_2 * sign_rms_watts_2
        net_watts_3 = rms_watts_3 * sign_rms_watts_3
        net_watts_tot = net_watts_1 + net_watts_2 + net_watts_3

        self.m_blk_b[Field.Net_Calc_Watts_Ln_1][MeterData.NativeValue] = net_watts_1
        self.m_blk_b[Field.Net_Calc_Watts_Ln_2][MeterData.NativeValue] = net_watts_2
        self.m_blk_b[Field.Net_Calc_Watts_Ln_3][MeterData.NativeValue] = net_watts_3
        self.m_blk_b[Field.Net_Calc_Watts_Tot][MeterData.NativeValue] = net_watts_tot

        self.m_blk_b[Field.Net_Calc_Watts_Ln_1][MeterData.StringValue] = str(net_watts_1)
        self.m_blk_b[Field.Net_Calc_Watts_Ln_2][MeterData.StringValue] = str(net_watts_2)
        self.m_blk_b[Field.Net_Calc_Watts_Ln_3][MeterData.StringValue] = str(net_watts_3)
        self.m_blk_b[Field.Net_Calc_Watts_Tot][MeterData.StringValue] = str(net_watts_tot)

        pass
Write calculated fields for read buffer.