/// <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(); }
private void OnEdit(IPackageSource source) { if (CanEdit(source)) { Save.Edit(source); IsEditActive = true; } }
public PackageSourceDescriptor([NotNull] IPackageSource source, [NotNull] PackageSourceAttribute attribute) { Assert.ArgumentNotNull(source, nameof(source)); Assert.ArgumentNotNull(attribute, nameof(attribute)); Source = source; Attribute = attribute; }
/// <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(); }
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); }
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)); } }
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(); }
private void Add(IPackageSource packageSource) { _ri.Invoke("Add-PackageSource " + packageSource.Name + " " + packageSource.Location + " " + packageSource.Provider); }
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(); }
public void Edit(IPackageSource source) { edit = source; Name = source.Name; Url = source.Uri.ToString(); }
private void Remove(IPackageSource packageSource) { _ri.Invoke("Remove-PackageSource " + packageSource.Name + " " + packageSource.Provider); }
public void RemovePackageSource(IPackageSource source) { _packageSourceProvider.Value.RemovePackageSource(source.Name); }
private bool CanEdit(IPackageSource source) => source != null;
public void Delive(IProtocolPackage <T> package, IPackageSource source) { ParseProtocolData(package); DoDelive(package, source); }
public void RemovePackageSource(IPackageSource packageSource) { _packageSourceProvider.SavePackageSources(PackageSources.Except(new[] { packageSource })); }
public IPackageSourceBuilder Edit(IPackageSource source) => new MockPackageSourceBuilder(this);
public void Delive(IProtocolPackage package, IPackageSource source) { var coder = GetCommandCoder(package.Protocol.ProtocolName); coder.DoDelive(package, source); }
public SymbolController(IPackageSource packageSource, ISymbolAccess symbolStore, ILoggerFactory loggerFactory) { _packageSource = packageSource; _symbolStore = symbolStore; _logger = loggerFactory.CreateLogger(GetType().FullName); }