// Get teh current to use in fault calculations for this cycle, based on the fault type. private static ComplexNumber GetDoubleEndedFaultCurrent(CycleData cycle, FaultType faultType) { ComplexNumber[] sequenceComponents; sequenceComponents = CycleData.CalculateSequenceComponents(cycle.AN.I, cycle.BN.I, cycle.CN.I); if (faultType == FaultType.ABC) { return(sequenceComponents[1]); } return(sequenceComponents[2]); }
private void InsertCycleData(FaultLocationDataSet faultDataSet, SqlCommand command, int lineDisturbanceID, int cycleIndex) { int cycleID; CycleData cycle; ComplexNumber[] sequenceVoltages; ComplexNumber[] sequenceCurrents; // Get the cycle data and sequence // components from the fault data set cycle = faultDataSet.Cycles[cycleIndex]; sequenceVoltages = CycleData.CalculateSequenceComponents(cycle.AN.V, cycle.BN.V, cycle.CN.V); sequenceCurrents = CycleData.CalculateSequenceComponents(cycle.AN.I, cycle.BN.I, cycle.CN.I); // Insert the cycle data into the database command.CommandText = "INSERT INTO Cycle (LineDisturbanceID, TimeStart, CycleIndex," + "ANVoltagePeak, ANVoltageRMS, ANVoltagePhase, ANCurrentPeak, ANCurrentRMS, ANCurrentPhase, " + "BNVoltagePeak, BNVoltageRMS, BNVoltagePhase, BNCurrentPeak, BNCurrentRMS, BNCurrentPhase, " + "CNVoltagePeak, CNVoltageRMS, CNVoltagePhase, CNCurrentPeak, CNCurrentRMS, CNCurrentPhase, " + "PositiveVoltageMagnitude, PositiveVoltageAngle, PositiveCurrentMagnitude, PositiveCurrentAngle, " + "NegativeVoltageMagnitude, NegativeVoltageAngle, NegativeCurrentMagnitude, NegativeCurrentAngle, " + "ZeroVoltageMagnitude, ZeroVoltageAngle, ZeroCurrentMagnitude, ZeroCurrentAngle) " + "VALUES (@lineDisturbanceID, @timeStart, @cycleIndex, " + "@anVoltagePeak, @anVoltageRMS, @anVoltagePhase, @anCurrentPeak, @anCurrentRMS, @anCurrentPhase, " + "@bnVoltagePeak, @bnVoltageRMS, @bnVoltagePhase, @bnCurrentPeak, @bnCurrentRMS, @bnCurrentPhase, " + "@cnVoltagePeak, @cnVoltageRMS, @cnVoltagePhase, @cnCurrentPeak, @cnCurrentRMS, @cnCurrentPhase, " + "@positiveVoltageMagnitude, @positiveVoltageAngle, @positiveCurrentMagnitude, @positiveCurrentAngle, " + "@negativeVoltageMagnitude, @negativeVoltageAngle, @negativeCurrentMagnitude, @negativeCurrentAngle, " + "@zeroVoltageMagnitude, @zeroVoltageAngle, @zeroCurrentMagnitude, @zeroCurrentAngle)"; command.Parameters.AddWithValue("@lineDisturbanceID", lineDisturbanceID); command.Parameters.AddWithValue("@timeStart", cycle.StartTime); command.Parameters.AddWithValue("@cycleIndex", cycleIndex); command.Parameters.AddWithValue("@anVoltagePeak", cycle.AN.V.Peak); command.Parameters.AddWithValue("@anVoltageRMS", cycle.AN.V.RMS); command.Parameters.AddWithValue("@anVoltagePhase", cycle.AN.V.Phase.ToDegrees()); command.Parameters.AddWithValue("@anCurrentPeak", cycle.AN.I.Peak); command.Parameters.AddWithValue("@anCurrentRMS", cycle.AN.I.RMS); command.Parameters.AddWithValue("@anCurrentPhase", cycle.AN.I.Phase.ToDegrees()); command.Parameters.AddWithValue("@bnVoltagePeak", cycle.BN.V.Peak); command.Parameters.AddWithValue("@bnVoltageRMS", cycle.BN.V.RMS); command.Parameters.AddWithValue("@bnVoltagePhase", cycle.BN.V.Phase.ToDegrees()); command.Parameters.AddWithValue("@bnCurrentPeak", cycle.BN.I.Peak); command.Parameters.AddWithValue("@bnCurrentRMS", cycle.BN.I.RMS); command.Parameters.AddWithValue("@bnCurrentPhase", cycle.BN.I.Phase.ToDegrees()); command.Parameters.AddWithValue("@cnVoltagePeak", cycle.CN.V.Peak); command.Parameters.AddWithValue("@cnVoltageRMS", cycle.CN.V.RMS); command.Parameters.AddWithValue("@cnVoltagePhase", cycle.CN.V.Phase.ToDegrees()); command.Parameters.AddWithValue("@cnCurrentPeak", cycle.CN.I.Peak); command.Parameters.AddWithValue("@cnCurrentRMS", cycle.CN.I.RMS); command.Parameters.AddWithValue("@cnCurrentPhase", cycle.CN.I.Phase.ToDegrees()); command.Parameters.AddWithValue("@positiveVoltageMagnitude", sequenceVoltages[1].Magnitude); command.Parameters.AddWithValue("@positiveVoltageAngle", sequenceVoltages[1].Angle.ToDegrees()); command.Parameters.AddWithValue("@negativeVoltageMagnitude", sequenceVoltages[2].Magnitude); command.Parameters.AddWithValue("@negativeVoltageAngle", sequenceVoltages[2].Angle.ToDegrees()); command.Parameters.AddWithValue("@zeroVoltageMagnitude", sequenceVoltages[0].Magnitude); command.Parameters.AddWithValue("@zeroVoltageAngle", sequenceVoltages[0].Angle.ToDegrees()); command.Parameters.AddWithValue("@positiveCurrentMagnitude", sequenceCurrents[1].Magnitude); command.Parameters.AddWithValue("@positiveCurrentAngle", sequenceCurrents[1].Angle.ToDegrees()); command.Parameters.AddWithValue("@negativeCurrentMagnitude", sequenceCurrents[2].Magnitude); command.Parameters.AddWithValue("@negativeCurrentAngle", sequenceCurrents[2].Angle.ToDegrees()); command.Parameters.AddWithValue("@zeroCurrentMagnitude", sequenceCurrents[0].Magnitude); command.Parameters.AddWithValue("@zeroCurrentAngle", sequenceCurrents[0].Angle.ToDegrees()); command.ExecuteNonQuery(); command.Parameters.Clear(); // Get the ID of the cycle data that was entered command.CommandText = "SELECT @@IDENTITY"; cycleID = Convert.ToInt32(command.ExecuteScalar()); // Insert fault distances calculated for this cycle InsertFaultDistances(faultDataSet, command, cycleIndex, cycleID); }