Exemplo n.º 1
0
        /// <summary>
        /// Generic state change request that represents the P-ROC's PRDriverUpdateState function
        /// </summary>
        /// <param name="newState"></param>
        public void update_state(DriverState newState)
        {
            // Copy the newState object to the current local state
            this._state.DriverNum            = newState.DriverNum;
            this._state.OutputDriveTime      = newState.OutputDriveTime;
            this._state.PatterEnable         = newState.PatterEnable;
            this._state.PatterOffTime        = newState.PatterOffTime;
            this._state.PatterOnTime         = newState.PatterOnTime;
            this._state.Polarity             = newState.Polarity;
            this._state.State                = newState.State;
            this._state.Timeslots            = newState.Timeslots;
            this._state.WaitForFirstTimeSlot = newState.WaitForFirstTimeSlot;

            if (!newState.State)
            {
                this.Disable();
            }
            else if (newState.Timeslots == 0)
            {
                this.Pulse(newState.OutputDriveTime);
            }
            else
            {
                this.Schedule(newState.Timeslots, newState.OutputDriveTime, newState.WaitForFirstTimeSlot);
            }
        }
Exemplo n.º 2
0
		private SlideshowDriver(SlideshowModel model, ISlideshowViewer viewer, IPlatformService platformService)
		{
			PlatformService = platformService;
			Model = model;
			Viewer = viewer;
			State = DriverState.Created;
		}
Exemplo n.º 3
0
 public void OnNext(ITaskMessage msg)
 {
     CheckMsgOrder(msg);
     Debug.Assert(Enumerable.SequenceEqual(HelloStringByteArray, msg.Message));
     Debug.Assert(_state == DriverState.SendMsg);
     _state = DriverState.Suspend;
     _clock.ScheduleAlarm(MsgDelay, this);
 }
Exemplo n.º 4
0
        private void CheckMsgOrder(object obj)
        {
            string msgClassName = _failMsgClass.FullName;

            Log.Log(Level.Info, "Driver state {0} event sequence {1} message obj type {2}",
                    _state, EventSequence[_expectIdx].Type, obj.GetType());

            if (_state == DriverState.Failed)
            {
                // If already failed, do not do anything
                return;
            }

            // Simulate failure at this step?
            if (_failMsgClass.IsInstanceOfType(obj))
            {
                _state = DriverState.Failed;
            }

            // Make sure events arrive in the right order (specified in EVENT_SEQUENCE):
            bool notFound = true;

            for (; _expectIdx < EventSequence.Length; ++_expectIdx)
            {
                if (EventSequence[_expectIdx].Type.IsInstanceOfType(obj))
                {
                    Log.Log(Level.Info, "Object type {0} is instance of expected type {1}", new object[] { obj.GetType(), EventSequence[_expectIdx].Type });
                    notFound = false;
                    break;
                }
                else if (EventSequence[_expectIdx].Flag == ExpectedMessage.RequiredFlag.Required)
                {
                    Log.Log(Level.Info, "Object type {0} is NOT instance of expected type {1}", new object[] { obj.GetType(), EventSequence[_expectIdx].Type });
                    break;
                }
            }

            if (notFound)
            {
                Log.Log(Level.Info, "Event out of sequence: Driver state {0} event sequence {1} message obj type {2}",
                        new object[] { _state, EventSequence[_expectIdx].Type, obj.GetType() });
                throw new DriverSideFailure("Event out of sequence: " + msgClassName);
            }

            Log.Log(Level.Info, "{0}: send: {1} got: {2}", new object[] {
                _state, EventSequence[_expectIdx], msgClassName
            });

            ++_expectIdx;

            if (_state == DriverState.Failed)
            {
                SimulatedDriverFailure ex = new SimulatedDriverFailure(
                    "Simulated Failure at FailDriver :: " + msgClassName);
                Log.Log(Level.Info, "Simulated Failure:", ex);
                throw ex;
            }
        }
Exemplo n.º 5
0
 public Driver(string Nom, string Prenom, string Pseudo, string Email, string Password, string NTelephone, string Image) : base(Nom, Prenom, Pseudo, Email, Password, NTelephone, Image)
 {
     Rating = 0;
     PosX   = 0;
     PosY   = 0;
     Active = false;
     Free   = false;
     State  = DriverState.Disabled;
 }
