public void VisitIdentifier(string identifier, string appName, bool isRaw, bool isNoLog) { m_symbolTable.GetId(identifier, appName, id => { var value = m_context.GetValue(id, isRaw, isNoLog); m_stack.Push(value); }, () => m_stack.Push(double.NaN)); }
public void VisitIdentifier(string identifier, string appName, bool isRaw, bool isNoLog) { m_symbolTable.GetId(identifier, appName, id => { m_stack.Push(Expression.Call(Expression.Constant(m_context), m_context.GetType().GetMethod("GetValue"), new [] { Expression.Constant(id), Expression.Constant(isRaw), Expression.Constant(isNoLog) })); }, () => { m_stack.Push(Expression.Constant(double.NaN)); }); }
public void VisitIdentifier(string identifier, string appName, bool isRaw, bool isNoLog) { m_symbolTable.GetId(identifier, appName, id => { if (isNoLog) { m_nologParameters.Add(id); } else { m_loggedParameters.Add(id); } }, () => throw new Exception($"Unknown identifier {identifier}:{appName}")); }
public void Build(string virtualParameterName, string formula, int rateInMilliHz, Action <IVirtualChannel <TTime>, bool> built, Action <Exception> failed) { try { m_symbolTable.GetId(virtualParameterName, string.Empty, virtualParameterId => { var expression = SMExpressionParser.ParseOrThrow(formula); var visitor = new VirtualChannelBuilderVisitor(m_symbolTable); expression.Accept(visitor); if (visitor.IsAlias()) { built(new AliasVirtualChannel <TTime>(visitor.LoggedParameters.First(), virtualParameterId), false); } else if (visitor.IsSlowRow()) { if (m_slowRowRateInMilliHz != rateInMilliHz) { failed(new ArgumentException($"{virtualParameterName} has rate {rateInMilliHz}, but it is slow row")); } built(new SlowRowVirtualChannel <TTime>(expression, virtualParameterId, rateInMilliHz, m_symbolTable, m_slowRowStorage, m_timeUtils), true); } else if (visitor.LoggedParameters.Count() == 1) { built(new SingleLoggedParameterVirtualChannel <TTime>(expression, virtualParameterId, visitor.LoggedParameters.First(), rateInMilliHz, m_symbolTable, m_slowRowStorage, m_timeUtils), false); } else { built(new MultiLoggedParametersVirtualChannel <TTime>(expression, virtualParameterId, visitor.LoggedParameters.ToArray(), rateInMilliHz, m_symbolTable, m_slowRowStorage, m_timeUtils), false); } }, () => { failed(new KeyNotFoundException($"Virtual parameter name {virtualParameterName} not found")); }); } catch (Exception e) { failed(e); } }