// To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    ConsoleWriteSerialOutput(FullDeviceOutput);

                    if (DeviceClient != null)
                    {
                        DeviceClient.Close();
                    }

                    if (SimulatorClient != null)
                    {
                        SimulatorClient.Disconnect();
                    }

                    Thread.Sleep(DelayAfterDisconnectingFromHardware);
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Ejemplo n.º 2
0
        public DnsController(IKeyManagerFactory factory, ILogger <KeyController> logger, Settings settings)
        {
            _manager = factory.BuildDnsManager();
            _logger  = logger;
            _orkId   = settings.Instance.Username;

            var cln = new SimulatorClient(settings.Endpoints.Simulator.Api, _orkId, settings.Instance.GetPrivateKey());

            _orkManager = new SimulatorOrkManager(_orkId, cln);
        }
        public void SimulateLight(int lightPercentage)
        {
            Console.WriteLine("");
            Console.WriteLine("Simulating light percentage");
            Console.WriteLine("  Sending analog percentage");
            Console.WriteLine("    PWM pin: " + LightSimulatorPin);
            Console.WriteLine("    Light light Percentage: " + lightPercentage + "%");
            Console.WriteLine("");

            SimulatorClient.AnalogWritePercentage(LightSimulatorPin, lightPercentage);
        }
Ejemplo n.º 4
0
        public void SimulateSoilMoisture(int soilMoisturePercentage)
        {
            Console.WriteLine("");
            Console.WriteLine("Simulating soil moisture percentage");
            Console.WriteLine("  Sending analog percentage");
            Console.WriteLine("    PWM pin: " + SoilMoistureSimulatorPin);
            Console.WriteLine("    Soil Moisture Percentage: " + soilMoisturePercentage + "%");
            Console.WriteLine("");

            SimulatorClient.AnalogWritePercentage(SoilMoistureSimulatorPin, soilMoisturePercentage);
        }
        public void SimulateVoltage(int voltage)
        {
            Console.WriteLine("");
            Console.WriteLine("Simulating voltage percentage");
            Console.WriteLine("  Sending analog percentage");
            Console.WriteLine("    PWM pin: " + VoltageSimulatorPin);
            Console.WriteLine("    Voltage: " + voltage + "v");
            Console.WriteLine("");

            SimulatorClient.AnalogWritePercentage(VoltageSimulatorPin, voltage);
        }
Ejemplo n.º 6
0
        public void TurnSwitch(bool state)
        {
            var pinValue = (state ? 1 : 0);

            var cmd = "D" + SwitchPin + ":" + pinValue;

            SendDeviceCommand(cmd);

            var pinOutputValue = SimulatorClient.DigitalRead(SwitchPin);

            Assert.AreEqual(state, pinOutputValue, "Pin output is incorrect.");
        }
        public void ToggleSwitch()
        {
            SwitchState = !SwitchState;

            var cmd = "T" + SwitchPin;

            SendDeviceCommand(cmd);

            var pinOutputValue = SimulatorClient.DigitalRead(SwitchPin);

            Assert.AreEqual(SwitchState, pinOutputValue, "Pin output is incorrect.");
        }
        public virtual void ResetDeviceViaPin()
        {
            // Close the connection to the device
            DisconnectDevice();

            // Set the reset trigger pin LOW (false) to begin a reset
            SimulatorClient.DigitalWrite(ResetTriggerPin, false);

            // Give the pin some time at LOW to ensure reset
            Thread.Sleep(10);

            // Change the reset trigger pin to an input to go back to normal
            // TODO: Implement a cleaner way to do this
            SimulatorClient.DigitalRead(ResetTriggerPin);

            // Re-open the connection to the device
            ConnectDevice();

            // Ensure the irrigator restarted
            WaitForText(IrrigatorStartText);
        }
Ejemplo n.º 9
0
 public TreatmentMachineModel(TreatmentMachineId id, SimulatorClient client) : base(client, id)
 {
 }
Ejemplo n.º 10
0
 public TreatmentMachineModel(TreatmentMachineReadModel entity, SimulatorClient client) : base(client, new TreatmentMachineId(entity.Id))
 {
 }
 public SimulatorAuditManager(string orkId, SimulatorClient client)
 {
     _orkId  = orkId;
     _client = client;
 }
Ejemplo n.º 12
0
 public SimulatorManagerCipherBase(string orkId, SimulatorClient client, AesKey key) : base(orkId, client)
 {
     _key = key;
 }
 public DoctorModel(DoctorReadModel entity, SimulatorClient client) : base(client, new DoctorId(entity.Id), entity)
 {
 }
 public ClientModelBase(SimulatorClient client, TId id, TReadModel readModel) : this(client, id)
 {
     this.readModel = readModel;
 }
Ejemplo n.º 15
0
 public TideVendor(TideConfiguration config)
 {
     Config  = config;
     _client = new SimulatorClient(Config.VendorId);
 }
 public SimulatorRuleManager(string orkId, SimulatorClient client, AesKey key) : base(orkId, client, key)
 {
 }
Ejemplo n.º 17
0
 public TemporaryDnsController(Settings settings)
 {
     _client = new SimulatorClient(settings.Endpoints.Simulator.Api, settings.Instance.Username, settings.Instance.GetPrivateKey());
 }
Ejemplo n.º 18
0
 public SimulatorManagerBase(string orkId, SimulatorClient client)
 {
     _orkId  = orkId;
     _client = client;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="simulation"></param>
 public Communicator(SimulatorClient client)
 {
     this.client            = client;
     this.messagingListener = new MessagingListener(this);
 }
Ejemplo n.º 20
0
 protected DomainTestBase(ITestOutputHelper output)
 {
     _output     = output;
     this.Client = SimulationApplication.Create().ConfigureInMemoryStore().Run();
 }
 public SimulatorManagerPublicBase(string orkId, SimulatorClient client) : base(orkId, client)
 {
 }
 public void DisconnectSimulator()
 {
     SimulatorClient.Disconnect();
 }
 public PatientModel(PatientId id, SimulatorClient client) : base(client, id)
 {
 }
 public ClientModelBase(SimulatorClient client, TId id)
 {
     this.Client = client;
     this.Id     = id;
 }
Ejemplo n.º 25
0
 public TreatmentRoomModel(TreatmentRoomId id, SimulatorClient client) : base(client, id)
 {
 }
 public DoctorModel(DoctorId id, SimulatorClient client) : base(client, id)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="simulation"></param>
 public Communicator(SimulatorClient client)
 {
     this.client = client;
     this.messagingListener = new MessagingListener(this);
 }
 public PatientModel(PatientReadModel entity, SimulatorClient client) : base(client, new PatientId(entity.Id), entity)
 {
 }
 public bool SimulatorDigitalRead(int pinNumber)
 {
     return(SimulatorClient.DigitalRead(pinNumber));
 }
 public SimulatorDnsManager(SimulatorClient client) : base("Dns", client)
 {
 }
Ejemplo n.º 31
0
 public TreatmentRoomModel(TreatmentRoomReadModel readModel, SimulatorClient client) : base(client, new TreatmentRoomId(readModel.Id.Value), readModel)
 {
 }