public override void UpdateState(int chainIndex, ICommand[] outputStates) { UpdateState(chainIndex, outputStates.ToChannelValuesAsBytes()); }
public override void UpdateState(int chainIndex, ICommand[] outputStates) { Stopwatch stopWatch = Stopwatch.StartNew(); var channelValues = outputStates.ToChannelValuesAsBytes(); this._eventCnt++; if (_universeTable == null) { return; } foreach (var uE in this._universeTable) { if (uE.Active) { if (this._eventRepeatCount > 0) { if (uE.EventRepeatCount-- > 0) { if (E131Packet.CompareSlots(uE.PhyBuffer, channelValues, uE.Start, uE.Size)) { continue; } } } E131Packet.CopySeqNumSlots(uE.PhyBuffer, channelValues, uE.Start, uE.Size, this._seqNum++); uE.Socket.SendTo(uE.PhyBuffer, uE.DestIpEndPoint); uE.EventRepeatCount = this._eventRepeatCount; uE.PktCount++; uE.SlotCount += uE.Size; } } stopWatch.Stop(); this._totalTicks += stopWatch.ElapsedTicks; }
public override void UpdateState(int chainIndex, ICommand[] outputStates) { Stopwatch stopWatch = Stopwatch.StartNew(); //Make sure the setup form is closed & the plugin has started if (isSetupOpen && hasStarted) { return; } var channelValues = outputStates.ToChannelValuesAsBytes(); int universeSize = 0; this._eventCnt++; if (_universeTable == null) { return; } foreach (var uE in this._universeTable) { //Check if the universe is active and inside a valid channel range if (uE.Active && (uE.Start+1) <= OutputCount) { //Check the universe size boundary. if ((uE.Start + 1 + uE.Size) > OutputCount) { universeSize = OutputCount - uE.Start-1; } else { universeSize = uE.Size; } //Reduce duplicate packets //SeqNumbers are per universe so that they can run independently if (this._eventRepeatCount > 0) { if (uE.EventRepeatCount-- > 0) { if (E131Packet.CompareSlots(uE.PhyBuffer, channelValues, uE.Start, universeSize)) { continue; } } } //Not sure why this is needed, but the plugin will crash after being reconfigured otherwise. if (uE.PhyBuffer != null) { E131Packet.CopySeqNumSlots(uE.PhyBuffer, channelValues, uE.Start, universeSize, uE.seqNum++); uE.Socket.SendTo(uE.PhyBuffer, uE.DestIpEndPoint); uE.EventRepeatCount = this._eventRepeatCount; uE.PktCount++; uE.SlotCount += uE.Size; } } } stopWatch.Stop(); this._totalTicks += stopWatch.ElapsedTicks; }