Exemplo n.º 6
0
 public DriverInfo(int id, string name, Guid guid, int systemRate, SpeakerMode speakerMode, int speakerModeChannels, DriverState driverState)
     : this()
 {
     Id                  = id;
     Name                = name;
     Guid                = guid;
     SystemRate          = systemRate;
     SpeakerMode         = speakerMode;
     SpeakerModeChannels = speakerModeChannels;
     DriverState         = driverState;
 }
Exemplo n.º 7
0
 public DriverInfo(int id, string name, Guid guid, int systemRate, SpeakerMode speakerMode, int speakerModeChannels, DriverState driverState)
     : this()
 {
     Id = id;
     Name = name;
     Guid = guid;
     SystemRate = systemRate;
     SpeakerMode = speakerMode;
     SpeakerModeChannels = speakerModeChannels;
     DriverState = driverState;
 }
Exemplo n.º 8
0
        private void HandleReport(object sender, IDeviceReport report)
        {
            if (BindingEnabled && OutputMode?.TabletProperties != null)
            {
                OutputMode?.Read(report);
                if (OutputMode is IBindingHandler <IBinding> binding)
                {
                    binding.HandleBinding(report);
                }
            }

            DriverState.PostReport(sender, report);
        }
Exemplo n.º 9
0
        public VirtualDriver(GameController game, string name, ushort number, bool polarity)
            : base(game, name, number)
        {
            this._state = new DriverState();
            this._state.Polarity = polarity;
            this._state.Timeslots = 0x0;
            this._state.PatterEnable = false;
            this._state.DriverNum = number;
            this._state.PatterOnTime = 0;
            this._state.PatterOffTime = 0;
            this._state.State = false;
            this._state.OutputDriveTime = 0;
            this._state.WaitForFirstTimeSlot = false;

            this._currentValue = !(_currentState ^ this._state.Polarity);
        }
Exemplo n.º 10
0
        public VirtualDriver(GameController game, string name, ushort number, bool polarity)
            : base(game, name, number)
        {
            this._state                      = new DriverState();
            this._state.Polarity             = polarity;
            this._state.Timeslots            = 0x0;
            this._state.PatterEnable         = false;
            this._state.DriverNum            = number;
            this._state.PatterOnTime         = 0;
            this._state.PatterOffTime        = 0;
            this._state.State                = false;
            this._state.OutputDriveTime      = 0;
            this._state.WaitForFirstTimeSlot = false;

            this._currentValue = !(_currentState ^ this._state.Polarity);
        }
Exemplo n.º 11
0
        public async Task StartCardReaderAsync(string deviceId)
        {
            if (isDriverManagerStarting)
            {
                await libWrapper.StartCardReaderAsync(deviceId);

                StartDriverManager();
                desiredDriverState = DriverState.ReaderConnected;
            }
            else
            {
                if (currentDriverState == DriverState.ReaderAuthenticated)
                {
                    desiredDriverState = DriverState.ReaderPolling;
                }
            }
        }
Exemplo n.º 12
0
        public void InitializeDrivers(IProcDevice proc)
        {
            // Loop through all of the drivers, initializing them with the polarity
            for (ushort i = 0; i < 208; i++)
            {
                DriverState state = new DriverState();
                state.DriverNum            = i;
                state.OutputDriveTime      = 0;
                state.Polarity             = true;
                state.State                = false;
                state.WaitForFirstTimeSlot = false;
                state.Timeslots            = 0;
                state.PatterOnTime         = 0;
                state.PatterOffTime        = 0;
                state.PatterEnable         = false;
                state.futureEnable         = false;

                proc.driver_update_state(ref state);
            }
        }
Exemplo n.º 13
0
        private void DoTaskWithTimeout(DriverState driverState, int timeout)
        {
            CancellationTokenSource ct = new CancellationTokenSource();
            Task t = Task.Run(async() =>
            {
                while (currentDriverState != driverState)
                {
                    await Task.Delay(100);
                }
            }, ct.Token);

            if (!t.Wait(timeout))
            {
                if (!ct.IsCancellationRequested)
                {
                    ct.Cancel();
                }
                throw new TimeoutException();
            }

            //currentDriverState = driverState;
        }
