internal EdgeAgentConnection( IModuleClientProvider moduleClientProvider, ISerde <DeploymentConfig> desiredPropertiesSerDe, IRequestManager requestManager, IDeviceManager deviceManager, bool enableSubscriptions, TimeSpan refreshConfigFrequency, RetryStrategy retryStrategy, IDeploymentMetrics deploymentMetrics, Option <X509Certificate2> manifestTrustBundle, TimeSpan twinPullOnConnectThrottleTime) { this.desiredPropertiesSerDe = Preconditions.CheckNotNull(desiredPropertiesSerDe, nameof(desiredPropertiesSerDe)); this.deploymentConfigInfo = Option.None <DeploymentConfigInfo>(); this.reportedProperties = Option.None <TwinCollection>(); this.moduleConnection = new ModuleConnection(moduleClientProvider, requestManager, this.OnConnectionStatusChanged, this.OnDesiredPropertiesUpdated, enableSubscriptions); this.retryStrategy = Preconditions.CheckNotNull(retryStrategy, nameof(retryStrategy)); this.refreshTwinTask = new PeriodicTask(this.ForceRefreshTwin, refreshConfigFrequency, refreshConfigFrequency, Events.Log, "refresh twin config"); this.pullOnReconnect = enableSubscriptions; this.deviceManager = Preconditions.CheckNotNull(deviceManager, nameof(deviceManager)); Events.TwinRefreshInit(refreshConfigFrequency); this.deploymentMetrics = Preconditions.CheckNotNull(deploymentMetrics, nameof(deploymentMetrics)); this.initTask = this.ForceRefreshTwin(); this.manifestTrustBundle = manifestTrustBundle; this.twinPullOnConnectThrottleTime = twinPullOnConnectThrottleTime; }
public StreamRequestListener(IStreamRequestHandlerProvider streamRequestHandlerProvider, IEdgeAgentConnection edgeAgentConnection, int maxConcurrentStreams = 10) { this.streamRequestHandlerProvider = Preconditions.CheckNotNull(streamRequestHandlerProvider, nameof(streamRequestHandlerProvider)); this.streamLock = new SemaphoreSlim(maxConcurrentStreams); this.maxConcurrentStreams = maxConcurrentStreams; this.moduleConnection = Preconditions.CheckNotNull(edgeAgentConnection, nameof(edgeAgentConnection)).ModuleConnection; }
static void Main(string[] args) { try { var wait = 30; //_moduleConnection = new SerialPortModuleConnection("COM3", 250000) //{ // LedCount = 159, // ErrorMode = ErrorMode.RetryOnError //}; //_moduleConnection = new HttpModuleConnection("http://192.168.0.103/led-strip") //{ // LedCount = 12 //}; //_moduleConnection = new TcpModuleConnection("192.168.137.134", 23) //{ // LedCount = 159, // ErrorMode = ErrorMode.SendAndForget //}; _moduleConnection = new UdpModuleConnection("192.168.0.106", 8888) { LedCount = 15, ErrorMode = ErrorMode.RetryOnError }; //_moduleConnection = new E131UdpModuleConnection("192.168.0.106") //{ // LedCount = 10 //}; _moduleConnection.Connect(); while (true) { // Some example procedures showing how to display to the pixels: ColorWipe(Color.Red, _moduleConnection.LedCount, wait); ColorWipe(Color.Green, _moduleConnection.LedCount, wait); ColorWipe(Color.Blue, _moduleConnection.LedCount, wait); // Send a theater pixel chase in... TheaterChase(Color.White.WithBrightness(127), wait); TheaterChase(Color.Red.WithBrightness(127), wait); TheaterChase(Color.Blue.WithBrightness(127), wait); Rainbow(0); RainbowCycle(0); TheaterChaseRainbow(wait); Detonate(Color.White, 1000); } } finally { _moduleConnection?.Dispose(); } }
public AudioAnimation(IModuleConnection moduleConnection) { _moduleConnection = moduleConnection; var deviceEnumerator = new MMDeviceEnumerator(); var devices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active); _device = devices[0]; }
/// <summary> /// Remove this connection is one of the modules is removed. /// </summary> protected override void RemovedFromPackage(IPersistentEntity entity) { base.RemovedFromPackage(entity); IModuleConnection conn = this; if ((entity == conn.ModuleA) || (entity == conn.ModuleB)) { Railway.ModuleConnections.Remove(this); } }
public StroboscopeAnimation(IModuleConnection moduleConnection, Color color) { _moduleConnection = moduleConnection; _color = color; var deviceEnumerator = new MMDeviceEnumerator(); var devices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active); _device = devices[0]; }
Task Pump(IModuleConnection moduleConnection) { return(Task.CompletedTask); ////while (!this.cts.IsCancellationRequested) ////{ //// try //// { //// await this.streamLock.WaitAsync(this.cts.Token); //// IModuleClient moduleClient = await moduleConnection.GetOrCreateModuleClient(); //// await this.ProcessStreamRequest(moduleClient); //// } //// catch (Exception e) //// { //// Events.ErrorInPump(e); //// } ////} }
internal EdgeAgentConnection( IModuleClientProvider moduleClientProvider, ISerde <DeploymentConfig> desiredPropertiesSerDe, IRequestManager requestManager, bool enableSubscriptions, TimeSpan refreshConfigFrequency, RetryStrategy retryStrategy) { this.desiredPropertiesSerDe = Preconditions.CheckNotNull(desiredPropertiesSerDe, nameof(desiredPropertiesSerDe)); this.deploymentConfigInfo = Option.None <DeploymentConfigInfo>(); this.reportedProperties = Option.None <TwinCollection>(); this.moduleConnection = new ModuleConnection(moduleClientProvider, requestManager, this.OnConnectionStatusChanged, this.OnDesiredPropertiesUpdated, enableSubscriptions); this.retryStrategy = Preconditions.CheckNotNull(retryStrategy, nameof(retryStrategy)); this.refreshTwinTask = new PeriodicTask(this.ForceRefreshTwin, refreshConfigFrequency, refreshConfigFrequency, Events.Log, "refresh twin config"); this.initTask = this.ForceRefreshTwin(); this.pullOnReconnect = enableSubscriptions; Events.TwinRefreshInit(refreshConfigFrequency); }
/// <summary> /// Validate the integrity of this entity. /// </summary> public override void Validate(IEntity validationRoot, ValidationResults results) { base.Validate(validationRoot, results); IModuleConnection mc = this; if (mc.ModuleA == null) { results.Warn(this, Strings.WarnModuleANotSpecified); } else if (mc.EdgeA == null) { results.Warn(this, Strings.WarnEdgeANotSpecified); } if (mc.ModuleB == null) { results.Warn(this, Strings.WarnModuleBNotSpecified); } else if (mc.EdgeB == null) { results.Warn(this, Strings.WarnEdgeBNotSpecified); } }
public virtual TReturn Visit(IModuleConnection entity, TData data) { return(default(TReturn)); }
public override object Visit(IModuleConnection entity, IPackage data) { data.Railway.ModuleConnections.Remove(entity); return(null); }
public override object Visit(IModuleConnection entity, GridContext data) { return(new ModuleConnectionSettings(entity, data)); }
public StroboscopeAnimation(IModuleConnection moduleConnection) : this(moduleConnection, Color.White) { }