コード例 #1
0
 private static void AddConnectedSchemeSymbols(DeviceGroup deviceGroup, Dictionary<int, ISchemeSymbol> symbolById, Dictionary<int, List<int>> symbolIdsByCableId, Dictionary<int, List<int>> deviceGroupIdsByCableId, Dictionary<int, DeviceGroup> deviceGroupById, string connectingBoxAssignment, string assignment, ref int schemeSymbolId, E3Text text)
 {
     if (symbolById.ContainsKey(deviceGroup.Id))
         return;
     symbolById.Add(deviceGroup.Id, deviceGroup);
     foreach (int cableId in deviceGroup.CableIds)
     {
         if (symbolIdsByCableId.ContainsKey(cableId))
             continue;
         List<int> ids = deviceGroupIdsByCableId[cableId];
         int mateId = (ids.First() == deviceGroup.Id) ? ids.Last() : ids.First();
         DeviceGroup mateGroup = deviceGroupById[mateId];
         if (symbolById.ContainsKey(mateId))
         {
             if (String.IsNullOrEmpty(mateGroup.Assignment) || mateGroup.Assignment.Equals(connectingBoxAssignment) || mateGroup.Assignment.Equals(assignment))
                 symbolIdsByCableId.Add(cableId, ids);
             continue;
         }
         symbolIdsByCableId.Add(cableId, new List<int>(2) { deviceGroup.Id });
         if (String.IsNullOrEmpty(mateGroup.Assignment) || mateGroup.Assignment.Equals(connectingBoxAssignment) || mateGroup.Assignment.Equals(assignment))
         {
             AddConnectedSchemeSymbols(mateGroup, symbolById, symbolIdsByCableId, deviceGroupIdsByCableId, deviceGroupById, connectingBoxAssignment, assignment, ref schemeSymbolId,text);
             symbolIdsByCableId[cableId].Add(mateId);
             //schemeSymbolById.Add(mateId, deviceGroupById[mateId]);
         }
         else
         {
             symbolById.Add(schemeSymbolId, new AssignmentReferenceSymbol(mateGroup.Assignment, schemeSymbolId, cableId, text));
             symbolIdsByCableId[cableId].Add(schemeSymbolId);
             schemeSymbolId++;
         }
     }
 }
コード例 #2
0
        public void Device_group_should_ignore_device_registration_requests_with_wrong_group_id()
        {
            var probe      = CreateTestProbe();
            var groupActor = Sys.ActorOf(DeviceGroup.Props("Group1"));

            groupActor.Tell(new RequestTrackDevice("Group2", "Device1"), probe.Ref);
            probe.ExpectNoMsg(TimeSpan.FromMilliseconds(value: 500));
        }
コード例 #3
0
        public Guid AddDeviceGroup(string Title, DeviceIoType deviceIoType)
        {
            var deviceGroup = new DeviceGroup(Title);

            GetDeviceGroupList(deviceIoType).Add(deviceGroup);
            Context.ContextChanged();
            return(deviceGroup.Guid);
        }
コード例 #4
0
 public bool AddDeviceGroup(DeviceGroup group)
 {
     if (group != null && group.Telemetries != null && group.Telemetries.Length == 1)
     {
         group.Telemetries = group.Telemetries[0].Split(',');
     }
     return(dataService.InsertGroup(group));
 }
コード例 #5
0
            public void DeviceGroup_actor_must_ignore_requests_for_wrong_groupId()
            {
                var probe      = CreateTestProbe();
                var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));

                groupActor.Tell(new RequestTrackDevice("wrongGroup", "device1"), probe.Ref);
                probe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
            }
コード例 #6
0
        public bool RenameDeviceGroup(Guid deviceGroupGuid, DeviceIoType deviceIoType, string title)
        {
            var deviceGroups = GetDeviceGroupList(deviceIoType);

            DeviceGroup.FindDeviceGroup(deviceGroups, deviceGroupGuid).Title = title;
            Context.ContextChanged();
            return(true);
        }