Exemplo n.º 14
0
 public void OnNext(ISuspendedTask suspendedTask)
 {
     CheckMsgOrder(suspendedTask);
     _state = DriverState.Resume;
     try
     {
         suspendedTask.ActiveContext.SubmitTask(TaskConfiguration.ConfigurationModule
                                                .Set(TaskConfiguration.Identifier, suspendedTask.Id + "_RESUMED")
                                                .Set(TaskConfiguration.Task, GenericType <NoopTask> .Class)
                                                .Set(TaskConfiguration.OnMessage, GenericType <NoopTask> .Class)
                                                .Set(TaskConfiguration.OnSuspend, GenericType <NoopTask> .Class)
                                                .Set(TaskConfiguration.OnClose, GenericType <NoopTask> .Class)
                                                .Set(TaskConfiguration.OnTaskStop, GenericType <NoopTask> .Class)
                                                .Set(TaskConfiguration.OnSendMessage, GenericType <NoopTask> .Class)
                                                .Set(TaskConfiguration.Memento, ByteUtilities.ByteArraysToString(HelloStringByteArray))
                                                .Build());
     }
     catch (BindException ex)
     {
         Log.Log(Level.Error, "Task configuration error", ex);
         throw new DriverSideFailure("Task configuration error", ex);
     }
 }
Exemplo n.º 15
0
        public void OnNext(IRunningTask runningTask)
        {
            CheckMsgOrder(runningTask);
            _task = runningTask;
            switch (_state)
            {
            case DriverState.Init:
                Log.Log(Level.Info, "Move to state {0}", DriverState.SendMsg);
                _state = DriverState.SendMsg;
                break;

            case DriverState.Resume:
                Log.Log(Level.Info, "Move to state {0}", DriverState.Close);
                _state = DriverState.Close;
                break;

            default:
                Log.Log(Level.Warning, "Unexpected state at TaskRuntime: {0}", _state);
                throw new DriverSideFailure("Unexpected state: " + _state);
            }

            // After a delay, send message or suspend the task:
            _clock.ScheduleAlarm(MsgDelay, this);
        }
Exemplo n.º 16
0
        private static void handleOne(Socket driverSocket)
        {
            var state = new DriverState { socket = driverSocket };

            StartReceiveCommand(state);
        }
Exemplo n.º 17
0
        private static void HandleCommand(DriverState state)
        {
            var parts = Encoding.ASCII.GetString(state.receiveBuffer, 0, state.receivedBytes).Split(' ');

            var cmd = parts[0];

            if (cmd == "LISTEN")
            {
                Console.WriteLine("Creating listening port " + parts[1]);

                var port = int.Parse(parts[1]);
                var newListeningPort = new TcpListener(IPAddress.Any, port);
                newListeningPort.Start();

                var acceptState = new ListenerState { listener = newListeningPort, driver = state, port = port };
                state.listeningPorts.Add(acceptState.port, acceptState);

                StartReceiveCommand(state);
            }
            else if (cmd == "STOP_LISTEN")
            {
                Console.WriteLine("Stopping listening port " + parts[1]);

                var port = int.Parse(parts[1]);
                var listenerState = state.listeningPorts[port];
                listenerState.listener.Stop();
                state.listeningPorts.Remove(port);

                StartReceiveCommand(state);
            }
            else if (cmd == "CLOSE_CONNECTION")
            {
                Console.WriteLine("Closing connection " + parts[1]);

                var connectionId = int.Parse(parts[1]);
                var connectionState = state.connections[connectionId];
                connectionState.socket.Shutdown(SocketShutdown.Both);
                connectionState.socket.Close();
                state.connections.Remove(connectionId);

                StartReceiveCommand(state);
            }
            else if (cmd == "ACCEPT_ONE")
            {
                Console.WriteLine("Accepting one connection on port " + parts[1]);

                var port = int.Parse(parts[1]);
                var listenerState = state.listeningPorts[port];
                listenerState.listener.BeginAcceptSocket(new AsyncCallback(OnAcceptSocketOnce), listenerState);

                StartReceiveCommand(state);
            }
            else if (cmd == "ACCEPT_ALL")
            {
                Console.WriteLine("Accepting all connections on port " + parts[1]);

                var port = int.Parse(parts[1]);
                var listenerState = state.listeningPorts[port];
                listenerState.listener.BeginAcceptSocket(new AsyncCallback(OnAcceptSocket), listenerState);

                StartReceiveCommand(state);
            }
            else if (cmd == "SEND")
            {
                Console.WriteLine("Sending " + parts[2] + " bytes to " + parts[1]);

                var connectionId = int.Parse(parts[1]);
                var messageLength = int.Parse(parts[2]);
                var payloadState = new SendPayloadState
                {
                    bytesToReceive = messageLength,
                    target = state.connections[connectionId]
                };
                state.socket.BeginReceive(state.receiveBuffer, 0, Math.Min(payloadState.bytesToReceive, state.receiveBuffer.Length),
                    SocketFlags.None, new AsyncCallback(OnPayloadReceived), payloadState);
            }
            else if (cmd == "READ_ONCE")
            {
                Console.WriteLine("Reading once (max " + parts[2] + " bytes) from " + parts[1]);

                var connectionId = int.Parse(parts[1]);
                var maxBytes = int.Parse(parts[2]);
                var connectionState = state.connections[connectionId];
                if (maxBytes == 0)
                {
                    maxBytes = connectionState.receiveBuffer.Length;
                }
                connectionState.socket.BeginReceive(connectionState.receiveBuffer, 0, maxBytes, SocketFlags.None, new AsyncCallback(OnReceiveClientDataOnce), connectionState);

                StartReceiveCommand(state);
            }
            else if (cmd == "READ_ALL")
            {
                Console.WriteLine("Reading all from " + parts[1]);

                var connectionId = int.Parse(parts[1]);
                var connectionState = state.connections[connectionId];
                connectionState.socket.BeginReceive(connectionState.receiveBuffer, 0, connectionState.receiveBuffer.Length, SocketFlags.None, new AsyncCallback(OnReceiveClientData), connectionState);

                StartReceiveCommand(state);
            }
            else
            {
                Console.WriteLine("Unknown command: " + string.Join(" ", parts));
            }
        }
