/// <summary> /// Record an event for a given set of data provided. /// </summary> /// <param name="phase"></param> /// <param name="evtType"></param> /// <param name="recCnt"></param> /// <param name="clstrCnt"></param> /// <param name="recNo"></param> /// <param name="clstrNo"></param> internal void RecordEvent(Phase phase, EvtType evtType, int recCnt, int clstrCnt, int recNo, int clstrNo) { int seqNo; var prgSeqNo = 0; lock (_locker) { seqNo = ++_allEvtCntr; if (evtType == EvtType.Progress) { if (phase == Phase.Intake) { prgSeqNo = ++_prgsEvtCntrI; } if (phase == Phase.Transformation) { prgSeqNo = ++_prgsEvtCntrT; } if (phase == Phase.Output) { prgSeqNo = ++_prgsEvtCntrO; } } _events.Add(new EvtInstance(seqNo, phase, evtType, prgSeqNo, recCnt, clstrCnt, recNo, clstrNo)); } }
public void PushEvent(EvtType eType, int value = 0) { SNetEvent oEvent = new SNetEvent(); oEvent.eType = eType; oEvent.value = value; lock (m_oEvtQueue) { m_oEvtQueue.Enqueue(oEvent); } }
/// <summary> /// Parse the event payload and that as Payload object /// instead of a jsonstring /// </summary> public void Parse() { _Payload = JsonUtility.FromJson <Payload>(payload); switch (type) { case "ItemAddedEvent": _eventType = EvtType.ItemAddedEvent; break; case "ItemRemoved": _eventType = EvtType.ItemRemovedEvent; break; case "ItemUpdateEvent": _eventType = EvtType.ItemUpdatedEvent; break; case "ItemCommadEvent": _eventType = EvtType.ItemCommandEvent; break; case "ItemStateEvent": _eventType = EvtType.ItemStateEvent; break; case "ItemStateChangedEvent": _eventType = EvtType.ItemStateChangedEvent; break; default: _eventType = EvtType.None; break; } /** * ItemAddedEvent /added * ItemRemovedEvent /removed * ItemUpdatedEvent /updated * ItemCommandEvent /command * ItemStateEvent /state * ItemStateChangedEvent /statechanged (This is 99% of times what we want) **/ // smarthome/items/Power_gfRgbLedShelf/statechanged string[] parseTopic = topic.Split('/'); if (parseTopic.Length == 4) { itemId = parseTopic[2]; } }
/// <summary> /// Initialize the ItemController. /// </summary> /// <param name="serverUrl">server url from widget</param> /// <param name="itemId">item name from widget</param> /// <param name="subType">subscription type from widget</param> public void Initialize(string serverUrl, string itemId, EvtType subType) { _ServerURL = serverUrl; _ItemId = itemId; _SubscribeTo = subType; GetItemFromServer(); if (_SubscribeTo != EvtType.None) { _EventController = GameObject.FindGameObjectWithTag("Eventbus").GetComponent <EventController>(); if (_EventController != null) { _EventController.Subscribe(gameObject); } else { Debug.Log("Failed to find Eventbus. Are you sure you have an EventController attached to a GameObject with \"Eventbus\" tag."); } } }
public GameArgs(EvtType evt) { this.Evt = evt; }
public SNetEvent() { eType = EvtType.netevt_invalid; value = 0; }
internal EvtInstance(int seqNo, Phase phase, EvtType evtType, int prgSeqNo, int recCnt, int clstrCnt, int recNo, int clstrNo) { SeqNo = seqNo; Phase = phase; EvtType = evtType; PrgSeqNo = prgSeqNo; RecCnt = recCnt; ClstrCnt = clstrCnt; RecNo = recNo; ClstrNo = clstrNo; ThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId; }
private void CreateGesture(int touchIndex,EvtType message,Finger finger, SwipeDirection swipe, float swipeLength, Vector2 swipeVector) { bool firingEvent = true; if (autoUpdatePickedUI && allowUIDetection){ finger.isOverGui = IsScreenPositionOverUI( finger.position ); finger.pickedUIElement = GetFirstUIElementFromCache(); } // NGui if (enabledNGuiMode && message == EvtType.On_TouchStart){ finger.isOverGui = finger.isOverGui || IsTouchOverNGui(finger.position); } // firing event ? if ((enableUIMode || enabledNGuiMode)){ firingEvent = !finger.isOverGui; } // The new gesture Gesture gesture = finger.GetGesture(); // Auto update picked object if (autoUpdatePickedObject && autoSelect){ if (message != EvtType.On_Drag && message != EvtType.On_DragEnd && message != EvtType.On_DragStart){ if (GetPickedGameObject(finger)){ gesture.pickedObject = pickedObject.pickedObj; gesture.pickedCamera = pickedObject.pickedCamera; gesture.isGuiCamera = pickedObject.isGUI; } else{ gesture.pickedObject = null; gesture.pickedCamera = null; gesture.isGuiCamera = false; } } } gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = 0; gesture.twistAngle = 0; // Firing event if ( firingEvent){ RaiseEvent(message, gesture); } else if (finger.isOverGui){ if (message == EvtType.On_TouchUp){ RaiseEvent(EvtType.On_UIElementTouchUp, gesture); } else{ RaiseEvent(EvtType.On_OverUIElement, gesture); } } }
private void RaiseEvent(EvtType evnt, Gesture gesture) { gesture.type = evnt; switch(evnt){ case EvtType.On_Cancel: if (On_Cancel!=null) On_Cancel( gesture); break; case EvtType.On_Cancel2Fingers: if (On_Cancel2Fingers!=null) On_Cancel2Fingers( gesture ); break; case EvtType.On_TouchStart: if (On_TouchStart!=null) On_TouchStart( gesture); break; case EvtType.On_TouchDown: if (On_TouchDown!=null) On_TouchDown( gesture); break; case EvtType.On_TouchUp: if (On_TouchUp!=null) On_TouchUp( gesture ); break; case EvtType.On_SimpleTap: if (On_SimpleTap!=null) On_SimpleTap( gesture); break; case EvtType.On_DoubleTap: if (On_DoubleTap!=null) On_DoubleTap(gesture); break; case EvtType.On_LongTapStart: if (On_LongTapStart!=null) On_LongTapStart(gesture); break; case EvtType.On_LongTap: if (On_LongTap!=null) On_LongTap(gesture); break; case EvtType.On_LongTapEnd: if (On_LongTapEnd!=null) On_LongTapEnd(gesture); break; case EvtType.On_DragStart: if (On_DragStart!=null) On_DragStart(gesture); break; case EvtType.On_Drag: if (On_Drag!=null) On_Drag(gesture); break; case EvtType.On_DragEnd: if (On_DragEnd!=null) On_DragEnd(gesture); break; case EvtType.On_SwipeStart: if (On_SwipeStart!=null) On_SwipeStart( gesture); break; case EvtType.On_Swipe: if (On_Swipe!=null) On_Swipe( gesture); break; case EvtType.On_SwipeEnd: if (On_SwipeEnd!=null) On_SwipeEnd(gesture); break; case EvtType.On_TouchStart2Fingers: if (On_TouchStart2Fingers!=null) On_TouchStart2Fingers( gesture); break; case EvtType.On_TouchDown2Fingers: if (On_TouchDown2Fingers!=null) On_TouchDown2Fingers(gesture); break; case EvtType.On_TouchUp2Fingers: if (On_TouchUp2Fingers!=null) On_TouchUp2Fingers(gesture); break; case EvtType.On_SimpleTap2Fingers: if (On_SimpleTap2Fingers!=null) On_SimpleTap2Fingers(gesture); break; case EvtType.On_DoubleTap2Fingers: if (On_DoubleTap2Fingers!=null) On_DoubleTap2Fingers(gesture); break; case EvtType.On_LongTapStart2Fingers: if (On_LongTapStart2Fingers!=null) On_LongTapStart2Fingers(gesture); break; case EvtType.On_LongTap2Fingers: if (On_LongTap2Fingers!=null) On_LongTap2Fingers(gesture); break; case EvtType.On_LongTapEnd2Fingers: if (On_LongTapEnd2Fingers!=null) On_LongTapEnd2Fingers(gesture); break; case EvtType.On_Twist: if (On_Twist!=null) On_Twist(gesture); break; case EvtType.On_TwistEnd: if (On_TwistEnd!=null) On_TwistEnd(gesture); break; case EvtType.On_Pinch: if (On_Pinch!=null) On_Pinch(gesture); break; case EvtType.On_PinchIn: if (On_PinchIn!=null) On_PinchIn(gesture); break; case EvtType.On_PinchOut: if (On_PinchOut!=null) On_PinchOut(gesture); break; case EvtType.On_PinchEnd: if (On_PinchEnd!=null) On_PinchEnd(gesture); break; case EvtType.On_DragStart2Fingers: if (On_DragStart2Fingers!=null) On_DragStart2Fingers(gesture); break; case EvtType.On_Drag2Fingers: if (On_Drag2Fingers!=null) On_Drag2Fingers(gesture); break; case EvtType.On_DragEnd2Fingers: if (On_DragEnd2Fingers!=null) On_DragEnd2Fingers(gesture); break; case EvtType.On_SwipeStart2Fingers: if (On_SwipeStart2Fingers!=null) On_SwipeStart2Fingers(gesture); break; case EvtType.On_Swipe2Fingers: if (On_Swipe2Fingers!=null) On_Swipe2Fingers(gesture); break; case EvtType.On_SwipeEnd2Fingers: if (On_SwipeEnd2Fingers!=null) On_SwipeEnd2Fingers(gesture); break; case EvtType.On_OverUIElement: if (On_OverUIElement!=null){ On_OverUIElement(gesture); } break; case EvtType.On_UIElementTouchUp: if (On_UIElementTouchUp!=null){ On_UIElementTouchUp( gesture); } break; } // Direct Acces int result = _currentGestures.FindIndex( delegate(Gesture obj) { return obj.type == gesture.type && obj.fingerIndex == gesture.fingerIndex; } ); if (result>-1){ _currentGestures[result].touchCount = gesture.touchCount; _currentGestures[result].position = gesture.position; _currentGestures[result].actionTime = gesture.actionTime; _currentGestures[result].pickedCamera = gesture.pickedCamera; _currentGestures[result].pickedObject = gesture.pickedObject; _currentGestures[result].pickedUIElement = gesture.pickedUIElement; _currentGestures[result].isOverGui = gesture.isOverGui; _currentGestures[result].isGuiCamera = gesture.isGuiCamera; // Update delta from current _currentGestures[result].deltaPinch += gesture.deltaPinch; _currentGestures[result].deltaPosition += gesture.deltaPosition; _currentGestures[result].deltaTime += gesture.deltaTime; _currentGestures[result].twistAngle += gesture.twistAngle; } if (result==-1 ){ _currentGestures.Add( (Gesture)gesture.Clone()); if (_currentGestures.Count>0){ _currentGesture = _currentGestures[0]; } } }
private void CreateGesture2Finger(EvtType message,Vector2 startPosition,Vector2 position,Vector2 deltaPosition, float actionTime, SwipeDirection swipe, float swipeLength,Vector2 swipeVector,float twist,float pinch, float twoDistance) { bool firingEvent = true; Gesture gesture = new Gesture(); gesture.isOverGui = false; // NGui if (enabledNGuiMode && message == EvtType.On_TouchStart2Fingers){ gesture.isOverGui = gesture.isOverGui || ( IsTouchOverNGui(twoFinger.position) && IsTouchOverNGui(twoFinger.position)); } gesture.touchCount=2; gesture.fingerIndex=-1; gesture.startPosition = startPosition; gesture.position = position; gesture.deltaPosition = deltaPosition; gesture.actionTime = actionTime; gesture.deltaTime=Time.deltaTime; gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = pinch; gesture.twistAngle = twist; gesture.twoFingerDistance = twoDistance; gesture.pickedObject = twoFinger.pickedObject; gesture.pickedCamera = twoFinger.pickedCamera; gesture.isGuiCamera= twoFinger.isGuiCamera; if (autoUpdatePickedObject){ if (message != EvtType.On_Drag && message != EvtType.On_DragEnd && message != EvtType.On_Twist && message != EvtType.On_TwistEnd && message != EvtType.On_Pinch && message != EvtType.On_PinchEnd && message != EvtType.On_PinchIn && message != EvtType.On_PinchOut){ if (GetTwoFingerPickedObject()){ gesture.pickedObject = pickedObject.pickedObj; gesture.pickedCamera = pickedObject.pickedCamera; gesture.isGuiCamera= pickedObject.isGUI; } else{ twoFinger.ClearPickedObjectData(); } } } gesture.pickedUIElement = twoFinger.pickedUIElement; gesture.isOverGui = twoFinger.isOverGui; if (allowUIDetection && autoUpdatePickedUI){ if (message != EvtType.On_Drag && message != EvtType.On_DragEnd && message != EvtType.On_Twist && message != EvtType.On_TwistEnd && message != EvtType.On_Pinch && message != EvtType.On_PinchEnd && message != EvtType.On_PinchIn && message != EvtType.On_PinchOut){ if (message == EvtType.On_SimpleTap2Fingers) if (GetTwoFingerPickedUIElement()){ gesture.pickedUIElement = pickedObject.pickedObj; gesture.isOverGui = true; } else{ twoFinger.ClearPickedUIData(); } } } // Firing event ? if ((enableUIMode || (enabledNGuiMode && allowUIDetection) ) ){ firingEvent = !gesture.isOverGui; } // Firing event if ( firingEvent){ RaiseEvent(message, gesture); } else if (gesture.isOverGui){ if (message == EvtType.On_TouchUp2Fingers){ RaiseEvent(EvtType.On_UIElementTouchUp, gesture); } else{ RaiseEvent(EvtType.On_OverUIElement, gesture); } } }