/// <summary>
        /// 油烟系统报警信息处理
        /// </summary>
        /// <param name="package"></param>
        /// <param name="source"></param>
        public static void LampblackAlarm(IProtocolPackage <byte[]> package, IPackageSource source)
        {
            var exception = package[ProtocolDataName.LampblackException];

            if (exception == null)
            {
                return;
            }

            var alarmList = new List <Alarm>();

            var flag = Globals.BytesToUint16(exception.ComponentContent, 0, false);

            for (var i = 0; i < 8; i++)
            {
                var error = (1 << i);

                if ((flag & error) == 0)
                {
                    continue;
                }
                var record = new AlarmRepository().CreateDefaultModel();
                record.AlarmType     = AlarmType.Lampblack;
                record.AlarmCode     = error;
                record.AlarmDeviceId = package.Device.Id;
                record.UpdateTime    = package.ReceiveDateTime;
                record.DomainId      = package.Device.DomainId;
                alarmList.Add(record);
            }

            if (alarmList.Count > 0)
            {
                ProcessInvoke.Instance <ProtocolPackageProcess>().AddOrUpdateAlarm(alarmList);
            }
        }
 public LuceneIndexingService(
     IPackageSource packageSource,
     Lucene.Net.Store.Directory directory)
 {
     _packageSource = packageSource;
     _directory     = directory;
 }
        /// <summary>
        /// 存储协议包携带的数据
        /// </summary>
        /// <param name="package">接收到的协议包</param>
        /// <param name="source">接收数据源</param>
        public void StoreData(IProtocolPackage <byte[]> package, IPackageSource source)
        {
            var monitorDataList = new List <MonitorData>();

            for (var i = 0; i < package.Command.CommandDatas.Count; i++)
            {
                var monitorData = new MonitorDataRepository().CreateDefaultModel();
                monitorData.DomainId = package.Device.DomainId;

                var commandData = package.Command.CommandDatas.First(obj => obj.DataIndex == i);

                var temp = _dataConverter.DecodeComponentData(package[commandData.DataName]);

                monitorData.DoubleValue     = Convert.ToDouble(temp);
                monitorData.ProtocolDataId  = package.ProtocolData.Id;
                monitorData.UpdateTime      = DateTime.Now;
                monitorData.CommandDataId   = commandData.Id;
                monitorData.DeviceIdentity  = package.Device.Identity;
                monitorData.ProjectIdentity = package.Device.Project.Identity;

                monitorDataList.Add(monitorData);
            }

            if (package[ProtocolDataName.DataValidFlag] != null)
            {
                ProcessDataValidFlag(package, monitorDataList);
            }

            lock (TempMonitorDatas)
            {
                TempMonitorDatas.AddRange(monitorDataList);
            }

            OnMonitorDataReceived();
        }
 public LuceneIndexingService(
     IPackageSource packageSource,
     Lucene.Net.Store.Directory directory)
 {
     _packageSource = packageSource;
     _directory = directory;
 }
Example #5
0
 private void OnEdit(IPackageSource source)
 {
     if (CanEdit(source))
     {
         Save.Edit(source);
         IsEditActive = true;
     }
 }
Example #6
0
            public PackageSourceDescriptor([NotNull] IPackageSource source, [NotNull] PackageSourceAttribute attribute)
            {
                Assert.ArgumentNotNull(source, nameof(source));
                Assert.ArgumentNotNull(attribute, nameof(attribute));

                Source    = source;
                Attribute = attribute;
            }
Example #7
0
        /// <summary>
        /// 将收到的协议包按原样回发
        /// </summary>
        /// <param name="package">接收到的协议包</param>
        /// <param name="source">接收数据源</param>
        public void ReplyOriginal(IProtocolPackage <T> package, IPackageSource source)
        {
            if (source.Type != PackageSourceType.CommunicationServer)
            {
                return;
            }

            source.Send(package.GetBytes());
        }
        public void Remove(IPackageSource source)
        {
            NuGetPackageSource target = EnsureType(source);

            if (Sources.Remove(target))
            {
                SavePackageSources();
            }
        }
        private NuGetPackageSource EnsureType(IPackageSource source, string argumentName = null)
        {
            Ensure.NotNull(source, argumentName ?? "source");
            if (source is NuGetPackageSource target)
            {
                return(target);
            }

            throw new InvalidPackageSourceImplementationException();
        }