Exemplo n.º 18
0
 public LampStateRecord(double time, DriverState state)
 {
     this.time  = time;
     this.state = state;
 }
Exemplo n.º 19
0
 private static extern Result FMOD_System_GetRecordDriverInfo(IntPtr system, int id, IntPtr name, int namelen,
                                                              out Guid guid, out int systemRate, out SpeakerMode speakerMode, out int speakerModeChannels, out DriverState state);
Exemplo n.º 20
0
		public void PauseOrResume()
		{
			logger.Info("SlideshowDriver.Pause: {0}", State);
			if (State == DriverState.Paused)
			{
				Play();
			}
			else if (State == DriverState.Playing)
			{
				State = DriverState.Paused;
                DestroyTimer();
			}
			PlatformService.InvokeOnUiThread( () => Viewer.UpdateUiState());
		}
Exemplo n.º 21
0
        public void link_flipper_switch(string switch_name, string[] linked_coils)
        {
            // Hold all of the linked coils * 2 (one for Main, one for Hold)
            DriverState[] drivers = new DriverState[linked_coils.Length * 2];
            Driver main_coil, hold_coil;
            ushort switch_num = _switches[switch_name].Number;
            int driverIdx = 0;
            if (_flippers_enabled)
            {
                foreach (string coil in linked_coils)
                {
                    main_coil = _coils[coil + "Main"];
                    hold_coil = _coils[coil + "Hold"];
                    drivers[driverIdx] = _proc.driver_state_pulse(main_coil.State, 34);
                    driverIdx++;
                    drivers[driverIdx] = _proc.driver_state_pulse(hold_coil.State, 0);
                    driverIdx++;
                }
                // Add switch rule for activating flippers (when switch closes)
                _proc.switch_update_rule(switch_num,
                    EventType.SwitchClosedNondebounced,
                    new SwitchRule { NotifyHost = false, ReloadActive = false },
                    drivers,
                    false
                );

                // --------------------------------------------------------------
                // Now add the rule for open switches and disabling flippers
                // --------------------------------------------------------------
                driverIdx = 0;
                foreach (string coil in linked_coils)
                {
                    main_coil = _coils[coil + "Main"];
                    hold_coil = _coils[coil + "Hold"];
                    drivers[driverIdx] = _proc.driver_state_disable(main_coil.State);
                    driverIdx++;
                    drivers[driverIdx] = _proc.driver_state_disable(hold_coil.State);
                    driverIdx++;
                }
                _proc.switch_update_rule(switch_num,
                    EventType.SwitchOpenNondebounced,
                    new SwitchRule { NotifyHost = false, ReloadActive = false },
                    drivers,
                    false
                );
            }
            else
            {
                // Remove all switch linkages
                _proc.switch_update_rule(switch_num,
                    EventType.SwitchClosedNondebounced,
                    new SwitchRule { NotifyHost = false, ReloadActive = false },
                    null,
                    false
                );
                _proc.switch_update_rule(switch_num,
                    EventType.SwitchOpenNondebounced,
                    new SwitchRule { NotifyHost = false, ReloadActive = false },
                    null,
                    false
                );
                // Disable flippers
                foreach (string coil in linked_coils)
                {
                    main_coil = _coils[coil + "Main"];
                    hold_coil = _coils[coil + "Hold"];
                    main_coil.Disable();
                    hold_coil.Disable();
                }
            }
        }