コード例 #7
0
        public async Task <DeviceGroup> UpdateDeviceGroupAsync(string id, DeviceGroup input, string etag)
        {
            var value = JsonConvert.SerializeObject(input, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var response = await this.client.UpdateAsync(DEVICE_GROUP_COLLECTION_ID, id, value, etag);

            return(this.CreateGroupServiceModel(response));
        }
コード例 #8
0
        public bool InsertDeviceGroupFileOnly(DeviceGroup group)
        {
            string             relativePath = $"{folderPathToStoreInfo}\\{groupPath}{format}";
            List <DeviceGroup> groups       = this.GetAllDeviceGroupsForced();

            groups.Add(group);
            File.WriteAllText(relativePath, JsonConvert.SerializeObject(groups));
            return(true);
        }
コード例 #9
0
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            DeviceGroup deviceGroup = await db.DeviceGroups.FindAsync(id);

            db.DeviceGroups.Remove(deviceGroup);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #10
0
 // POST api/<controller>
 public void Post([FromBody] DeviceGroup value)
 {
     if (value == null)
     {
         return;
     }
     DeviceContext.Instance.DeviceGroups.AddOrUpdate(value);
     DeviceContext.Instance.SaveChanges();
 }
コード例 #11
0
        public async Task <DeviceGroup> CreateDeviceGroupAsync(DeviceGroup input)
        {
            var value = JsonConvert.SerializeObject(input, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var response = await this.client.CreateAsync(DEVICE_GROUP_COLLECTION_ID, value);

            return(this.CreateGroupServiceModel(response));
        }
コード例 #12
0
        private async Task DeleteDeviceGroupToADX(DeviceGroup deviceGroup)
        {
            bool isKustoEnabled = this.config.DeviceTelemetryService.Messages.TelemetryStorageType.Equals(Common.Services.Models.TelemetryStorageTypeConstants.Ade, StringComparison.OrdinalIgnoreCase);

            if (isKustoEnabled)
            {
                await this.AddDeviceGroupToADX(deviceGroup, true);
            }
        }
コード例 #13
0
        public async Task UpdateDeviceGroupAsyncTest()
        {
            var groupId     = this.rand.NextString();
            var displayName = this.rand.NextString();
            var conditions  = new List <DeviceGroupCondition>()
            {
                new DeviceGroupCondition()
                {
                    Key      = this.rand.NextString(),
                    Operator = OperatorType.EQ,
                    Value    = this.rand.NextString(),
                },
            };
            var etagOld = this.rand.NextString();
            var etagNew = this.rand.NextString();

            var group = new DeviceGroup
            {
                DisplayName = displayName,
                Conditions  = conditions,
            };

            this.mockClient
            .Setup(x => x.UpdateAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new ValueApiModel
            {
                Key  = groupId,
                Data = JsonConvert.SerializeObject(group),
                ETag = etagNew,
            });

            var result = await this.storage.UpdateDeviceGroupAsync(groupId, group, etagOld);

            this.mockClient
            .Verify(
                x => x.UpdateAsync(
                    It.Is <string>(s => s == Storage.DeviceGroupCollectionId),
                    It.Is <string>(s => s == groupId),
                    It.Is <string>(s => s == JsonConvert.SerializeObject(group, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            })),
                    It.Is <string>(s => s == etagOld)),
                Times.Once);

            this.mockAsaManager
            .Verify(
                x => x.BeginDeviceGroupsConversionAsync(),
                Times.Once);

            Assert.Equal(result.Id, groupId);
            Assert.Equal(result.DisplayName, displayName);
            Assert.Equal(result.Conditions.First().Key, conditions.First().Key);
            Assert.Equal(result.Conditions.First().Operator, conditions.First().Operator);
            Assert.Equal(result.Conditions.First().Value, conditions.First().Value);
            Assert.Equal(result.ETag, etagNew);
        }
コード例 #14
0
ファイル: DeviceDocument.cs プロジェクト: cdy816/Spider
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="childGroupName"></param>
        /// <returns></returns>
        public bool HasChildGroup(DeviceGroup parent, string childGroupName)
        {
            var vss = this.mDeviceGroups.Values.Where(e => e.Parent == parent).Select(e => e.Name);

            if (vss.Count() > 0 && vss.Contains(childGroupName))
            {
                return(true);
            }
            return(false);
        }
コード例 #15
0
        public async Task DeleteDeviceGroupAsync(string id)
        {
            DeviceGroup deviceGroup = await this.GetDeviceGroupAsync(id);

            await this.client.DeleteAsync(DeviceGroupCollectionId, id);

            await this.DeleteDeviceGroupToADX(deviceGroup);

            await this.asaManager.BeginDeviceGroupsConversionAsync();
        }
コード例 #16
0
        static async Task ResetFlow(DeviceGroup devices, int brightness)
        {
            ColorFlow flow = new(0, ColorFlowEndAction.Keep) {
                new ColorFlowTemperatureExpression(4500, brightness, 1000)
            };

            await devices.StopColorFlow();

            await devices.StartColorFlow(flow);
        }
コード例 #17
0
        public HttpResponseMessage Post([FromBody] DeviceGroup deviceGroupInfo)
        {
            return(ActionWarpper.Process(deviceGroupInfo, OperationCodes.ADVG, () =>
            {
                var repo = RepositoryManager.GetRepository <IDeviceGroupRepository>();
                repo.Insert(deviceGroupInfo);

                return Request.CreateResponse(HttpStatusCode.OK, deviceGroupInfo);
            }, this));
        }
コード例 #18
0
        public CommandResult Delete(DeviceGroup info)
        {
            List <DeviceGroup> depts    = ProviderFactory.Create <IDeviceGroupProvider>(_RepoUri).GetItems(null).QueryObjects;
            IUnitWork          unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);

            foreach (DeviceGroup dept in depts.Where(item => item.ID.IndexOf(info.ID, 0) == 0))
            {
                ProviderFactory.Create <IDeviceGroupProvider>(_RepoUri).Delete(dept, unitWork);
            }
            return(unitWork.Commit());
        }
