public Task <ICollection <Device> > HandleAsync(DeviceQuery query, CancellationToken cancellationToken) { return(_deviceService .FindDevices(query.Request) .LogInfo(_logger, result => $"got {result.Count} devices") .LogException(_logger) .ToTask(cancellationToken)); }
public ActionResult <QueryResult <DeviceInfo> > GetDevices([FromQuery] bool?supportsSync, [FromQuery] Guid?userId) { var deviceQuery = new DeviceQuery { SupportsSync = supportsSync, UserId = userId ?? Guid.Empty }; return(_deviceManager.GetDevices(deviceQuery)); }
public void TimeOutQuery() { var queryRequestor = CreateTestProbe(); var temp1 = CreateTestProbe(); var temp2 = CreateTestProbe(); var deviceQuery = Sys.ActorOf(DeviceQuery.Props( actorRefToDeviceIdMap: new Dictionary <IActorRef, string> { [temp1.Ref] = "123", [temp2.Ref] = "456" }, correlationId: 1, sender: queryRequestor.Ref, queryTimeout: TimeSpan.FromSeconds(3) )); temp1.ExpectMsg <SystemEvent>((m, sender) => { Assert.Equal(1, m.CorrelationId); Assert.Equal(deviceQuery, sender); }); temp2.ExpectMsg <SystemEvent>((m, sender) => { Assert.Equal(1, m.CorrelationId); Assert.Equal(deviceQuery, sender); }); deviceQuery.Tell(new SystemEvent( SystemEventTypesEnum.RespondDeviceDetails, 1, new DeviceDetailsPayload { Devices = new List <DeviceDetails> { new DeviceDetails { DeviceId = "123", IsOnline = true } } }), temp1.Ref ); var response = queryRequestor.ExpectMsg <SystemEvent>(TimeSpan.FromSeconds(5)); var data = response.Payload as DeviceDetailsPayload; Assert.Equal(1, response.CorrelationId); Assert.Single(data.Devices); var temp1Reading = Assert.IsAssignableFrom <bool>(data.Devices.Where(x => x.DeviceId.Equals("123")).FirstOrDefault().IsOnline); Assert.True(temp1Reading); var temp2Reading = Assert.IsAssignableFrom <int>(data.Devices.Where(x => x.DeviceId.Equals("456")).Count()); Assert.Equal(0, temp2Reading); }
public string readCard() { if (!device.connected()) { bool success = device.connect(this.reader); if (!success) { return("Device not connected"); } } DeviceQuery query = device.select(); if (!query.authenticate(new byte[6] { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5 }, 0x08)) { return("Authentication failed"); } byte[] read = query.readBlock(0x08); if (read == null) { return(null); } string val = ""; foreach (var b in read) { byte bcd = b; ulong p = (ulong)((bcd >> 0x04) * 10 + (bcd & 0x0F)); if (p < 10) { val += "0"; } val += p; } char[] arr = val.ToCharArray(); Array.Reverse(arr); val = new string(arr); //val = val.TrimStart('0'); val = val.Substring(6, 8); char[] cardNo = new char[8]; Array.Copy(val.ToCharArray(), 0, cardNo, 0, 8); device.disconnect(); SendKeys.SendWait("72{ENTER}"); System.Threading.Thread.Sleep(1000); SendKeys.SendWait(new string(cardNo)); //SendKeys.SendWait("{ENTER}"); return(new string(cardNo)); }
public BSAction CreateAction(string functionName, Device device, DeviceQuery query = null) { BSAction node = new BSAction() { m_scheme = this }; node.SetAction(device.GetFunction(functionName), query); m_nodes.Add(node); return(node); }
/// <summary> /// Map to Query object. /// </summary> /// <param name="data">device query</param> /// <returns>Query</returns> public static Query Map(DeviceQuery data) { var query = new Query { CreatedAt = data.CreatedAt, Id = data.Id, Name = data.Name, Filter = new Filter(data.Query), UpdatedAt = data.UpdatedAt }; return(query); }
public int PartialUpdate([FromRoute] string id, [FromBody] JsonMergePatchDocument <Device> patch) { Guid docId = new Guid(id); var ops = new List <string>(); patch.Operations.ForEach(op => { ops.Add(op.path.TrimStart('/')); }); var data = new Device(); patch.ApplyTo(data); var query = new DeviceQuery(); return(query.PartialUpdate(docId, data, ops)); }
public QueryResult <DeviceInfo> GetDevices(DeviceQuery query) { IEnumerable <DeviceInfo> devices = _repo.GetDevices().OrderByDescending(i => i.DateLastModified); if (query.SupportsContentUploading.HasValue) { var val = query.SupportsContentUploading.Value; devices = devices.Where(i => GetCapabilities(i.Id).SupportsContentUploading == val); } if (query.SupportsSync.HasValue) { var val = query.SupportsSync.Value; devices = devices.Where(i => GetCapabilities(i.Id).SupportsSync == val); } if (query.SupportsPersistentIdentifier.HasValue) { var val = query.SupportsPersistentIdentifier.Value; devices = devices.Where(i => { var caps = GetCapabilities(i.Id); var deviceVal = caps.SupportsPersistentIdentifier; return(deviceVal == val); }); } if (!string.IsNullOrWhiteSpace(query.UserId)) { devices = devices.Where(i => CanAccessDevice(query.UserId, i.Id)); } var array = devices.ToArray(); return(new QueryResult <DeviceInfo> { Items = array, TotalRecordCount = array.Length }); }
public Device[] GetCoveredItems(int QuoteID) { QuoteQuery quotequery = new QuoteQuery() { ID = QuoteID }; EWS.Domain.Data.DataModel.Quote quote = _queryProcessor.Execute(quotequery); DeviceQuery devicequery = new DeviceQuery() { DeviceID = quote.DeviceID }; EWS.Domain.Model.Device device = _queryProcessor.Execute(devicequery); return(new Device[1] { device }); //Todo finish this so it returns the individual components }
public QueryResult <DeviceInfo> GetDevices(DeviceQuery query) { IEnumerable <DeviceInfo> devices = _repo.GetDevices(); if (query.SupportsSync.HasValue) { var val = query.SupportsSync.Value; devices = devices.Where(i => i.Capabilities.SupportsSync == val); } if (query.SupportsPersistentIdentifier.HasValue) { var val = query.SupportsPersistentIdentifier.Value; devices = devices.Where(i => { var deviceVal = i.Capabilities.SupportsPersistentIdentifier; return(deviceVal == val); }); } if (!string.IsNullOrEmpty(query.UserId)) { var user = _userManager.GetUserById(query.UserId); devices = devices.Where(i => CanAccessDevice(user, i.Id)); } var array = devices.ToArray(); return(new QueryResult <DeviceInfo> { Items = array, TotalRecordCount = array.Length }); }
private static Ship GeneratePatrolShip() { Ship ship = new Ship(0.3f) { EntityName = "patrolship" }; GameObject[] markers = new GameObject[] { new GameObject("Marker1", typeof(TransformMarker)), new GameObject("Marker2", typeof(TransformMarker)), new GameObject("Marker3", typeof(TransformMarker)), new GameObject("Marker4", typeof(TransformMarker)), }; markers[0].transform.position = Vector3.right * 15f; markers[1].transform.position = Vector3.left * 15f; markers[2].transform.position = Vector3.forward * 15f; markers[3].transform.position = Vector3.back * 15f; DEngine engine = new DEngine() { EntityName = "engine", m_lookDirection = Vector3.forward, m_space = Space.Self }; DSteerModule steerer = new DSteerModule() { EntityName = "steerer" }; DPatrolModule patrol = new DPatrolModule() { EntityName = "patrol", m_patrolPoints = new Vector3[] { markers[0].transform.position, markers[1].transform.position, markers[2].transform.position, markers[3].transform.position } }; DLauncher launcher = new DLauncher() { EntityName = "launcher", m_projectileName = "Missile" }; DRanger enemydetector = new DRanger() { EntityName = "enemydetector", detectionRange = 5f }; DMagnet magnet = new DMagnet(); DTradeComputer trader = new DTradeComputer(); ship.IntegratedDevice.IntegrateDevice(trader); ship.IntegratedDevice.IntegrateDevice(engine); ship.IntegratedDevice.IntegrateDevice(steerer); ship.IntegratedDevice.IntegrateDevice(patrol); ship.IntegratedDevice.IntegrateDevice(enemydetector); ship.IntegratedDevice.IntegrateDevice(launcher); ship.IntegratedDevice.IntegrateDevice(magnet); BSBranch rootDecision = ship.IntegratedDevice.Blueprint.CreateBranch(); BSSequence patrolSequence = ship.IntegratedDevice.Blueprint.CreateSequence(); BSAction disableEngine = ship.IntegratedDevice.Blueprint.CreateAction("DeactivateDevice", engine); BSAction steerTowardsTarget = ship.IntegratedDevice.Blueprint.CreateAction("SteerTowards", steerer, patrol.GetQuery("CurrentTarget")); BSAction enableEngine = ship.IntegratedDevice.Blueprint.CreateAction("ActivateDevice", engine); BSAction waitUntilReach = ship.IntegratedDevice.Blueprint.CreateAction("ReachTarget", patrol, patrol.GetQuery("CurrentTarget")); BSAction nextPoint = ship.IntegratedDevice.Blueprint.CreateAction("SetNextPoint", patrol); BSBranch miningDecision = ship.IntegratedDevice.Blueprint.CreateBranch(); miningDecision.AddCondition(magnet.GetCheck("IsStorageble"), enemydetector.GetQuery("CurrentTargetContainer")); BSSequence shootingSequence = ship.IntegratedDevice.Blueprint.CreateSequence(); BSAction steerTowardsShootingTarget = ship.IntegratedDevice.Blueprint.CreateAction("SteerTowards", steerer, enemydetector.GetQuery("CurrentTargetPosition")); BSAction shootTarget = ship.IntegratedDevice.Blueprint.CreateAction("Fire", launcher); BSSequence collectingSequence = ship.IntegratedDevice.Blueprint.CreateSequence(); BSAction attractAsteroid = ship.IntegratedDevice.Blueprint.CreateAction("Attract", magnet, enemydetector.GetQuery("CurrentTargetContainer")); BSAction storageAsteroid = ship.IntegratedDevice.Blueprint.CreateAction("Load", magnet, enemydetector.GetQuery("CurrentTargetContainer")); DeviceQuery tradeInfo = () => { return(ship.m_cargo.ComposeTradeOffer("Asteroid")); }; DeviceQuery stationPosition = () => { return(new PositionArgs() { position = WorldManager.RequestContainerData("MotherBase").View.transform.position }); }; Device stationTrader = WorldManager.RequestContainerData("MotherBase").IntegratedDevice.GetInternalDevice("trader"); BSSequence goingHomeSequence = ship.IntegratedDevice.Blueprint.CreateSequence(); BSAction steerTowardsHome = ship.IntegratedDevice.Blueprint.CreateAction("SteerTowards", steerer, stationPosition); BSAction waitUntilReachHome = ship.IntegratedDevice.Blueprint.CreateAction("ReachTarget", patrol, stationPosition); BSAction sellResouces = ship.IntegratedDevice.Blueprint.CreateAction("LoadItemsFrom", stationTrader, tradeInfo); // interupt current commands stack // enemydetector.AddEvent("OnRangerEntered", ship.IntegratedDevice.Blueprint.InterruptExecution); ship.IntegratedDevice.Blueprint.m_entryPoint.AddChild(rootDecision); rootDecision.AddCondition(enemydetector.GetCheck("IsAnyTarget")); rootDecision.AddCondition(ship.IntegratedDevice.GetCheck("IsCargoFull")); rootDecision.AddChild(miningDecision); rootDecision.AddChild(goingHomeSequence); rootDecision.AddChild(patrolSequence); miningDecision.AddChild(collectingSequence); miningDecision.AddChild(shootingSequence); collectingSequence.AddChild(storageAsteroid); collectingSequence.AddChild(attractAsteroid); collectingSequence.AddChild(disableEngine); shootingSequence.AddChild(shootTarget); shootingSequence.AddChild(steerTowardsShootingTarget); shootingSequence.AddChild(disableEngine); patrolSequence.AddChild(nextPoint); patrolSequence.AddChild(waitUntilReach); patrolSequence.AddChild(enableEngine); patrolSequence.AddChild(steerTowardsTarget); patrolSequence.AddChild(disableEngine); goingHomeSequence.AddChild(sellResouces); goingHomeSequence.AddChild(waitUntilReachHome); goingHomeSequence.AddChild(enableEngine); goingHomeSequence.AddChild(steerTowardsHome); goingHomeSequence.AddChild(disableEngine); ContainerView shipView = WorldManager.SpawnContainer(ship, Vector3.zero, Quaternion.identity, 2); return(ship); }
public void AddScheduledEvent(DeviceEvent evt, DeviceQuery data) { scheduledEventsList.Add(evt); scheduledEventsDataList.Add(data); }
public IEnumerable <Device> Page([FromBody] PageRequest pageDoc) { var query = new DeviceQuery(); return(query.GetPage(pageDoc.Page, pageDoc.PageSize, new System.DateTime())); }
public void Insert([FromBody] Device data) { var q = new DeviceQuery(); q.Insert(data); }
public void InsertList([FromBody] List <Device> data) { var q = new DeviceQuery(); q.Insert(data); }
public int Update([FromBody] Device data) { var q = new DeviceQuery(); return(q.Update(data)); }
public Device Get([FromRoute] string id) { var query = new DeviceQuery(); return(query.GetSingle(new Guid(id))); }
public void AddQuery(string name, DeviceQuery query) { m_queries.Add(name, query); }
public async Task <QueryResult <DeviceQueryRow> > QueryDevice( DeviceQueryFilter filter = null, DeviceQuerySort sort = null, DeviceQueryProjection projection = null, DeviceQueryPaging paging = null, DeviceQueryOptions options = null) { var conn = context.Database.GetDbConnection(); var openConn = conn.OpenAsync(); var query = DeviceQuery.CreateDynamicSql(); #region General if (filter != null) { query = query.SqlFilter(filter); } if (projection != null) { query = query.SqlJoin(projection); } DynamicSql countQuery = null; int?totalCount = null; Task <int> countTask = null; if (options != null && options.count_total) { countQuery = query.SqlCount("*"); } if (projection != null) { query = query.SqlProjectFields(projection); } #endregion await openConn; if (options != null && !options.single_only) { #region List query if (sort != null) { query = query.SqlSort(sort); } if (paging != null && (!options.load_all || !DeviceQueryOptions.IsLoadAllAllowed)) { query = query.SqlSelectPage(paging.page, paging.limit); } #endregion #region Count query if (options.count_total) { countTask = conn.ExecuteScalarAsync <int>( sql: countQuery.PreparedForm, param: countQuery.DynamicParameters); } #endregion } var queryResult = await conn.QueryAsync( sql : query.PreparedForm, types : query.GetTypesArr(), map : (objs) => ProcessMultiResults(query, objs), splitOn : string.Join(',', query.GetSplitOns()), param : query.DynamicParameters); if (options != null && options.single_only) { var single = queryResult.FirstOrDefault(); return(new QueryResult <DeviceQueryRow> { SingleResult = single }); } if (options != null && options.count_total) { totalCount = await countTask; } return(new QueryResult <DeviceQueryRow> { Results = queryResult, TotalCount = totalCount }); }
public BalanzaController(BalanzasEntities db, DeviceQuery deviceQuery, SysLogger logger) { _db = db; _deviceQuery = deviceQuery; _logger = logger; }
public void ScheduleEvent(DeviceEvent evt, DeviceQuery data = null) { Blueprint.AddScheduledEvent(evt, data); }
public int Remove([FromBody] Device data) { var q = new DeviceQuery(); return(q.Remove(data)); }