Exemplo n.º 22
0
 public LampStateRecord(double time, DriverState state)
 {
     this.time = time;
     this.state = state;
 }
Exemplo n.º 23
0
        public void link_flipper_switch(string switch_name, string[] linked_coils)
        {
            // Hold all of the linked coils * 2 (one for Main, one for Hold)
            DriverState[] drivers = new DriverState[linked_coils.Length * 2];
            Driver        main_coil, hold_coil;
            ushort        switch_num = _switches[switch_name].Number;
            int           driverIdx  = 0;

            if (_flippers_enabled)
            {
                foreach (string coil in linked_coils)
                {
                    main_coil          = _coils[coil + "Main"];
                    hold_coil          = _coils[coil + "Hold"];
                    drivers[driverIdx] = _proc.driver_state_pulse(main_coil.State, 34);
                    driverIdx++;
                    drivers[driverIdx] = _proc.driver_state_pulse(hold_coil.State, 0);
                    driverIdx++;
                }
                // Add switch rule for activating flippers (when switch closes)
                _proc.switch_update_rule(switch_num,
                                         EventType.SwitchClosedNondebounced,
                                         new SwitchRule {
                    NotifyHost = false, ReloadActive = false
                },
                                         drivers,
                                         false
                                         );

                // --------------------------------------------------------------
                // Now add the rule for open switches and disabling flippers
                // --------------------------------------------------------------
                driverIdx = 0;
                foreach (string coil in linked_coils)
                {
                    main_coil          = _coils[coil + "Main"];
                    hold_coil          = _coils[coil + "Hold"];
                    drivers[driverIdx] = _proc.driver_state_disable(main_coil.State);
                    driverIdx++;
                    drivers[driverIdx] = _proc.driver_state_disable(hold_coil.State);
                    driverIdx++;
                }
                _proc.switch_update_rule(switch_num,
                                         EventType.SwitchOpenNondebounced,
                                         new SwitchRule {
                    NotifyHost = false, ReloadActive = false
                },
                                         drivers,
                                         false
                                         );
            }
            else
            {
                // Remove all switch linkages
                _proc.switch_update_rule(switch_num,
                                         EventType.SwitchClosedNondebounced,
                                         new SwitchRule {
                    NotifyHost = false, ReloadActive = false
                },
                                         null,
                                         false
                                         );
                _proc.switch_update_rule(switch_num,
                                         EventType.SwitchOpenNondebounced,
                                         new SwitchRule {
                    NotifyHost = false, ReloadActive = false
                },
                                         null,
                                         false
                                         );
                // Disable flippers
                foreach (string coil in linked_coils)
                {
                    main_coil = _coils[coil + "Main"];
                    hold_coil = _coils[coil + "Hold"];
                    main_coil.Disable();
                    hold_coil.Disable();
                }
            }
        }
Exemplo n.º 24
0
		public void Stop()
		{
			logger.Info("SlideshowDriver.Stop {0}", State);
			State = DriverState.Stopped;
            DestroyTimer();
		}
Exemplo n.º 25
0
		private void BeginEnumerate()
		{
			State = DriverState.Enumerating;
			Task.Factory.StartNew( () => 
				{
					Model.Enumerate( () => 
						{
							logger.Info("Images available: {0}", Model.MediaList.Count);
							PlatformService.InvokeOnUiThread( delegate { Viewer.UpdateUiState(); } );
							Play();
						});
				})
			.ContinueWith( t =>
				{
					if (!t.IsFaulted && !t.IsCanceled)
					{
						if (State == DriverState.Playing || State == DriverState.Paused)
						{
							logger.Info("Images fully loaded: {0}", Model.MediaList.Count);
							PlatformService.InvokeOnUiThread( delegate 
								{
									Viewer.UpdateUiState(); 
								} );
							Play();
						}
						else
						{
							logger.Info("Not playing, ignoring completed enumeration");
						}
					}
					else
					{
						logger.Error("Failed or canceled: {0}", t.Exception);
						PlatformService.InvokeOnUiThread( delegate { Viewer.Error(t.Exception.Message); });
					}

					return t;
				});
		}
Exemplo n.º 26
0
 private void UpdateState(DriverState state)
 {
     currentDriverState = state;
     LogMessage("===> Driver State Changed: " + state);
 }
