123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using Edge.Core.Processor.Dispatcher;
- using Edge.Core.Processor.Dispatcher.Attributes;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Text;
- using System.Threading.Tasks;
- using System.Linq;
- using System.Reflection;
- namespace Edge.Core.Processor
- {
- public interface IProcessor
- {
-
-
-
-
-
- string MetaConfigName { get; set; }
-
-
-
-
-
-
- Task<bool> Start() { return Task.FromResult(true); }
- Task<bool> Stop() { return Task.FromResult(true); }
-
-
-
-
-
-
-
-
- Task Test(params object[] parameters) { throw new NotImplementedException("暂不支持测试"); }
- }
- public class ProcessorEqualityComparer : IEqualityComparer<IProcessor>
- {
- public bool Equals([AllowNull] IProcessor x, [AllowNull] IProcessor y)
- {
- if (x == null || y == null) return false;
- if (x.MetaConfigName != y.MetaConfigName) return false;
-
- if (x is IAppProcessor && !(y is IAppProcessor)) return false;
- if (y is IAppProcessor && !(x is IAppProcessor)) return false;
- return true;
- }
- public int GetHashCode([DisallowNull] IProcessor obj)
- {
- return obj.GetHashCode();
- }
- }
-
-
-
- public class ProcessorInstanceOperatingResult
- {
- public IProcessor ProcessorInstance { get; set; }
- public ProcessorMetaConfig MetaConfig { get; set; }
-
- public bool Succeed { get; set; }
-
-
-
- public string HostVersion { get; set; }
-
-
-
- public string CoreVersion { get; set; }
- public string FailedReason { get; set; }
- }
- public class ProcessorLifeCycleOperationResult
- {
- public static ProcessorLifeCycleOperationResult From(ProcessorInstanceOperatingResult input)
- {
- var output = new ProcessorLifeCycleOperationResult();
- var metaPartsDescriptor = input.ProcessorInstance?.ProcessorDescriptor()?.DeviceHandlerOrApp?.GetType()
- ?.GetCustomAttributes<MetaPartsDescriptor>()?.FirstOrDefault();
- output.Description = metaPartsDescriptor?.Description;
- output.IsSystemInternalComponent = metaPartsDescriptor?.IsSystemInternalComponent ?? false;
- output.ProcessorInstanceEntryName = input.MetaConfig?.Name;
- output.Tags = metaPartsDescriptor?.Tags;
- output.ProcessorMetaConfigName = input.MetaConfig?.Name;
- output.HostVersion = input.HostVersion;
- output.CoreVersion = input.CoreVersion;
- output.Succeed = input.Succeed;
- output.FailedReason = input.FailedReason;
- return output;
- }
- public string Description { get; set; }
- public string ProcessorMetaConfigName { get; set; }
- public string ProcessorInstanceEntryName { get; set; }
-
-
-
- public string HostVersion { get; set; }
-
-
-
- public string CoreVersion { get; set; }
- public bool IsSystemInternalComponent { get; set; }
- public bool Succeed { get; set; }
- public string FailedReason { get; set; }
- public string[] Tags { get; set; }
- }
- }
|