コード例 #19
0
        public bool RemoveDeviceGroup(Guid deviceGroupGuid, DeviceIoType deviceIoType)
        {
            var deviceGroups = GetDeviceGroupList(deviceIoType);

            if (!deviceGroups.Remove(DeviceGroup.FindDeviceGroup(deviceGroups, deviceGroupGuid)))
            {
                return(false);
            }
            Context.ContextChanged();
            return(true);
        }
コード例 #20
0
        public async Task <DeviceGroup> UpdateDeviceGroupAsync(string id, DeviceGroup input, string etag)
        {
            var value = JsonConvert.SerializeObject(input, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var response = await this.client.UpdateAsync(DeviceGroupCollectionId, id, value, etag);

            await this.asaManager.BeginDeviceGroupsConversionAsync();

            return(this.CreateGroupServiceModel(response));
        }
コード例 #21
0
        public HttpResponseMessage Put(int id, [FromBody] DeviceGroup deviceGroupInfo)
        {
            return(ActionWarpper.Process(deviceGroupInfo, OperationCodes.MDVG, () =>
            {
                deviceGroupInfo.DeviceGroupID = id;
                var repo = RepositoryManager.GetRepository <IDeviceGroupRepository>();
                repo.Update(deviceGroupInfo);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
コード例 #22
0
        private void SetUpInsertBaseDataForMainDb()
        {
            var organization = new Organization
            {
                Name          = "OrganizationName1",
                Address       = "OrganizationAddress1",
                DelegatePhone = "123465789",
                AdminPhone    = "987654321",
                AdminMail     = "*****@*****.**",
                StartDay      = DateTime.Now,
                EndDay        = DateTime.Now,
                Url           = "Organization1.co.jp",
                IsValid       = true,
            };

            _deviceGroup = new DeviceGroup
            {
                Version      = "1.1",
                Os           = "Window10",
                Organization = organization
            };
            _simGroup = new SimGroup
            {
                SimGroupName        = "SimGroup1",
                Organization        = organization,
                PrimaryDns          = "255.0.0.0",
                SecondaryDns        = "255.0.0.1",
                Apn                 = "SimGroupApn1",
                NasIpAddress        = "NasAddress",
                Nw1IpAddressPool    = "Nw1AddressPool",
                Nw1IpAddressRange   = "Nw1AddressRange",
                AuthServerIpAddress = "127.0.0.1",
                Nw1PrimaryDns       = "255.0.0.0",
                Nw1SecondaryDns     = "255.0.0.0"
            };
            _domain = new Domain
            {
                DomainName   = "Domain1",
                Organization = organization,
            };
            _userGroup = new UserGroup
            {
                Domain        = _domain,
                UserGroupName = "UserGroup1"
            };
            _lte = new Lte
            {
                LteName            = "Lte1",
                NwAdapterName      = "LteAdapter1",
                SoftwareRadioState = true
            };
            _mainDbContext.AddRange(organization, _deviceGroup, _domain, _userGroup, _lte);
            _mainDbContext.SaveChanges();
        }
コード例 #23
0
        static async Task RGBFlow(DeviceGroup devices, int brightness)
        {
            ColorFlow flow = new(0, ColorFlowEndAction.Keep) {
                new ColorFlowRGBExpression(255, 0, 0, brightness, 2000),
                new ColorFlowRGBExpression(0, 255, 0, brightness, 2000),
                new ColorFlowRGBExpression(0, 0, 255, brightness, 2000),
            };

            await devices.StopColorFlow();

            await devices.StartColorFlow(flow);
        }
コード例 #24
0
        static DeviceGroup GetDevices()
        {
            var bulbs        = LoadBulbs();
            var devicesGroup = new DeviceGroup();

            foreach (var bulb in bulbs)
            {
                var device = new Device(bulb);
                devicesGroup.Add(device);
            }
            return(devicesGroup);
        }
コード例 #25
0
ファイル: DeviceDocument.cs プロジェクト: cdy816/Spider
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public List <DeviceGroup> GetAllChildGroups(DeviceGroup parent)
        {
            List <DeviceGroup> re = new List <DeviceGroup>();
            var grps = GetGroups(parent);

            re.AddRange(grps);
            foreach (var vv in grps)
            {
                re.AddRange(GetAllChildGroups(vv));
            }
            return(re);
        }
コード例 #26
0
        /// <summary>
        /// Package start
        /// </summary>
        public override void OnStart()
        {
            PackageHost.WriteInfo("Package starting - IsRunning: {0} - IsConnected: {1}", PackageHost.IsRunning, PackageHost.IsConnected);

            //parallel connection to the devices
            PackageHost.GetSettingAsJsonObject <IEnumerable <DeviceConfig> >("Devices").AsParallel().ForAll(dc =>
            {
                //create new device and connect
                Device device = new Device(dc.Hostname, dc.Port)
                {
                    Name = dc.Name
                };
                try
                {
                    if (device.Connect().Result)
                    {
                        PackageHost.WriteInfo($"Device {dc.Name} ({dc.Hostname}:{dc.Port}) connected");
                        device.OnNotificationReceived += (object sender, NotificationReceivedEventArgs e) =>
                        {
                            //updated device properties
                            PackageHost.PushStateObject(dc.Name, device.Properties);
                            PackageHost.WriteDebug(e.Result);
                        };

                        device.OnError += (object sender, UnhandledExceptionEventArgs e) =>
                        {
                            PackageHost.WriteError(e.ExceptionObject);
                        };

                        //initial device properties
                        PackageHost.PushStateObject(dc.Name, device.Properties);
                    }

                    _all.Add(dc.Name, device);
                }
                catch (Exception ex)
                {
                    PackageHost.WriteError($"Unable to connect to device {dc.Name} ({dc.Hostname}:{dc.Port}) : {ex.Message}");;
                }
            });

            //creation of groups
            foreach (DeviceGroupConfig gc in PackageHost.GetSettingAsJsonObject <IEnumerable <DeviceGroupConfig> >("Groups"))
            {
                DeviceGroup group = new DeviceGroup();
                foreach (Device device in gc.Devices.Select(x => _all.SingleOrDefault(d => d.Key == x).Value))
                {
                    group.Add(device);
                }

                _all.Add(gc.Name, group);
            }
        }
コード例 #27
0
 public static void Write(this BinaryWriter writer, DeviceGroup group)
 {
     writer.WriteEpString(group.Name);
     writer.Write(group.DeviceGroupUnknown03);
     writer.Write(group.DeviceGroupUnknown01);
     writer.Write(group.Shortcut);
     writer.Write((UInt16)group.Entries.Count);
     foreach (var device in group.Entries)
     {
         writer.Write(device);
     }
 }
コード例 #28
0
        // PUT api/<controller>/5
        public void Put(Guid id, [FromBody] DeviceGroup value)
        {
            if (value == null)
            {
                return;
            }
            var element = DeviceContext.Instance.DeviceGroups.Find(id);

            value.DeviceInfos = element.DeviceInfos;
            DeviceContext.Instance.DeviceGroups.AddOrUpdate(value);
            DeviceContext.Instance.SaveChanges();
        }
コード例 #29
0
        public async Task Initialize()
        {
            if (_deviceGroup == null)
            {
                var devices = await DeviceLocator.Discover().ConfigureAwait(false);

                if (devices.Count > 0)
                {
                    _deviceGroup = new DeviceGroup(devices);
                    await _deviceGroup.Connect().ConfigureAwait(false);
                }
            }
        }
コード例 #30
0
        public CommandResult Update(DeviceGroup info)
        {
            DeviceGroup original = ProviderFactory.Create <IDeviceGroupProvider>(_RepoUri).GetByID(info.ID).QueryObject;

            if (original != null)
            {
                return(ProviderFactory.Create <IDeviceGroupProvider>(_RepoUri).Update(info, original));
            }
            else
            {
                return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord)));
            }
        }
コード例 #31
0
        public DeviceGroupApiModel(DeviceGroup model)
        {
            this.Id          = model.Id;
            this.DisplayName = model.DisplayName;
            this.Conditions  = model.Conditions;
            this.ETag        = model.ETag;

            this.Metadata = new Dictionary <string, string>
            {
                { "$type", $"DeviceGroup;{Version.NUMBER}" },
                { "$url", $"/{Version.PATH}/devicegroups/{model.Id}" }
            };
        }
コード例 #32
0
ファイル: GKAutoSearchHelper.cs プロジェクト: xbadcode/Rubezh
		bool FindDevicesOnShleif(GKDevice kauDevice, int shleifNo, GKProgressCallback progressCallback, Guid clientUID)
		{
			var shleifDevice = kauDevice.Children.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif && x.IntAddress == shleifNo + 1);
			progressCallback.Title = "Автопоиск на АЛС " + (shleifNo + 1) + " устройства " + kauDevice.PresentationName;
			progressCallback.CurrentStep = 0;
			progressCallback.StepCount = 256;
			using (var gkLifecycleManager = new GKLifecycleManager(kauDevice, "Автопоиск на АЛС " + (shleifNo + 1)))
			{
				var deviceGroups = new List<DeviceGroup>();
				var devices = new List<GKDevice>();
				for (int address = 1; address <= 255; address++)
				{
					gkLifecycleManager.Progress(address, 255);
					GKProcessorManager.DoProgress("Поиск устройства с адресом " + address, progressCallback, clientUID);
					if (progressCallback.IsCanceled)
					{
						Error = "Операция отменена";
						return false;
					}
					var bytes = new List<byte>();
					bytes.Add(0);
					bytes.Add((byte)address);
					bytes.Add((byte)shleifNo);
					var result2 = new SendResult("");
					for (int i = 0; i < 3; i++)
					{
						if (progressCallback.IsCanceled)
						{
							Error = "Операция отменена";
							return false;
						}
						result2 = SendManager.Send(kauDevice, 3, 0x86, 6, bytes, true, false, 3000);
						if (!result2.HasError)
							break;
					}
					if (!result2.HasError)
					{
						if (result2.Bytes.Count == 6)
						{
							var driverTypeNo = result2.Bytes[1];
							var serialNo = BytesHelper.SubstructInt(result2.Bytes, 2);
							var driver = GKManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == (ushort)driverTypeNo);
							if (driver != null)
							{
								var device = new GKDevice();
								device.Driver = driver;
								device.DriverUID = driver.UID;
								device.IntAddress = (byte)address;
								devices.Add(device);

								var deviceGroup = deviceGroups.FirstOrDefault(x => x.SerialNo == serialNo);
								if (deviceGroup == null || (serialNo == 0 || serialNo == -1) || (driver.DriverType != GKDriverType.RSR2_AM_1 && driver.DriverType != GKDriverType.RSR2_MAP4
									&& driver.DriverType != GKDriverType.RSR2_MVK8 && driver.DriverType != GKDriverType.RSR2_RM_1 && driver.DriverType != GKDriverType.RSR2_OPKZ))
								{
									deviceGroup = new DeviceGroup();
									deviceGroup.SerialNo = serialNo;
									deviceGroups.Add(deviceGroup);
								}
								deviceGroup.Devices.Add(device);
							}
						}
					}
					else
					{
						break;
					}
				}

				foreach (var deviceGroup in deviceGroups)
				{
					var firstDeviceInGroup = deviceGroup.Devices.FirstOrDefault();
					if (deviceGroup.Devices.Count > 1 && firstDeviceInGroup != null)
					{
						GKDriver groupDriver = null;
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_AM_1)
						{
							if (deviceGroup.Devices.Count == 2)
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_AM_2);
							else
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_AM_4);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_MAP4)
						{
							groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_MAP4_Group);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_MVK8)
						{
							groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_MVK8_Group);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_RM_1)
						{
							if (deviceGroup.Devices.Count == 2)
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_RM_2);
							else
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_RM_4);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_OPKS)
						{
							groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_OPSZ);
						}

						var groupDevice = new GKDevice();
						groupDevice.Driver = groupDriver;
						if (groupDriver != null)
							groupDevice.DriverUID = groupDriver.UID;
						groupDevice.IntAddress = firstDeviceInGroup.IntAddress;
						foreach (var deviceInGroup in deviceGroup.Devices)
						{
							groupDevice.Children.Add(deviceInGroup);
						}
						if (shleifDevice != null)
							shleifDevice.Children.Add(groupDevice);
					}
					else
					{
						if (shleifDevice != null)
							shleifDevice.Children.Add(firstDeviceInGroup);
					}
				}
			}
			return true;
		}