Exemplo n.º 27
0
        private void StartStateTransitionManager()
        {
            while (1 == 1)
            {
                try
                {
                    if (cancellationTokenForDriverManager.Token.IsCancellationRequested)
                    {
                        cancellationTokenForDriverManager.Dispose();
                        break;
                    }

                    //any reader event/exception causing a disconect must set DriverState to ReaderDiconnected
                    if (desiredDriverState != currentDriverState)
                    {
                        switch (desiredDriverState)
                        {
                        case DriverState.ReaderDiconnected:
                            DoTaskWithTimeout(doDisconnect(), 5000);
                            break;

                        case DriverState.ReaderConnected:
                            DoTaskWithTimeout(doConnect(), 5000);
                            desiredDriverState = DriverState.ReaderDetected;    //move to next state
                            break;

                        case DriverState.ReaderDetected:
                            DoTaskWithTimeout(doDetect(), 5000);
                            desiredDriverState = DriverState.ReaderAuthenticated; //move to next state
                            Task.Delay(1000).Wait();                              //wait after detection, before trying to auth
                            break;

                        case DriverState.ReaderAuthenticated:
                            if (currentDriverState == DriverState.ReaderPolling)
                            {
                                doStopPoll();
                                currentDriverState = DriverState.ReaderAuthenticated;
                                break;
                            }
                            DoTaskWithTimeout(doAuth(), 5000);
                            if (isDriverManagerStarting)
                            {
                                Task.Run(() => { doTurnOffSleepMode(); });
                                Task.Delay(1000).Wait();    //wait for sleep mode turned on
                                desiredDriverState      = DriverState.ReaderPolling;
                                isDriverManagerStarting = false;
                            }
                            break;

                        case DriverState.ReaderPolling:
                            currentDriverState = doStartPoll();
                            //fire an ReaderStarted event
                            break;
                        }
                    }
                    else
                    {
                        Task.Delay(100).Wait();
                    }
                }
                catch (Exception ex)
                {
                    LogMessage("Error in StateTransitionManager:" + ex.Message);
                    //if (currentDriverState == DriverState.ReaderAuthenticated || currentDriverState == DriverState.ReaderPolling)
                    //{
                    //    //restart the state engine
                    //    desiredDriverState = DriverState.ReaderConnected;
                    //}
                    //else
                    //{
                    //    //stop the state engine
                    //    desiredDriverState = DriverState.ReaderDiconnected;
                    //}
                    desiredDriverState = DriverState.ReaderConnected;
                }
            }
        }
Exemplo n.º 28
0
 public void StopCardReaderAsync()
 {
     desiredDriverState = DriverState.ReaderAuthenticated;
 }
Exemplo n.º 29
0
 private static void StartReceiveCommand(DriverState state)
 {
     state.receivedBytes = 0;
     state.socket.BeginReceive(state.receiveBuffer, state.receivedBytes, 1, SocketFlags.None, new AsyncCallback(OnCommandDataReceived), state);
 }
Exemplo n.º 30
0
		public void Play()
		{
			logger.Info("SlideshowDriver.Play: {0}", State);
			if (State == DriverState.Playing)
			{
				return;
			}

			State = DriverState.Playing;
            SetupTimer();
			Next();
		}
Exemplo n.º 31
0
 internal RecordDriverInfo(string name, Guid guid, int rate, SpeakerMode speakermode, int channels, DriverState state)
     : base(name, guid, rate, speakermode, channels)
 {
     State = state;
 }
Exemplo n.º 32
0
        /// <summary>
        /// Generic state change request that represents the P-ROC's PRDriverUpdateState function
        /// </summary>
        /// <param name="newState"></param>
        public void update_state(DriverState newState)
        {
            // Copy the newState object to the current local state
            this._state.DriverNum = newState.DriverNum;
            this._state.OutputDriveTime = newState.OutputDriveTime;
            this._state.PatterEnable = newState.PatterEnable;
            this._state.PatterOffTime = newState.PatterOffTime;
            this._state.PatterOnTime = newState.PatterOnTime;
            this._state.Polarity = newState.Polarity;
            this._state.State = newState.State;
            this._state.Timeslots = newState.Timeslots;
            this._state.WaitForFirstTimeSlot = newState.WaitForFirstTimeSlot;

            if (!newState.State) this.Disable();
            else if (newState.Timeslots == 0) this.Pulse(newState.OutputDriveTime);
            else this.Schedule(newState.Timeslots, newState.OutputDriveTime, newState.WaitForFirstTimeSlot);
        }