//checks output when changing control bit public override bool TestGate() { Control.Value = 1; String first_string = "["; String second_string = "["; for (int i = 0; i < Size; i++) { Input[i].Value = 1; first_string = first_string + "1"; second_string = second_string + "0"; } first_string = first_string + "]"; second_string = second_string + "]"; if (!Output1.ToString().Equals(second_string) || !Output2.ToString().Equals(first_string)) { return(false); } Control.Value = 0; if (!Output1.ToString().Equals(first_string) || !Output2.ToString().Equals(second_string)) { return(false); } return(true); }
public override string ToString() { string g = guard.ToString(); string o1 = (Output == null ? "" : "/" + Output.ToString()); string o2 = (Output2 == null ? "" : "/" + Output2.ToString()); string u = (Update == null ? "" : "; r:=" + Update.ToString()); string s = String.Format("{4}{0}{1}{2}{3}{5}{6}", g, o1, o2, u, (IsFinal ? "[" : ""), (IsFinal ? "]" : ""), (k > 1 ? "(" + k + ")" : "")); return(s); }
public void Compute() { if (Control.Value == 0) { Output1.SetValue(Input.GetValue()); Output2.SetValue(0); } else { Output2.SetValue(Input.GetValue()); Output1.SetValue(0); } }
/// <summary> /// Calculate elevation angle and ETA /// </summary> /// <param name="range"></param> /// <param name="deltaAlt"></param> /// <param name="velocity"></param> /// <param name="isSteepAngle"></param> public static Output2 Calculate2(double range, double deltaAlt, double velocity) { var output = new Output2(); const double g = 9.80665; output.Angle0 = Math.Atan((Math.Pow(velocity, 2) - Math.Sqrt(Math.Pow(velocity, 4) - g*(g*Math.Pow(range, 2) + 2*deltaAlt*Math.Pow(velocity, 2))))/ (g*range))*(180/Math.PI); output.Angle1 = Math.Atan((Math.Pow(velocity, 2) + Math.Sqrt(Math.Pow(velocity, 4) - g*(g*Math.Pow(range, 2) + 2*deltaAlt*Math.Pow(velocity, 2))))/ (g*range))*(180/Math.PI); output.Eta0 = range/(velocity*Math.Cos(output.Angle0*(Math.PI/180))); output.Eta1 = range/(velocity*Math.Cos(output.Angle1*(Math.PI/180))); return output; }