Inheritance: MonoBehaviour
Example #1
0
        /// <summary>
        /// Returns the compressed column storage (CCS) representation of the sparse matrix.
        /// </summary>
        /// <typeparam name="K">The type of keys.</typeparam>
        /// <typeparam name="T">The type of entry values.</typeparam>
        /// <param name="sparseMatrix">The sparse matrix to compress.</param>
        /// <returns>The compressed column storage (CCS) representation of the sparse matrix.</returns>
        public static CCS <T> ToCCS <K, T>(this DOKSparseMatrixBase <K, T> sparseMatrix)
        {
            CCS <T> ccs = new CCS <T>(sparseMatrix.Size);

            ccs.Compress(sparseMatrix);
            return(ccs);
        }
Example #2
0
        private void CCS_Click(object sender, EventArgs e)
        {
            if (loadStructures() != 0)
            {
                return;
            }
            string mat = new CCS(matrix).serialize();

            resultsTextBox.Text = "CCS format:" + Environment.NewLine + mat;
        }
Example #3
0
        private void CCSx_Click(object sender, EventArgs e)
        {
            if (loadStructures() != 0)
            {
                return;
            }
            resultsTextBox.Text  = "CCS Matrix Multiplication:" + Environment.NewLine + Environment.NewLine;
            resultsTextBox.Text += "M =" + Environment.NewLine;
            CCS mat = new CCS(matrix);

            resultsTextBox.Text += mat.serialize();
            resultsTextBox.Text += Environment.NewLine + Environment.NewLine;
            resultsTextBox.Text += "V =" + Environment.NewLine;
            resultsTextBox.Text += String.Join(" ", vector.Select(x => x.ToString()).ToArray());
            resultsTextBox.Text += Environment.NewLine + Environment.NewLine;
            resultsTextBox.Text += "M*V =" + Environment.NewLine;
            double[] res = mat.vectorMultiply(vector);
            resultsTextBox.Text += String.Join(" ", res.Select(x => x.ToString()).ToArray());
        }
        public override void Update()
        {
            UpdateSignalPassed();

            if (IsAlerterEnabled() && VACMAPresent)
            {
                UpdateVACMA();
            }

            if (IsTrainControlEnabled())
            {
                if (RSOPresent)
                {
                    UpdateRSO();
                }

                if (CurrentPostSpeedLimitMpS() <= MpS.FromKpH(220f))
                {
                    if (KVBPresent)
                    {
                        // Classic line = KVB active
                        ActiveCCS = CCS.KVB;

                        if (SignalPassed)
                        {
                            SetNextSignalAspect(NextSignalAspect(0));
                        }

                        UpdateKVB();
                    }
                    else
                    {
                        if (!DAATPresent)
                        {
                            ActiveCCS = CCS.RSO;
                        }
                        else
                        {
                            ActiveCCS = CCS.DAAT;
                        }

                        SetNextSignalAspect(Aspect.Clear_1);
                    }
                }
                else
                {
                    // High speed line = TVM active

                    // Activation control (KAr) in KVB system
                    if (TVM300Present)
                    {
                        ActiveCCS = CCS.TVM300;

                        UpdateTVM300Display();
                        UpdateTVM300COVIT();
                    }
                    else if (TVM430Present)
                    {
                        ActiveCCS = CCS.TVM430;

                        UpdateTVM430Display();
                        UpdateTVM430COVIT();
                    }
                    else if (KVBPresent)
                    {
                        // TVM not activated because not present
                        ActiveCCS = CCS.KVB;

                        if (SignalPassed)
                        {
                            SetNextSignalAspect(NextSignalAspect(0));
                        }

                        KVBEmergencyBraking = true;
                    }
                }

                SetEmergencyBrake(
                    RSOEmergencyBraking ||
                    KVBEmergencyBraking ||
                    TVMCOVITEmergencyBraking ||
                    VACMAEmergencyBraking ||
                    ExternalEmergencyBraking
                    );

                SetPenaltyApplicationDisplay(IsBrakeEmergency());

                SetPowerAuthorization(!RSOEmergencyBraking &&
                                      !KVBEmergencyBraking &&
                                      !TVMCOVITEmergencyBraking &&
                                      !VACMAEmergencyBraking
                                      );

                if (ActiveCCS != CCS.TVM300 && ActiveCCS != CCS.TVM430)
                {
                    TVMAspect         = Aspect.None;
                    TVMPreviousAspect = Aspect.None;
                }

                RSOType1Inhibition = IsDirectionReverse();
                RSOType2Inhibition = !KVBInhibited && ((TVM300Present && ActiveCCS == CCS.TVM300) || (TVM430Present && ActiveCCS == CCS.TVM430));
                RSOType3Inhibition = (TVM300Present || TVM430Present) && !TVMCOVITInhibited;

                PreviousCCS = ActiveCCS;
            }
        }