private static void RegisterSymbolPath(IProduction production, UniqueList <ISymbol> symbolPath, int s) { if (s < production.RightHandSide.Count) { var postDotSymbol = production.RightHandSide[s]; symbolPath.AddUnique(postDotSymbol); } }
private static void RegisterSymbolPath(Production production, UniqueList <Symbol> symbolPath, int dot) { if (dot < production.Count) { var postDotSymbol = production[dot]; symbolPath.AddUnique(postDotSymbol); } }
private bool AddUniquePrediction(INormalState normalState) { if (_predictions == null) { _predictions = new UniqueList <INormalState>(); } return(_predictions.AddUnique(normalState)); }
private bool EnqueueTransition(ITransitionState transitionState) { if (_transitions == null) { _transitions = new UniqueList <ITransitionState>(); } return(_transitions.AddUnique(transitionState)); }
private bool AddUniqueScan(INormalState normalState) { if (_scans == null) { _scans = new UniqueList <INormalState>(); } return(_scans.AddUnique(normalState)); }
private bool AddUniqueCompletion(INormalState normalState) { if (_completions == null) { _completions = new UniqueList <INormalState>(); } return(_completions.AddUnique(normalState)); }
private bool EnqueueNormal(IState state, INormalState normalState) { if (!state.IsComplete) { var currentSymbol = state.PostDotSymbol; if (currentSymbol.SymbolType == SymbolType.NonTerminal) { return(_predictions.AddUnique(normalState)); } return(_scans.AddUnique(normalState)); } return(_completions.AddUnique(normalState)); }
private static void FindNullableSymbols( Dictionary <INonTerminal, UniqueList <IProduction> > reverseLookup, UniqueList <INonTerminal> nullable) { // trace nullability through productions: http://cstheory.stackexchange.com/questions/2479/quickly-finding-empty-string-producing-nonterminals-in-a-cfg // I think this is Dijkstra's algorithm var nullableQueue = new Queue <INonTerminal>(nullable); var productionSizes = new Dictionary <IProduction, int>(); // foreach nullable symbol discovered in forming the reverse lookup while (nullableQueue.Count > 0) { var nonTerminal = nullableQueue.Dequeue(); UniqueList <IProduction> productionsContainingNonTerminal = null; if (reverseLookup.TryGetValue(nonTerminal, out productionsContainingNonTerminal)) { for (int p = 0; p < productionsContainingNonTerminal.Count; p++) { var production = productionsContainingNonTerminal[p]; var size = 0; if (!productionSizes.TryGetValue(production, out size)) { size = production.RightHandSide.Count; productionSizes[production] = size; } for (var s = 0; s < production.RightHandSide.Count; s++) { var symbol = production.RightHandSide[s]; if (symbol.SymbolType == SymbolType.NonTerminal && nonTerminal.Equals(symbol)) { size--; } } if (size == 0 && nullable.AddUnique(production.LeftHandSide)) { nullableQueue.Enqueue(production.LeftHandSide); } productionSizes[production] = size; } } } }
internal bool Enqueue(DeterministicState frame) { var hasEnqueued = _states.AddUnique(frame); return(hasEnqueued); }
/// <summary> /// Processes a Publish response from the UA server. /// </summary> /// <param name="monitoredItem"></param> /// <param name="e"></param> void MonitoredItem_Notification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e) { try { EventFieldList eventFields = e.NotificationValue as EventFieldList; if (eventFields == null) { return; } if (monitoredItem != null) { if (monitoredItem.ClientHandle != eventFields.ClientHandle) { return; } } INode eventUA = monitoredItem.GetEventType(eventFields); EventCategory cat = FindEventCatInfo(eventUA.BrowseName.ToString()); if (cat == null) return; // The event is not of a category that we recognize. if (cat.EventType == OpcRcw.Ae.Constants.CONDITION_EVENT) { NodeId branchId = monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.ConditionType, Opc.Ua.BrowseNames.BranchId) as NodeId; if (!NodeId.IsNull(branchId)) return; // We don't support condition branches in the COM Proxy } EventNotification ev = new EventNotification(); ev.EventId = monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.EventId)) as byte[]; ev.SourceID = System.Convert.ToString(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.SourceName))); ev.Time = System.Convert.ToDateTime(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.Time))); ev.Message = System.Convert.ToString(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.Message))); ev.EventType = cat.EventType; ev.EventCategory = cat.CategoryID; ev.Severity = System.Convert.ToInt32(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.Severity))); List<EventAttribute> Attrs = GetEventAttributes(cat.CategoryID); UniqueList<string> strEventNodeIds = new UniqueList<string>(); foreach (EventAttribute attr in Attrs) if (attr.strEventNodeId != "") strEventNodeIds.AddUnique(attr.strEventNodeId); ev.EventAttributes = new Dictionary<int, object>(); foreach (EventAttribute attr in m_configFile.Attributes) { foreach (string strEventNodeId in strEventNodeIds) { if (attr.strEventNodeId == strEventNodeId) { object value = monitoredItem.GetFieldValue(eventFields, (NodeId)attr.strEventNodeId, new QualifiedName(attr.BrowseName, attr.BrowseNameNSIndex)); if (value == null) { ev.EventAttributes.Add(attr.AttributeID, ""); } else if ((value.GetType() != null) & (short)ComUtils.GetVarType(value) != 0) { ev.EventAttributes.Add(attr.AttributeID, value); } else { // any value with a UA type that does not have a corresponding COM type will be returned as a string ev.EventAttributes.Add(attr.AttributeID, value.ToString()); } } } } //Condition-Related Event properties ev.ConditionName = ""; ev.SubConditionName = ""; ev.ChangeMask = 0; ev.NewState = OpcRcw.Ae.Constants.CONDITION_ENABLED | OpcRcw.Ae.Constants.CONDITION_ACKED; ev.Quality = OpcRcw.Da.Qualities.OPC_QUALITY_GOOD; ev.AckRequired = false; ev.ActiveTime = DateTime.Now; ev.Cookie = 0; if (ev.EventType == OpcRcw.Ae.Constants.CONDITION_EVENT) SetConditionEventFields(monitoredItem, eventFields, ev, cat); //Tracking Events and for Condition-Related Events which are acknowledgment notifications if (cat.EventType == OpcRcw.Ae.Constants.TRACKING_EVENT) ev.ActorID = System.Convert.ToString(monitoredItem.GetFieldValue(eventFields, (NodeId)eventUA.NodeId, new QualifiedName(Opc.Ua.BrowseNames.ClientUserId))); IncomingEventHandler eventHandler = new IncomingEventHandler(); //extract the area associated with this event. AreaNode areaNode; string[] areas = null; if (m_notifiers.TryGetValue(monitoredItem.ClientHandle, out areaNode)) { areas = new string[] { areaNode.AreaName }; } eventHandler.ProcessEventNotificationList(ev, areas); } catch (Exception ex) { Utils.Trace(ex, "Unexpected error in MonitoredItem_Notification"); } }
internal bool Enqueue(StateFrame frame) { var hasEnqueued = _frames.AddUnique(frame); return(hasEnqueued); }
private bool EnqueueTransition(ITransitionState transitionState) { return(_transitions.AddUnique(transitionState)); }