static void Main(string[] args) { //"using" is recommended for correct usage of IDisposable interface using (IListenerBoard board = GetListenerBoard()) //expected listener board is piso-813 analog input card, expected output card is piso-da2/da2u { var boardId = board.CardSearch(); Console.WriteLine($"BoardId={boardId}"); var cardResult = board.CardPoll(); Console.WriteLine($"card result={cardResult}"); Console.ReadLine(); } outputBoard = new OutputBoard(); //remove comments and set as startup for enabling console mode outputBoard.BoardPushValue(2); }
public CalculationViewModel() { _cardPollTimer = new Timer(25); InternalQueue = new DoubleFixedSizeQueue(100); InternalOutputQueue = new DoubleFixedSizeQueue(100); InternalInputAnodeQueue = new DoubleFixedSizeQueue(100); InternalInputPowerQueue = new DoubleFixedSizeQueue(100); InternalOutputAnodeQueue = new DoubleFixedSizeQueue(100); InternalOutputPowerQueue = new DoubleFixedSizeQueue(100); XAxisTimerQueue = new DateTimeFixedSizeQueue(100); AngleValueK = new DoubleFixedSizeQueue(100); _cardPollTimer.Elapsed += (s, e) => { try { _cardPollTimer.Stop(); InboundVoltage = Math.Round(_board.CardPoll(), 4, MidpointRounding.ToEven); InternalQueue.Enqueue(InboundVoltage); VoltageAveraging(); OnPropertyChanged("InternalQueue"); XAxisTimerQueue.Enqueue(DateTime.Now); OnPropertyChanged("XAxisTimerQueue"); double _internalInputAnodeQueue = Math.Round((InboundVoltage * ValueFromRangeDAC((float)InboundVoltage) + ShiftAmountBDAC((float)InboundVoltage)) / 10, 4, MidpointRounding.ToEven); InternalInputAnodeQueue.Enqueue(_internalInputAnodeQueue); OnPropertyChanged("OutboundAnodeCurrentActive"); double _internalInputPowerQueue = Math.Round(3 * InboundVoltage * ValueFromRangeDAC((float)InboundVoltage + ShiftAmountBDAC((float)InboundVoltage)) / 10, 4, MidpointRounding.ToEven); InternalInputPowerQueue.Enqueue(_internalInputPowerQueue); OnPropertyChanged("OutboundPowerActive"); AngleValueK.Enqueue(ValueFromRangeDAC((float)InboundVoltage)); OnPropertyChanged("AngleValueK"); InternalOutputQueue.Enqueue(OutboundCurrentActive); OnPropertyChanged("OutboundCurrentActive"); double _internalOutputAnodeQueue = Math.Round(10 * _outboundCurrentActive * ValueFromRange(10 * (float)_outboundCurrentActive) + ShiftAmountB(10 * (float)_outboundCurrentActive), 4, MidpointRounding.ToEven); InternalOutputAnodeQueue.Enqueue(_internalOutputAnodeQueue); OnPropertyChanged("OutboundCurrentActiveAnode"); double _internalOutputPowerQueue = Math.Round(10 * (_outboundCurrentActive / 3) * ValueFromRange(10 * ((float)_outboundCurrentActive / 3)) + ShiftAmountB(10 * ((float)_outboundCurrentActive / 3))); InternalOutputPowerQueue.Enqueue(_internalOutputPowerQueue); OnPropertyChanged("OutboundCurrentActivePower"); if (_autoModeActive) { AutoMode(2); } //IQ = InternalQueue; OACA = OutboundAnodeCurrentActive; OPA = OutboundPowerActive; OCA = OutboundCurrentActive; OCAA = OutboundCurrentActiveAnode; OCAP = OutboundCurrentActivePower; _logger.Info($"IQ = {InboundVoltage}, OACA={_internalInputAnodeQueue}, OPA={_internalInputPowerQueue}, OCA={OutboundCurrentActive}, OCAA={_internalOutputAnodeQueue}, OCAP={_internalOutputPowerQueue}"); } finally { _cardPollTimer.Start(); } }; }