// Register a push trigger. public void RegisterTrigger(string triggerId, TriggerInput <string, TriggerBody> triggerInput) { lock (_store) { _store.Add(triggerId, triggerInput); } }
public GreaterThen(SignalHandler signal, double compareValue, AlgerbraOperator nextOperator) : base(signal, nextOperator) { this._compareValue = compareValue; this._triggerInputs = TriggerInput.OnlyValue; base.SignalHandlersUsedByTrigger.Add(signal); }
public GreaterThen(SignalHandler signal, double compareValue, AlgerbraOperator nextOperator) : base(signal, nextOperator) { this._compareValue = compareValue; this._triggerInputs = TriggerInput.OnlyValue; base.SignalHandlersUsedByTrigger.Add(signal); }
public void AndTest() { TriggerStub triggerA = new TriggerStub("A"); TriggerStub triggerB = new TriggerStub("B"); TriggerInput combined = triggerA.And(triggerB); Assert.That(combined.ToString(), Is.EqualTo("A+B")); ValueSpy <bool> spy = new ValueSpy <bool>(combined); triggerA.Update(true); spy.WaitFrame(); spy.AssertNothingHappened(); triggerA.Update(false); triggerB.Update(true); spy.WaitFrame(); spy.AssertNothingHappened(); triggerA.Update(true); spy.WaitFrame(); spy.AssertWasUpdatedTo(true); triggerA.Update(false); spy.WaitFrame(); spy.AssertWasUpdatedTo(false); triggerB.Update(false); spy.WaitFrame(); spy.AssertNothingHappened(); }
// Register a push trigger. public void RegisterTrigger(string triggerId, TriggerInput<string, TriggerBody> triggerInput) { lock (_store) { _store.Add(triggerId, triggerInput); } }
public GreaterThen(SignalHandler signal, SignalHandler compareSignal, AlgerbraOperator nextOperator) : base(signal, nextOperator) { this._compareSignal = compareSignal; this._triggerInputs = TriggerInput.OnlySignal; base.SignalHandlersUsedByTrigger.Add(signal); base.SignalHandlersUsedByTrigger.Add(compareSignal); }
public GreaterThen(SignalHandler signal, SignalHandler compareSignal, AlgerbraOperator nextOperator) : base(signal, nextOperator) { this._compareSignal = compareSignal; this._triggerInputs = TriggerInput.OnlySignal; base.SignalHandlersUsedByTrigger.Add(signal); base.SignalHandlersUsedByTrigger.Add(compareSignal); }
public async Task <HttpResponseMessage> RegisterCallback(string triggerId, [FromBody] TriggerInput <PushTriggerConfiguration> parameters) { // Store the callback await _callbackStore.WriteCallbackAsync(triggerId, parameters.GetCallback().CallbackUri, parameters.inputs); // Report success return(Request.PushTriggerRegistered(parameters.GetCallback())); }
public HttpResponseMessage EventHubPushTrigger(string triggerId, [FromBody] TriggerInput <EventHubInput, EventHubMessage> triggerInput) { if (!InMemoryTriggerStore.Instance.GetStore().ContainsKey(triggerId)) { HostingEnvironment.QueueBackgroundWorkItem(async ct => await InMemoryTriggerStore.Instance.RegisterTrigger(triggerId, triggerInput)); } return(this.Request.PushTriggerRegistered(triggerInput.GetCallback())); }
public void Update(Index index) { if (UseButton()) { ButtonInput?.Invoke(GetButton(), index); } else { isCurrentTriggerPressed = (GamepadInput.GamePad.GetTrigger(GetTrigger(), index) > 0); TriggerInput?.Invoke(GetTrigger(), index, isCurrentTriggerPressed, isPreviewTriggerPressed); isPreviewTriggerPressed = isCurrentTriggerPressed; } }
public async Task <HttpResponseMessage> RegisterCallback(string triggerId, [FromBody] TriggerInput <PushTriggerConfiguration, PushTriggerOutput> parameters) { // Store the callback ICallbackStore <PushTriggerConfiguration> callbackStore = new AzureMobileAppCallbackStore(); await callbackStore.WriteCallbackAsync(triggerId, parameters.GetCallback().CallbackUri, parameters.inputs); // Report that everything is happy return(Request.PushTriggerRegistered(parameters.GetCallback())); }
public HttpResponseMessage RegisterCallback( string triggerId, [FromBody] TriggerInput <SamplePushConfig, SamplePushEvent> parameters) { // Store the callback for later use CallbackStore[triggerId] = new SampleStoredCallback() { SampleConfigFromLogicApp = parameters.inputs, CallbackUri = parameters.GetCallback().CallbackUri }; // Notify the Logic App that the callback was registered return(Request.PushTriggerRegistered(parameters.GetCallback())); }
public BaseResult ResumeTrigger(TriggerInput input) { var result = new BaseResult(); try { var triggerKey = new TriggerKey(input.Trigger, DEFAULTGROUP); _schedulerProvider.Scheduler.ResumeTrigger(triggerKey); result.Success = true; } catch (Exception ex) { result.ErrorMessage = ex.Message; } return(result); }
public HttpResponseMessage Put(string triggerId, [FromBody] TriggerInput <string, TriggerBody> triggerInput) { ClientTriggerCallback callback; try { callback = triggerInput.GetCallback(); } catch (Exception) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } _triggerRepository.RegisterTrigger(triggerId, triggerInput); return(Request.PushTriggerRegistered(callback)); }
public static void PrintTriggerInputsInfo(TriggerInputs triggerInputs) { for (int i = 0; i < triggerInputs.Count; i++) { TriggerInput triggerInput = triggerInputs[i]; Console.WriteLine(" Trigger input " + i.ToString() + ":"); Console.WriteLine(" Id : " + triggerInput.Id.ToString()); Console.WriteLine(" Name : " + triggerInput.Name); Console.WriteLine(" Available : " + triggerInput.IsAvailable.ToString()); if (triggerInput.IsAvailable) { Console.WriteLine(" Enabled : " + triggerInput.Enabled.ToString()); Console.WriteLine(" Kinds : " + TriggerKindToStr(triggerInput.Kinds)); if (triggerInput.Kinds != Constants.TKM_NONE) { Console.WriteLine(" Kind : " + TriggerKindToStr((UInt64)triggerInput.Kind)); } } } }
/// <summary> /// The method that registers Event Hub listeners and assigns them to a recieve event. When I receive an event from the event hub listener, I trigger the callbackURL /// </summary> /// <param name="triggerId"></param> /// <param name="triggerInput"></param> /// <returns></returns> public async Task RegisterTrigger(string triggerId, TriggerInput <EventHubInput, EventHubMessage> triggerInput) { var client = EventHubClient.CreateFromConnectionString(triggerInput.inputs.eventHubConnectionString, triggerInput.inputs.eventHubName); EventHubConsumerGroup group = client.GetConsumerGroup(triggerInput.inputs.consumerGroup); string[] partitions; //If they specified partitions, iterate over their list to only listen to the partitions they specified if (!String.IsNullOrEmpty(triggerInput.inputs.eventHubPartitionList)) { partitions = triggerInput.inputs.eventHubPartitionList.Split(','); } //If they left it blank, create a list to listen to all partitions else { partitions = new string[client.GetRuntimeInformation().PartitionCount]; for (int x = 0; x < partitions.Length; x++) { partitions[x] = x.ToString(); } } //For ever partition I should listen to, create a thread with a listener on it foreach (var p in partitions) { p.Trim(); var reciever = group.CreateReceiver(client.GetRuntimeInformation().PartitionIds[int.Parse(p)], DateTime.UtcNow); EventHubListener listener = new EventHubListener(reciever); //Register the event. When I recieve a message, call the method to trigger the logic app listener.MessageReceived += (sender, e) => sendTrigger(sender, e, Runtime.FromAppSettings(), triggerInput.GetCallback()); listener.StartListening(); } //Register the triggerID in my store, so on subsequent checks from the logic app I don't spin up a new set of listeners _store[triggerId] = true; }
public void BoundEventListTest() { InputEvent.ResetBindings(); TriggerInput t = new TriggerInput("t"); ScalarInput v = new ScalarInput("v"); Action <bool> boolAction = _ => { }; Action <bool> boolAction2 = _ => { }; Action <float> floatAction = _ => { }; t.Updated += boolAction; t.Updated += boolAction2; v.Updated += floatAction; Assert.That(InputEvent.BoundEvents, ContainsExactly(t, v)); t.Updated -= boolAction; Assert.That(InputEvent.BoundEvents, ContainsExactly(t, v)); t.Updated -= boolAction2; Assert.That(InputEvent.BoundEvents, ContainsExactly(v)); InputEvent.ResetBindings(); Assert.That(InputEvent.BoundEvents, Is.Empty); }
public override void HandleTrigger(TriggerInput _Output) { throw new NotImplementedException(); }
public static ScalarInput TriggersToAxis(TriggerInput positive, TriggerInput negative) { return(new ScalarInput($"Axis({positive}, {negative})", new TriggerAsAxis(positive, negative))); }
public override void HandleTrigger(TriggerInput _Input) { K8055.Initialize(); K8055.ToggleOutput(channel - 1); }
public override void HandleTrigger(TriggerInput _Output) { System.Diagnostics.Debug.WriteLine(GetInput(DataInputs[0])); }
public virtual byte[] Compile(TriggerInput _Input) { throw new NotImplementedException(); }
public TriggerAsAxis(TriggerInput positive, TriggerInput negative) : base(positive, negative, Calculate) { }
public HttpResponseMessage RegisterCallback(string triggerId, [FromBody] TriggerInput <string, JObject> parameters) { CallbackStore[triggerId] = parameters.GetCallback().CallbackUri; return(Request.PushTriggerRegistered(parameters.GetCallback())); }
public override byte[] Compile(TriggerInput _Input) { MemoryStream stream = new MemoryStream(); foreach (TriggerInput ti in TriggerOutputs[0].Connected) { byte[] blob = ((MainStationCodeBlock)ti.Owner.Owner).Compile(ti); stream.Write(blob, 0, blob.Length); } return stream.ToArray(); }
public override void HandleTrigger(TriggerInput _Input) { toggle = true; }
public static void Main() { // Print library information: PrintInfo.PrintLibraryInfo(); // Enable network search: Network.AutoDetectEnabled = true; // Update device list: DeviceList.Update(); // Try to open an oscilloscope with block measurement support and a generator in the same device: Oscilloscope scp = null; Generator gen = null; for (UInt32 i = 0; i < DeviceList.Count; i++) { DeviceListItem item = DeviceList.GetItemByIndex(i); if (item.CanOpen(DeviceType.Oscilloscope) && item.CanOpen(DeviceType.Generator)) { scp = item.OpenOscilloscope(); if ((scp.MeasureModes & Constants.MM_BLOCK) != 0) { gen = item.OpenGenerator(); break; } else { scp.Dispose(); scp = null; } } } if (scp != null && gen != null) { try { // Oscilloscope settings: // Get the number of channels: UInt16 channelCount = Convert.ToUInt16(scp.Channels.Count); // Set measure mode: scp.MeasureMode = MeasureMode.Block; // Set sample frequency: scp.SampleFrequency = 1e6; // 1 MHz // Set record length: scp.RecordLength = 10000; // 10 kS UInt64 recordLength = scp.RecordLength; // Read actual record length. // Set pre sample ratio: scp.PreSampleRatio = 0; // 0 % // For all channels: for (UInt16 ch = 0; ch < channelCount; ch++) { OscilloscopeChannel channel = scp.Channels[ch]; // Enable channel to measure it: channel.Enabled = true; // Set range: channel.Range = 8; // 8 V // Set coupling: channel.Coupling = Coupling.DCV; // DC Volt } // Set trigger timeout: scp.TriggerTimeOut = 1; // 1 s // Disable all channel trigger sources: for (UInt16 ch = 0; ch < channelCount; ch++) { scp.Channels[ch].Trigger.Enabled = false; } // Locate trigger input: TriggerInput triggerInput = scp.TriggerInputs.GetById(Constants.TIID_GENERATOR_NEW_PERIOD); // or Constants.TIID_GENERATOR_START or Constants.TIID_GENERATOR_STOP if (triggerInput == null) { throw new System.Exception("Unknown trigger input!"); } // Enable trigger input: triggerInput.Enabled = true; // Generator settings: // Set signal type: gen.SignalType = SignalType.Triangle; // Set frequency: gen.Frequency = 1e3; // 1 kHz // Set amplitude: gen.Amplitude = 2; // 2 V // Set offset: gen.Offset = 0; // 0 V // Enable output: gen.OutputOn = true; // Print oscilloscope info: PrintInfo.PrintDeviceInfo(scp); // Print generator info: PrintInfo.PrintDeviceInfo(gen); // Start measurement: scp.Start(); // Start signal generation: gen.Start(); // Wait for measurement to complete: while (!scp.IsDataReady) { Thread.Sleep(10); // 10 ms delay, to save CPU time. } // Stop generator: gen.Stop(); // Disable output: gen.OutputOn = false; // Get data: float[][] data = scp.GetData(); // Open file with write/update permissions: string filename = "OscilloscopeGeneratorTrigger.csv"; StreamWriter file = new StreamWriter(filename, false); // Output CSV data: if (File.Exists(filename)) { // Write csv header: file.Write("Sample"); for (UInt16 i = 0; i < channelCount; i++) { file.Write(string.Format(";Ch{0}", i + 1)); } file.Write(Environment.NewLine); // Write the data to csv: for (UInt64 i = 0; i < recordLength; i++) { file.Write(i.ToString()); for (UInt16 ch = 0; ch < channelCount; ch++) { file.Write(";" + data[ch][i].ToString()); } file.Write(Environment.NewLine); } Console.WriteLine("Data written to: " + filename); // Close file: file.Close(); } else { Console.WriteLine("Couldn't open file: " + filename); Environment.Exit(1); } } catch (System.Exception e) { Console.WriteLine("Exception: " + e.Message); Environment.Exit(1); } // Close oscilloscope: scp.Dispose(); scp = null; // Close generator: gen.Dispose(); gen = null; } else { Console.WriteLine("No oscilloscope available with block measurement support!"); Environment.Exit(1); } Environment.Exit(0); }
public override void HandleTrigger(TriggerInput _Input) { update = true; targetstate = (bool)GetInput(DataInputs[0]); }
public override void HandleTrigger(TriggerInput _Input) { if (_Input == null) Trigger(TriggerOutputs[0]); if (_Input == TriggerInputs[0]) { Control c = WebInterface.WebInterface.FindControl(switchname); if (c != null && c is Switch) { ((Switch)c).State = !((Switch)c).State; } } }
public static void Main() { // Print library information: PrintInfo.PrintLibraryInfo(); // Enable network search: Network.AutoDetectEnabled = true; // Update device list: DeviceList.Update(); // Try to open a generator with triggered burst support: Generator gen = null; for (UInt32 i = 0; i < DeviceList.Count; i++) { DeviceListItem item = DeviceList.GetItemByIndex(i); if (item.CanOpen(DeviceType.Generator)) { gen = item.OpenGenerator(); // Check for triggered burst support: if ((gen.ModesNative & Constants.GM_BURST_COUNT) != 0 && gen.TriggerInputs.Count > 0) { break; } else { gen.Dispose(); gen = null; } } } if (gen != null) { try { // Set signal type: gen.SignalType = SignalType.Square; // Set frequency: gen.Frequency = 100e3; // 100 kHz // Set amplitude: gen.Amplitude = 2.5; // 2.5 V // Set offset: gen.Offset = 2.5; // 2.5 V // Set symmetry (duty cycle): gen.Symmetry = 0.25; // 25 % // Set burst mode: gen.Mode = GeneratorMode.BurstCount; // Set burst count: gen.BurstCount = 20; // 20 periods // Locate trigger input: TriggerInput triggerInput = gen.TriggerInputs.GetById(Constants.TIID_EXT1); if (triggerInput == null) { triggerInput = gen.TriggerInputs.GetById(Constants.TIID_EXT2); } if (triggerInput == null) { throw new System.Exception("Unknown trigger input!"); } // Enable trigger input: triggerInput.Enabled = true; // Set trigger input kind: triggerInput.Kind = TriggerKind.FallingEdge; // Enable output: gen.OutputOn = true; // Print generator info: PrintInfo.PrintDeviceInfo(gen); // Start signal generation gen.Start(); // Wait for keystroke: Console.WriteLine("Press Enter to stop signal generation..."); Console.ReadLine(); // Stop generator: gen.Stop(); // Disable output: gen.OutputOn = false; } catch (System.Exception e) { Console.WriteLine("Exception: " + e.Message); Environment.Exit(1); } // Close generator: gen.Dispose(); gen = null; } else { Console.WriteLine("No generator available with triggered burst support!"); Environment.Exit(1); } Environment.Exit(0); }
public override byte[] Compile(TriggerInput _Input) { MemoryStream bstream = new MemoryStream(); foreach (TriggerInput i in TriggerOutputs[0].Connected) { byte[] c = ((MainStationCodeBlock)i.Owner.Owner).Compile(i); bstream.Write(c, 0, c.Length); } MemoryStream stream = new MemoryStream(); //CodeInstructions.Jump(); return stream.ToArray(); }
public override void HandleTrigger(TriggerInput _Input) { Trigger(TriggerOutputs[0]); }
public override byte[] Compile(TriggerInput _Input) { var v = ((MainStationCodeBlock)DataInputs[0].Connected.Owner.Owner).GetOutput(DataInputs[0].Connected); byte[] code = CodeInstructions.SetLED(v.Register.index); MemoryStream stream = new MemoryStream(); stream.Write(v.Code, 0, v.Code.Length); stream.Write(code, 0, code.Length); return stream.ToArray(); }
public override void HandleTrigger(TriggerInput _Input) { if (!(bool)GetInput(DataInputs[0])) { Trigger(TriggerOutputs[0]); } }
public override byte[] Compile(TriggerInput _Input) { MemoryStream stream = new MemoryStream(); byte[] code; code = CodeInstructions.Load8(0, EventID); stream.Write(code, 0, code.Length); byte index = 1; foreach (DataInput i in DataInputs) { GetOutputResult ans = ((MainStationCodeBlock)(i.Connected.Owner.Owner)).GetOutput(i.Connected); stream.Write(ans.Code, 0, ans.Code.Length); code = CodeInstructions.Mov(ans.Register.index, index, (byte)ans.Register.size); index += (byte)ans.Register.size; stream.Write(code, 0, code.Length); } code = CodeInstructions.EPSend(DeviceID, index); stream.Write(code, 0, code.Length); return stream.ToArray(); }
public override void HandleTrigger(TriggerInput _Input) { MainStation.MainStation.InvokeLocalEvent(deviceid, eventid, 0); }
/// <summary> /// The method that registers Event Hub listeners and assigns them to a recieve event. When I receive an event from the event hub listener, I trigger the callbackURL /// </summary> /// <param name="triggerId"></param> /// <param name="triggerInput"></param> /// <returns></returns> public async Task RegisterTrigger(string triggerId, TriggerInput<EventHubInput, EventHubMessage> triggerInput) { var client = EventHubClient.CreateFromConnectionString(triggerInput.inputs.eventHubConnectionString, triggerInput.inputs.eventHubName); EventHubConsumerGroup group = client.GetDefaultConsumerGroup(); //client.GetConsumerGroup(triggerInput.inputs.consumerGroup); string[] partitions; //If they specified partitions, iterate over their list to only listen to the partitions they specified if (!String.IsNullOrEmpty(triggerInput.inputs.eventHubPartitionList)) { partitions = triggerInput.inputs.eventHubPartitionList.Split(','); } //If they left it blank, create a list to listen to all partitions else { partitions = new string[client.GetRuntimeInformation().PartitionCount]; for(int x = 0; x < partitions.Length; x++) { partitions[x] = x.ToString(); } } //For ever partition I should listen to, create a thread with a listener on it foreach (var p in partitions) { p.Trim(); var reciever = group.CreateReceiver(client.GetRuntimeInformation().PartitionIds[int.Parse(p)], DateTime.UtcNow); EventHubListener listener = new EventHubListener(reciever); //Register the event. When I recieve a message, call the method to trigger the logic app listener.MessageReceived += (sender, e) => sendTrigger(sender, e, Runtime.FromAppSettings(), triggerInput.GetCallback()); listener.StartListening(); } //Register the triggerID in my store, so on subsequent checks from the logic app I don't spin up a new set of listeners _store[triggerId] = true; }
public override void HandleTrigger(TriggerInput _Output) { if (GetInput(DataInputs[0]) == GetInput(DataInputs[1]))Trigger(TriggerOutputs[0]); else Trigger(TriggerOutputs[1]); }
public override void HandleTrigger(TriggerInput _Input) { var sam = new System.Speech.Synthesis.SpeechSynthesizer(); sam.SpeakAsync(text); }
public override void HandleTrigger(TriggerInput _Input) { K8055.Initialize(); K8055.SetOutput(outputid - 1, (bool)GetInput(DataInputs[0])); }
public override void HandleTrigger(TriggerInput _Input) { if (_Input == TriggerInputs[0]) { invokedate = DateTime.Now.AddSeconds(val); Running = true; } if (_Input == TriggerInputs[1]) { Running = false; } }
public override void HandleTrigger(TriggerInput _Input) { if (DesktopClient.DesktopClient.MainStation == null) return; byte eventid = 0; ushort deviceid = 0; foreach (CodeBlock c in DesktopClient.DesktopClient.MainStation.Sequence.CodeBlocks) { if (c is MainStationCodeBlocks.BlockGenericEvent) { MainStationCodeBlocks.BlockGenericEvent evnt = (MainStationCodeBlocks.BlockGenericEvent)c; if (evnt.Name == Name) { eventid = evnt.GetEventID(); } } } if (eventid != 0) { MainStation.MainStation.InvokeLocalEvent(deviceid, eventid, 0); } }