/// <summary> /// The basic system object, sets up the connection to the serial port. /// </summary> /// <param name="portName"></param> public FluffInsteon(string portName, DeviceProvider provider) { this.port = new CommunicationDevice(new SerialPort(portName, 19000, Parity.None, 8, StopBits.One)); this.port.ReceivedMessage += port_ReceivedMessage; this.linkingEvent = new AutoResetEvent(false); this.deviceFactory = new DeviceFactory(this); this.provider = provider; log.Info("Started FluffInsteon up"); }
/// <summary> /// The basic system object, sets up the connection to the serial port. /// </summary> /// <param name="portName"></param> public FluffInsteon(string portName, DeviceProvider provider) { this.port = new CommunicationDevice(new SerialPort(portName, 19000, Parity.None, 8, StopBits.One)); this.port.ReceivedMessage += port_ReceivedMessage; this.linkingEvent = new AutoResetEvent(false); this.deviceFactory = new DeviceFactory(this); this.provider = provider; log.Info("Started FluffInsteon up"); }
public static IWavePlayer CreateOrGetDefaultDevice(out IDeviceInfo actualDeviceInfo) { var play = AppSettings.Default?.Play; if (play != null) { return(DeviceProvider.CreateDevice(out actualDeviceInfo, play.DeviceInfo, play.DesiredLatency, play.IsExclusive)); } return(DeviceProvider.CreateDevice(out actualDeviceInfo)); }
private void OnUpdateAllPinpads(object sender, RoutedEventArgs e) { this.Authorizers = DeviceProvider.ActivateAndGetAll(this.stoneCode, this.PinpadMessages); this.uxCbbxAllPinpads.Items.Clear(); foreach (ICardPaymentAuthorizer c in this.Authorizers) { this.uxCbbxAllPinpads.Items.Add(c.PinpadFacade.Infos.SerialNumber); } }
public override void Initialize() { var deviceProvider = new DeviceProvider(); Mvx.RegisterSingleton <IDeviceProvider>(deviceProvider); var notificationsProvider = new NotificationsProvider(); Mvx.RegisterSingleton <INotificationsProvider>(notificationsProvider); Mvx.RegisterSingleton <IUserDialogs>(UserDialogs.Instance); //db string externalDirPath = deviceProvider.DataPath(); string dbPath = PortablePath.Combine(externalDirPath, FilesNames.databaseFile); var dbConnectionFactory = new DbConnectionFactory(dbPath); Mvx.RegisterSingleton <IDbConnectionFactory>(dbConnectionFactory); var storageProvider = new StorageProvider(Mvx.Resolve <IDeviceProvider>(), Mvx.Resolve <IDbConnectionFactory>()); Mvx.RegisterSingleton <IStorageProvider>(storageProvider); var sessionProvider = new SessionProvider(Mvx.Resolve <IStorageProvider>()); Mvx.RegisterSingleton <ISessionProvider>(sessionProvider); //api interfaces var carrierOrdersApi = RestService.For <ICarrierOrdersApi>(sessionProvider.HttpClient); Mvx.RegisterSingleton <ICarrierOrdersApi>(carrierOrdersApi); var routesApi = RestService.For <IRoutesApi>(sessionProvider.HttpClient); Mvx.RegisterSingleton <IRoutesApi>(routesApi); var salepointOrdersApi = RestService.For <ISalepointOrdersApi>(sessionProvider.HttpClient); Mvx.RegisterSingleton <ISalepointOrdersApi>(salepointOrdersApi); //services var carrierOrdersService = new CarrierOrdersService(Mvx.Resolve <ICarrierOrdersApi>(), Mvx.Resolve <INotificationsProvider>()); Mvx.RegisterSingleton <ICarrierOrdersService>(carrierOrdersService); var salepointOrdersService = new SalepointOrdersService(Mvx.Resolve <ISalepointOrdersApi>(), Mvx.Resolve <IStorageProvider>(), Mvx.Resolve <INotificationsProvider>()); Mvx.RegisterSingleton <ISalepointOrdersService>(salepointOrdersService); var routesService = new RoutesService(Mvx.Resolve <IRoutesApi>(), Mvx.Resolve <INotificationsProvider>(), Mvx.Resolve <ISessionProvider>()); Mvx.RegisterSingleton <IRoutesService>(routesService); RegisterNavigationServiceAppStart <SignInViewModel>(); }
public async Task <ActionResult> Add(DeviceAddModel model) { try { var provider = new DeviceProvider(DomainSession.GetDataContextForUserContext(this.HttpContext)); model.Result = StatusResponseGenerator.GetStatusResponseResultForReturnParam(provider.Add(model.Device, model.LocationId, model.TypeId, model.DeviceSiteId)); return(View(model)); } catch (Exception e) { return(View()); } }
public ActionResult Index(int ServerId) { try { var provider = new DeviceProvider(DomainSession.GetDataContextForUserContext(this.HttpContext)); DeviceViewModel model = new DeviceViewModel(provider.GetById(ServerId)); return(View(model)); } catch (Exception e) { return(View()); } }
/// <summary> /// Disposes this object. /// </summary> public void Dispose() { this.linkingEvent.Dispose(); this.port.Dispose(); this.devices.Clear(); this.devices = null; this.deviceFactory = null; this.linkedDevices = null; this.linkingEvent = null; this.plm = null; this.port = null; this.provider = null; this.receivedPacket = null; this.sendingPacket = null; this.connected = false; }
public DeviceProviderTests() { var iDeviceEnumMock = new Mock <IDeviceEnumerator>(); deviceStateNotifMock = new Mock <IDeviceStateNotificationHandler>(); defaultDevice = OutputDeviceModelTests.GetDeviceMock("111", "speakers", this.deviceStateNotifMock.Object); var device = OutputDeviceModelTests.GetDeviceMock("123", "device", this.deviceStateNotifMock.Object); var devices = new List <OutputDeviceModel> { defaultDevice, device }; iDeviceEnumMock.Setup(m => m.GetCurrentActiveDevices(deviceStateNotifMock.Object)).Returns(devices); iDeviceEnumMock.Setup(m => m.GetDefaultDeviceId()).Returns(defaultDevice.Id); model = GetDeviceProviderMock(iDeviceEnumMock.Object, deviceStateNotifMock.Object); }
internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider, DeviceEntity deviceEntity) { Identifier = rgbDevice.GetDeviceIdentifier(); DeviceEntity = deviceEntity; RgbDevice = rgbDevice; DeviceProvider = deviceProvider; InputIdentifiers = new List <ArtemisDeviceInputIdentifier>(); InputMappings = new Dictionary <ArtemisLed, ArtemisLed>(); foreach (DeviceInputIdentifierEntity identifierEntity in DeviceEntity.InputIdentifiers) { InputIdentifiers.Add(new ArtemisDeviceInputIdentifier(identifierEntity.InputProvider, identifierEntity.Identifier)); } UpdateLeds(); ApplyKeyboardLayout(); }
internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider, DeviceEntity deviceEntity) { Identifier = rgbDevice.GetDeviceIdentifier(); DeviceEntity = deviceEntity; RgbDevice = rgbDevice; DeviceProvider = deviceProvider; InputIdentifiers = new List <ArtemisDeviceInputIdentifier>(); foreach (DeviceInputIdentifierEntity identifierEntity in DeviceEntity.InputIdentifiers) { InputIdentifiers.Add(new ArtemisDeviceInputIdentifier(identifierEntity.InputProvider, identifierEntity.Identifier)); } Leds = rgbDevice.Select(l => new ArtemisLed(l, this)).ToList().AsReadOnly(); LedIds = new ReadOnlyDictionary <LedId, ArtemisLed>(Leds.ToDictionary(l => l.RgbLed.Id, l => l)); ApplyKeyboardLayout(); }
/// <summary> /// Creates all pinpad messages. /// Establishes connection with the pinpad. /// </summary> public PizzaAuthorizer() { this.BoughtPizzas = new Collection <IAuthorizationReport>(); // Creates all pinpad messages: this.PizzaMachineMessages = new DisplayableMessages(); this.PizzaMachineMessages.ApprovedMessage = "Aprovado, nham!"; this.PizzaMachineMessages.DeclinedMessage = "Nao autorizada"; this.PizzaMachineMessages.InitializationMessage = "olá..."; this.PizzaMachineMessages.MainLabel = "pizza machine"; this.PizzaMachineMessages.ProcessingMessage = "assando pizza..."; // Establishes connection with the pinpad. Microtef.Platform.Desktop.DesktopInitializer.Initialize(); this.authorizer = DeviceProvider.ActivateAndGetOneOrFirst(this.StoneCode, this.PizzaMachineMessages); // Attach event to read all transaction status: this.authorizer.OnStateChanged += this.OnStatusChange; }
public static ICollection <GasStationAuthorizer> CreateAll() { ICollection <ICardPaymentAuthorizer> authorizers = DeviceProvider.ActivateAndGetAll(StoneCode, new DisplayableMessages() { ApprovedMessage = "Aprovada", DeclinedMessage = "Negada", InitializationMessage = "Iniciando...", MainLabel = "Stone Pagamentos", ProcessingMessage = "Processando..." }); if (authorizers == null || authorizers.Count <= 0) { return(null); } ICollection <GasStationAuthorizer> gasAuthorizers = new List <GasStationAuthorizer>(); foreach (ICardPaymentAuthorizer authorizer in authorizers) { gasAuthorizers.Add(new GasStationAuthorizer(authorizer)); } return(gasAuthorizers); }
public async Task <ActionResult> Edit(DeviceEditModel model) { try { if (model.Device != null) { var provider = new DeviceProvider(DomainSession.GetDataContextForUserContext(this.HttpContext)); model.Result = StatusResponseGenerator.GetStatusResponseResultForReturnParam(provider.Update(model.Device)); return(View(model)); } else { model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure); } } catch (Exception e) { model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure); } return(View(model)); }
/// <summary> /// Try to connect to the pinpad. /// </summary> /// <param name="activation">Data to connect to the pinpad.</param> /// <returns>True if the pinpad was found and connected.</returns> public bool TryActivate(ActivateOption activation) { try { // Tries to connect to one pinpad: this.StoneAuthorizer = DeviceProvider .ActivateAndGetOneOrFirst(activation.StoneCode, null, activation.Port); // Show result: this.StoneAuthorizer.ShowPinpadOnConsole(); } catch (PinpadNotFoundException) { Console.WriteLine("Pinpad nao encontrado."); } catch (Exception) { Console.WriteLine("Erro ao ativar o terminal. Você está usando o StoneCode correto?"); } return(this.IsUsable); }
internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider) { Identifier = rgbDevice.GetDeviceIdentifier(); DeviceEntity = new DeviceEntity(); RgbDevice = rgbDevice; DeviceProvider = deviceProvider; Rotation = 0; Scale = 1; ZIndex = 1; RedScale = 1; GreenScale = 1; BlueScale = 1; IsEnabled = true; InputIdentifiers = new List <ArtemisDeviceInputIdentifier>(); InputMappings = new Dictionary <ArtemisLed, ArtemisLed>(); UpdateLeds(); ApplyKeyboardLayout(); ApplyToEntity(); CalculateRenderProperties(); }
internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider) { Identifier = rgbDevice.GetDeviceIdentifier(); DeviceEntity = new DeviceEntity(); RgbDevice = rgbDevice; DeviceProvider = deviceProvider; Rotation = 0; Scale = 1; ZIndex = 1; RedScale = 1; GreenScale = 1; BlueScale = 1; IsEnabled = true; InputIdentifiers = new List <ArtemisDeviceInputIdentifier>(); Leds = rgbDevice.Select(l => new ArtemisLed(l, this)).ToList().AsReadOnly(); LedIds = new ReadOnlyDictionary <LedId, ArtemisLed>(Leds.ToDictionary(l => l.RgbLed.Id, l => l)); ApplyKeyboardLayout(); ApplyToEntity(); CalculateRenderProperties(); }