public void Send(LPD433MHzCodeSequence codeSequence) { foreach (var code in codeSequence.Codes) { Send(code); } }
private void ApiPost(HttpContext context) { JsonArray sequence = context.Request.JsonBody.GetNamedArray("sequence", new JsonArray()); if (sequence.Count == 0) { return; } var codeSequence = new LPD433MHzCodeSequence(); foreach (IJsonValue item in sequence) { var code = item.GetObject(); uint value = (uint)code.GetNamedNumber("value", 0); byte length = (byte)code.GetNamedNumber("length", 0); byte repeats = (byte)code.GetNamedNumber("repeats", 1); if (value == 0 || length == 0) { throw new InvalidOperationException("Value or length is null."); } codeSequence.WithCode(new LPD433MHzCode(value, length, repeats)); } Send(codeSequence); }
private void ApiPost(IApiContext apiContext) { var sequence = apiContext.Request["sequence"].ToObject<JArray>(); if (sequence.Count == 0) { return; } var codeSequence = new LPD433MHzCodeSequence(); foreach (var item in sequence) { var code = item.ToObject<JObject>(); var value = (uint)code["value"]; var length = (byte)code["length"]; var repeats = (byte)code["repeats"]; if (value == 0 || length == 0) { throw new InvalidOperationException("Value or length is null."); } codeSequence.WithCode(new LPD433MHzCode(value, length, repeats)); } Send(codeSequence); }
public LPD433MHzCodeSequencePair(LPD433MHzCodeSequence onSequence, LPD433MHzCodeSequence offSequence) { if (onSequence == null) throw new ArgumentNullException(nameof(onSequence)); if (offSequence == null) throw new ArgumentNullException(nameof(offSequence)); OnSequence = onSequence; OffSequence = offSequence; }
public RemoteSwitchOutputPort(int id, LPD433MHzCodeSequence onCodeSequence, LPD433MHzCodeSequence offCodeSequence, LPD433MHzSignalSender sender) { if (onCodeSequence == null) throw new ArgumentNullException(nameof(onCodeSequence)); if (offCodeSequence == null) throw new ArgumentNullException(nameof(offCodeSequence)); if (sender == null) throw new ArgumentNullException(nameof(sender)); _onCodeSqCodeSequence = onCodeSequence; _offCodeSequence = offCodeSequence; _sender = sender; }
public void Register(int id, LPD433MHzCodeSequence onCodeSequence, LPD433MHzCodeSequence offCodeSequence) { if (onCodeSequence == null) throw new ArgumentNullException(nameof(onCodeSequence)); if (offCodeSequence == null) throw new ArgumentNullException(nameof(offCodeSequence)); lock (_syncRoot) { var port = new RemoteSwitchOutputPort(id, onCodeSequence, offCodeSequence, _sender); port.Write(BinaryState.Low); _ports.Add(id, port); } }
public RemoteSocketController WithRemoteSocket(int id, LPD433MHzCodeSequence onCodeSequence, LPD433MHzCodeSequence offCodeSequence) { if (onCodeSequence == null) { throw new ArgumentNullException(nameof(onCodeSequence)); } if (offCodeSequence == null) { throw new ArgumentNullException(nameof(offCodeSequence)); } lock (_syncRoot) { var port = new RemoteSocketOutputPort(id, onCodeSequence, offCodeSequence, _sender); port.Write(BinaryState.Low); _ports.Add(id, port); } return(this); }
private void ApiPost(HttpContext context) { JsonObject requestData; if (!JsonObject.TryParse(context.Request.Body, out requestData)) { context.Response.StatusCode = HttpStatusCode.BadRequest; return; } JsonArray sequence = requestData.GetNamedArray("sequence", new JsonArray()); if (sequence.Count == 0) { return; } var codeSequence = new LPD433MHzCodeSequence(); foreach (IJsonValue item in sequence) { var code = item.GetObject(); uint value = (uint)code.GetNamedNumber("value", 0); byte length = (byte)code.GetNamedNumber("length", 0); byte repeats = (byte)code.GetNamedNumber("repeats", 1); if (value == 0 || length == 0) { throw new InvalidOperationException("Value or length is null."); } codeSequence.WithCode(new LPD433MHzCode(value, length, repeats)); } Send(codeSequence); }