Example #10
0
        public void DoDelive(IProtocolPackage package, IPackageSource source)
        {
            var bytesPackage = (IProtocolPackage <string>)package;

            if (bytesPackage == null)
            {
                return;
            }
            _deliver.Delive(bytesPackage, source);
        }
        public int MoveDown(IPackageSource source)
        {
            NuGetPackageSource target = EnsureType(source);
            int index = Sources.IndexOf(target);

            if (index < Sources.Count - 1)
            {
                Sources.RemoveAt(index);
                Sources.Insert(++index, target);
                SavePackageSources();
            }

            return(index);
        }
Example #12
0
        protected virtual void DoDelive(IProtocolPackage <T> package, IPackageSource source)
        {
            var deliverParams = package.DeliverParams;

            if (deliverParams.Count == 0)
            {
                return;
            }

            foreach (var deliverMethod in deliverParams.Select(param => Deliver.GetMethod(param)))
            {
                deliverMethod.Invoke(this, new object[] { package, source });
            }
        }
        public int MoveUp(IPackageSource source)
        {
            NuGetPackageSource target = EnsureType(source);
            int index = Sources.IndexOf(target);

            if (index > 0)
            {
                Sources.RemoveAt(index);
                Sources.Insert(--index, target);
                SavePackageSources();
            }

            return(index);
        }
        public NugetPackage InstallPackage(string packageId, Version packageVersion, string downloadUri)
        {
            string        installPath     = GetInstallPathForPackage(packageId);
            DirectoryInfo targetDirectory = Directory.CreateDirectory(installPath);
            string        targetPath      = Path.Combine(installPath, NugetPackage.GetPackageFileName(packageId, packageVersion));

            IPackageSourceRepository packageSourceRepository = packageSourceRepositoryFactory.CreateRepository(downloadUri);
            IPackageSource           packageSource           = packageSourceRepository.FindPackage(packageId, packageVersion);

            packageSource.Copy(targetPath);

            NugetPackage installedPackage = new NugetPackage(targetPath);

            return(installedPackage);
        }
        public void MarkAsPrimary(IPackageSource source)
        {
            if (Provider.ActivePackageSourceName == source?.Name)
            {
                return;
            }

            if (source == null)
            {
                Provider.SaveActivePackageSource(null);
            }
            else
            {
                Provider.SaveActivePackageSource(UnWrap(source));
            }
        }
        public void MarkAsPrimary(IPackageSource source)
        {
            if (string.Equals(Provider.ActivePackageSourceName, source?.Name, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }

            if (source == null)
            {
                Provider.SaveActivePackageSource(null);
            }
            else
            {
                Provider.SaveActivePackageSource(UnWrap(source));
            }
        }
Example #17
0
        public override void Execute()
        {
            if (CanExecute() && Uri.TryCreate(Url, UriKind.RelativeOrAbsolute, out var uri))
            {
                if (edit == null)
                {
                    sources.Add(service.Add().Name(Name).Uri(uri).Save());
                }
                else
                {
                    int index = sources.IndexOf(edit);
                    sources.RemoveAt(index);
                    sources.Insert(index, service.Edit(edit).Name(Name).Uri(uri).Save());
                }

                edit = null;
                Name = null;
                Url  = null;

                Executed?.Invoke();
            }
        }
 public PackagesController(IPackageSource packageSource)
 {
     m_PackageSource = packageSource;
 }
 public int MoveDown(IPackageSource source)
 => throw Ensure.Exception.NotSupported();
 public void Remove(IPackageSource source)
 {
     all.Remove((MockPackageSource)source);
     RaiseChanged();
 }
 public void MarkAsPrimary(IPackageSource source)
 {
     primary = source;
     RaiseChanged();
 }
Example #22
0
 private void Add(IPackageSource packageSource)
 {
     _ri.Invoke("Add-PackageSource " + packageSource.Name + " " + packageSource.Location + " " + packageSource.Provider);
 }
Example #23
0
 public void New()
 {
     edit = null;
     Name = null;
     Url  = null;
 }
 public IPackageSourceBuilder Edit(IPackageSource source)
 => new NuGetPackageSourceBuilder(this, EnsureType(source));
 private PackageSource UnWrap(IPackageSource source, string argumentName = null)
 => EnsureType(source, argumentName).Original;
        public void Lampblack(IProtocolPackage <byte[]> package, IPackageSource source)
        {
            var monitorDataList = new List <MonitorData>();

            foreach (var dataComponent in package.DataComponents)
            {
                if (dataComponent.Value.CommandData.DataName == null ||
                    dataComponent.Value.CommandData.DataConvertType == ProtocolDataType.None)
                {
                    continue;
                }
                var data = _dataConverter.DecodeComponentData(dataComponent.Value);

                var monitorData = new MonitorDataRepository().CreateDefaultModel();
                monitorData.DomainId = package.Device.DomainId;

                switch (dataComponent.Value.CommandData.DataValueType)
                {
                case DataValueType.Double:
                    monitorData.DoubleValue = Convert.ToDouble(data);
                    break;

                case DataValueType.Integer:
                    monitorData.IntegerValue = Convert.ToInt32(data);
                    break;

                case DataValueType.Boolean:
                    monitorData.BooleanValue = Convert.ToBoolean(data);
                    break;
                }

                monitorData.ProtocolDataId  = package.ProtocolData.Id;
                monitorData.UpdateTime      = DateTime.Now;
                monitorData.CommandDataId   = dataComponent.Value.CommandData.Id;
                monitorData.DeviceIdentity  = package.Device.Identity;
                monitorData.ProjectIdentity = package.Device.Project.Identity;
                monitorData.DataIsValid     = (dataComponent.Value.ValidFlag & 0x80) == 0;
                monitorData.DataChannel     = dataComponent.Value.ComponentChannel;

                monitorDataList.Add(monitorData);

                if (dataComponent.Value.CommandData.DataName != "CleanerCurrent")
                {
                    continue;
                }
                var cleanerSwitch = new MonitorData
                {
                    DomainId        = package.Device.DomainId,
                    ProtocolDataId  = package.ProtocolData.Id,
                    UpdateTime      = DateTime.Now,
                    CommandDataId   = new Guid("15802959-D25B-42AD-BE50-5B48DCE4039A"),
                    DeviceIdentity  = package.Device.Identity,
                    ProjectIdentity = package.Device.Project.Identity,
                    DataIsValid     = true,
                    DataChannel     = dataComponent.Value.ComponentChannel
                };
                if (monitorData.DoubleValue > 4)
                {
                    cleanerSwitch.BooleanValue = true;
                }
                monitorDataList.Add(cleanerSwitch);
            }

            lock (TempMonitorDatas)
            {
                TempMonitorDatas.AddRange(monitorDataList);
            }

            OnMonitorDataReceived();
        }
Example #27
0
 public void Edit(IPackageSource source)
 {
     edit = source;
     Name = source.Name;
     Url  = source.Uri.ToString();
 }
Example #28
0
 private void Remove(IPackageSource packageSource)
 {
     _ri.Invoke("Remove-PackageSource " + packageSource.Name + " " + packageSource.Provider);
 }
 public void RemovePackageSource(IPackageSource source)
 {
     _packageSourceProvider.Value.RemovePackageSource(source.Name);
 }
Example #30
0
 private bool CanEdit(IPackageSource source)
 => source != null;
Example #31
0
 public void Delive(IProtocolPackage <T> package, IPackageSource source)
 {
     ParseProtocolData(package);
     DoDelive(package, source);
 }
Example #32
0
 public void RemovePackageSource(IPackageSource packageSource)
 {
     _packageSourceProvider.SavePackageSources(PackageSources.Except(new[] { packageSource }));
 }
 public IPackageSourceBuilder Edit(IPackageSource source)
 => new MockPackageSourceBuilder(this);
Example #34
0
        public void Delive(IProtocolPackage package, IPackageSource source)
        {
            var coder = GetCommandCoder(package.Protocol.ProtocolName);

            coder.DoDelive(package, source);
        }
Example #35
0
 public SymbolController(IPackageSource packageSource, ISymbolAccess symbolStore, ILoggerFactory loggerFactory)
 {
     _packageSource = packageSource;
     _symbolStore   = symbolStore;
     _logger        = loggerFactory.CreateLogger(GetType().FullName);
 }