/*#--------------------------------------------------------------------------#*/ /* Description: Reset * * Input(s) : Reset all variables to default * * Output(s) : * * Returns : * * Pre.Cond. : * * Post.Cond. : * * Notes : */ /*#--------------------------------------------------------------------------#*/ public void Reset() { CL10Heart.Value = true; F11.Value = false; EOS10.Value = false; EOS11.Value = false; F13.Value = false; F12.Value = false; Block5B.Value = false; Block8A.Value = false; TrackPower.Value = false; Block5BIn.Value = true; Block6In.Value = true; Block7In.Value = true; Resistor.Value = true; Track1.Value = false; Track2.Value = false; Track3.Value = false; Track4.Value = false; Track5.Value = false; Track6.Value = false; Track7.Value = false; Track8.Value = false; Track9.Value = false; Track10.Value = false; Track11.Value = false; Block6.Value = false; Block7.Value = false; F10.Value = false; M10.Value = false; //TrackNo.Count = 1; TrackPower15V.Value = false; FiddleOneLeftFinished.Mssg = false; FiddleOneLeftFinished.Data = 0x03; FiddleOneRightFinished.Mssg = false; FiddleOneRightFinished.Data = 0x04; FiddleMultipleLeftFinished.Mssg = false; FiddleMultipleLeftFinished.Data = 0x05; FiddleMultipleRightFinished.Mssg = false; FiddleMultipleRightFinished.Data = 0x06; TrainDetectionFinished.Mssg = false; TrainDetectionFinished.Data = 0x07; TrainOn5B.Mssg = false; TrainOn5B.Data = 0x0F; TrainOn8A.Mssg = false; TrainOn8A.Data = 0x11; FiddleYardReset.Mssg = false; FiddleYardReset.Data = 0x15; if ("FiddleYardTOP" == m_instance) { for (int i = 1; i < NoOfSimTrains; i++) { TrainsOnFYSim[i] = rng.Next(0, 2); current = FYSimTrains[i - 1]; if (TrainsOnFYSim[i] == 1) { current.SimTrainLocation = TrackNoToTrackString(i); } else { current.SimTrainLocation = TrackNoToTrackString(0); } } } else if ("FiddleYardBOT" == m_instance) { for (int i = 1; i < NoOfSimTrains; i++) { rng.Next(0, 2); } for (int i = 1; i < NoOfSimTrains; i++) { TrainsOnFYSim[i] = rng.Next(0, 2); current = FYSimTrains[i - 1]; if (TrainsOnFYSim[i] == 1) { current.SimTrainLocation = TrackNoToTrackString(i); } else { current.SimTrainLocation = TrackNoToTrackString(0); } } } }
/*#--------------------------------------------------------------------------#*/ /* Description: Start: When simulator is required, start the alive kick * and create the simulator variables * * * Input(s) : * * Output(s) : timer timed event * * Returns : * * Pre.Cond. : * * Post.Cond. : * * Notes : * */ /*#--------------------------------------------------------------------------#*/ public void Start() { FiddleYardSimulatorLogging.StoreText("### Fiddle Yard Simulator started ###"); // Create simtrains here, when the simulator is not started the simulated trains are not created for (int i = 1; i <= NoOfSimTrains; i++) { TrainsOnFYSim[i] = rng.Next(0, 2); current = new FiddleYardSimTrain(m_instance, this, m_FYIOHandleVar, FYSimVar); current.FYSimtrainInstance = current.ClassName + i.ToString(fmt); if (TrainsOnFYSim[i] == 1) { current.SimTrainLocation = TrackNoToTrackString(i); // on FY OR Block 5B/7/8A OR buffer } else { current.SimTrainLocation = TrackNoToTrackString(0); // Always in buffer in this case } FYSimTrains.Add(current); } FiddleYardSimulatorLogging.StoreText("FYSim created "+ Convert.ToString(NoOfSimTrains) +" FYSimTrains."); FYSimVar.Reset(); FiddleYardSimulatorLogging.StoreText("FYSim Simulator Reset()"); UpdateSimArrayToAppArray(); // Update track variables if a train is present or not FiddleYardSimulatorLogging.StoreText("FYSim Simulator UpdateSimArrayToAppArray()"); aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); // Set the Interval to [x] miliseconds. aTimer.Interval = Convert.ToInt16(Siebwalde_Application.Properties.Settings.Default.FIDDLExYARDxSIMxSPEEDxSETTING); aTimer.AutoReset = true; // Enable the timer aTimer.Enabled = true; FiddleYardSimulatorLogging.StoreText("FYSim Simulator Timer started: aTimer.Interval = " + Convert.ToString(aTimer.Interval)); FiddleYardSimulatorLogging.StoreText("FYSim State_Machine = State.Idle from Start()"); }
public FiddleYardSimulator(string Instance, iFiddleYardController iFYCtrl) { m_iFYCtrl = iFYCtrl; // connect to FYController interface, save interface in variable m_instance = Instance; TargetAlive = new SensorUpdater(); FYMove = new FiddleYardSimMove(this); FYTrDt = new FiddleYardSimTrainDetect(this); if ("FiddleYardTOP" == m_instance) { path = @"c:\localdata\FiddleYardSimTOPLogging.txt"; // different logging file per target, this is default Message Msg_TargetAliveTop = new Message("TargetAlive", " Target Alive ", (name, log) => SetMessage(name, log)); // initialize and subscribe readback action, Message m_iFYCtrl.GetIoHandler().TargetAliveTop.Attach(Msg_TargetAliveTop); for (int i = 1; i < NoOfSimTrains; i++) { TrainsOnFYSim[i]=rng.Next(0, 2); current = new FiddleYardSimTrain(m_instance, this, m_iFYCtrl); current.FYSimtrainInstance = current.ClassName + i.ToString(); if (TrainsOnFYSim[i] == 1) { current.SimTrainLocation = TrackNoToTrackString(i); } else { current.SimTrainLocation = TrackNoToTrackString(0); } FYSimTrains.Add(current); } TrackNo.Count = 1; } else if ("FiddleYardBOT" == m_instance) { path = @"c:\localdata\FiddleYardSimBOTLogging.txt"; // different logging file per target, this is default Message Msg_TargetAliveBot = new Message("TargetAlive", " Target Alive ", (name, log) => SetMessage(name, log)); // initialize and subscribe readback action, Message m_iFYCtrl.GetIoHandler().TargetAliveBot.Attach(Msg_TargetAliveBot); for (int i = 1; i < NoOfSimTrains; i++) { rng.Next(0, 2); } for (int i = 1; i < NoOfSimTrains; i++) { TrainsOnFYSim[i] = rng.Next(0, 2); current = new FiddleYardSimTrain(m_instance, this, m_iFYCtrl); current.FYSimtrainInstance = current.ClassName + i.ToString(); if (TrainsOnFYSim[i] == 1) { current.SimTrainLocation = TrackNoToTrackString(i); } else { current.SimTrainLocation = TrackNoToTrackString(0); } FYSimTrains.Add(current); } TrackNo.Count = 1; } }