Ejemplo n.º 1
0
        public InteractNode() : base(NodeType.Interact, UniqueId.NewId())
        {
            Name  = "Interact";
            Color = 0xFF_32cd32;

            OutputPins.Add(new FlowOutputPin(PinId.NewId(NodeId, PinType.Output, 0), string.Empty));
        }
        public ConstantReadNode(string serializedValue, string type) : base(NodeType.ConstantRead, UniqueId.NewId())
        {
            Name  = $"Constant - {type}";
            Color = HashColorConverter.GetColor(type);

            OutputPins.Add(new TypeOutputPin(PinId.NewId(NodeId, PinType.Output, 0), serializedValue, type));
        }
        public VariableGetNode(string variable, string type) : base(NodeType.VariableGet, UniqueId.NewId())
        {
            Name  = $"Get Variable - {type}";
            Color = HashColorConverter.GetColor(type);

            OutputPins.Add(new TypeOutputPin(PinId.NewId(NodeId, PinType.Output, 0), variable, type));
        }
Ejemplo n.º 4
0
        string PinToCordSound(PinId pin)
        {
            switch (pin)
            {
            case PinId.PIN_0:
                return("WhatTheHeck");

            case PinId.PIN_1:
                return(ApplemanNodes ? "Appleman_1(C)" : "1 (C1)");

            case PinId.PIN_2:
                return(ApplemanNodes ? "Appleman_2(D)" : "2 (Eb)");

            case PinId.PIN_3:
                return(ApplemanNodes ? "Appleman_3(E)" : "3 (F1)");

            case PinId.PIN_4:
                return(ApplemanNodes ? "Appleman_4(F)" : "4 (Ab)");

            case PinId.PIN_5:
                return(ApplemanNodes ? "Appleman_5(G)" : "5 (Bb)");

            case PinId.PIN_6:
                return("6 (C2)");

            case PinId.PIN_7:
                return("7 (Dd)");

            case PinId.PIN_8:
                return("8 (F2)");

            default:
                return("KeyboardPlayingSkill");
            }
        }
Ejemplo n.º 5
0
 public SetPinValueCommand(UniqueId node, PinId pin, string oldValue, string newValue)
 {
     _nodeId   = node;
     _pin      = pin;
     _oldValue = oldValue;
     _newValue = newValue;
 }
Ejemplo n.º 6
0
        public PlayerDialogueNode() : base(NodeType.PlayerDialogue, UniqueId.NewId())
        {
            Name  = "Player Dialogue";
            Color = 0xFF_87cefa;

            InputPins.Add(new FlowInputPin(PinId.NewId(NodeId, PinType.Input, 0)));
        }
Ejemplo n.º 7
0
        public ExitNode() : base(NodeType.Exit, UniqueId.NewId())
        {
            Name  = "Exit";
            Color = 0xFF_cd5c5c;

            InputPins.Add(new FlowInputPin(PinId.NewId(NodeId, PinType.Input, 0)));
        }
Ejemplo n.º 8
0
 public SetPinTypeValueCommand(PinId pin, string oldValue, string newValue, string oldType, string newType)
 {
     _pin      = pin;
     _oldValue = oldValue;
     _newValue = newValue;
     _oldType  = oldType;
     _newType  = newType;
 }
        public TriggerEventNode(string eventName) : base(NodeType.TriggerEvent, UniqueId.NewId())
        {
            Name  = "Trigger Event";
            Color = 0xFF_bdb76b;

            InputPins.Add(new FlowInputPin(PinId.NewId(NodeId, PinType.Input, 0)));

            OutputPins.Add(new FlowOutputPin(PinId.NewId(NodeId, PinType.Output, 0), eventName));
        }
Ejemplo n.º 10
0
        public static void Write(this BinaryWriter stream, PinId id)
        {
            stream.Write(id.Node);

            var bytes = id.GetPinBytes();

            stream.Write(bytes.Length);
            stream.Write(bytes);
        }
        public NpcDialogueNode() : base(NodeType.NpcDialogue, UniqueId.NewId())
        {
            Name  = "NPC Dialogue";
            Color = 0xFF_9370db;

            InputPins.Add(new FlowInputPin(PinId.NewId(NodeId, PinType.Input, 0)));

            OutputPins.Add(new FlowOutputPin(PinId.NewId(NodeId, PinType.Output, 0), string.Empty));
        }
Ejemplo n.º 12
0
        public VariableSetNode(string variable, string type) : base(NodeType.VariableSet, UniqueId.NewId())
        {
            Name  = $"Set Variable - {type}";
            Color = HashColorConverter.GetColor(type);

            InputPins.Add(new FlowInputPin(PinId.NewId(NodeId, PinType.Input, 0)));
            InputPins.Add(new TypeInputPin(PinId.NewId(NodeId, PinType.Input, 1), variable, type));

            OutputPins.Add(new FlowOutputPin(PinId.NewId(NodeId, PinType.Output, 0), string.Empty));
        }
Ejemplo n.º 13
0
        public BranchNode() : base(NodeType.Branch, UniqueId.NewId())
        {
            Name  = "Branch";
            Color = 0xFF_ff8c00;

            InputPins.Add(new FlowInputPin(PinId.NewId(NodeId, PinType.Input, 0)));
            InputPins.Add(new TypeInputPin(PinId.NewId(NodeId, PinType.Input, 1), "Condition", "Z"));

            OutputPins.Add(new FlowOutputPin(PinId.NewId(NodeId, PinType.Output, 0), "True"));
            OutputPins.Add(new FlowOutputPin(PinId.NewId(NodeId, PinType.Output, 1), "False"));
        }
Ejemplo n.º 14
0
        public void CreateConnection(PinId idA, PinId idB)
        {
            var(nodeA, pinA) = GetPin(idA);
            var(nodeB, pinB) = GetPin(idB);

            if (!pinA.CanConnectTo(pinB))
            {
                return;
            }

            if (pinB is IOutputPin && pinA is IInputPin)
            {
                // b -> a

                if (pinA is TypeInputPin && HasSource(pinA))
                {
                    return;
                }

                if (pinB is FlowOutputPin && HasDestination(pinB))
                {
                    nodeB.Connections.RemoveAll(connection => connection.Source == pinB.PinId);
                }

                nodeB.Connections.Add(new Connection(pinB.PinId, pinA.PinId));
            }
            else if (pinA is IOutputPin && pinB is IInputPin)
            {
                // a -> b

                if (pinB is TypeInputPin && HasSource(pinB))
                {
                    return;
                }

                if (pinA is FlowOutputPin && HasDestination(pinA))
                {
                    nodeA.Connections.RemoveAll(connection => connection.Source == pinA.PinId);
                }

                nodeA.Connections.Add(new Connection(pinA.PinId, pinB.PinId));
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Ejemplo n.º 15
0
        private void Mpr122IRQpin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                //read the touch status register and convert it in to CapsenseElectrode Enum
                int rawTouchRegisterData = readTouchStatusRegister();
                currentReading = (PinId)rawTouchRegisterData;

                List <PinId> allTouchedPins  = new List <PinId>();
                List <PinId> allReleasedPins = new List <PinId>();

                foreach (PinId val in Enum.GetValues(typeof(PinId))) //loop through all CapSense Pins
                {
                    if (val != PinId.None)
                    {
                        if (currentReading.HasFlag(val) && !lastReading.HasFlag(val))
                        {
                            allTouchedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(true);
                        }

                        if (!currentReading.HasFlag(val) && lastReading.HasFlag(val))
                        {
                            allReleasedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(false);
                        }
                    }
                }

                allTouchedPins.TrimExcess();
                allReleasedPins.TrimExcess();
                if (allTouchedPins.Count > 0)
                {
                    PinTouchedEventArgs touchedData = new PinTouchedEventArgs(allTouchedPins);
                    OnPinTouched(touchedData);
                }

                if (allReleasedPins.Count > 0)
                {
                    PinReleasedEventArgs releasedData = new PinReleasedEventArgs(allReleasedPins);
                    OnPinReleased(releasedData);
                }

                lastReading = currentReading;
            }
        }
Ejemplo n.º 16
0
        public PinReference GetPin(PinId pinId)
        {
            var node = this.FirstOrDefault(node1 => node1.NodeId == pinId.Node);

            if (node == null)
            {
                return(null);
            }

            var  pinIdx = pinId.GetIndex();
            IPin pin;

            switch (pinId.GetSide())
            {
            case PinType.Input:
            {
                if (pinIdx >= node.InputPins.Count)
                {
                    return(null);
                }

                pin = node.InputPins[pinIdx];
                break;
            }

            case PinType.Output:
            {
                if (pinIdx >= node.OutputPins.Count)
                {
                    return(null);
                }

                pin = node.OutputPins[pinIdx];
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(new PinReference(node, pin));
        }
Ejemplo n.º 17
0
        public void RemoveConnection(PinId idA, PinId idB)
        {
            var(nodeA, pinA) = GetPin(idA);
            var(nodeB, pinB) = GetPin(idB);

            if (pinB is IOutputPin && pinA is IInputPin)
            {
                // b -> a

                nodeB.Connections.RemoveAll(connection => connection.Source == idB && connection.Destination == idA);
            }
            else if (pinA is IOutputPin && pinB is IInputPin)
            {
                // a -> b

                nodeA.Connections.RemoveAll(connection => connection.Source == idA && connection.Destination == idB);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Ejemplo n.º 18
0
 /// <inheritdoc />
 public FlowOutputPin(PinId pinId, string name)
 {
     PinId = pinId;
     Name  = name;
 }
Ejemplo n.º 19
0
 public Connection(PinId source, PinId destination)
 {
     Source      = source;
     Destination = destination;
 }
        private void Mpr122IRQpin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                //read the touch status register and convert it in to CapsenseElectrode Enum
                int rawTouchRegisterData = readTouchStatusRegister();
                currentReading = (PinId)rawTouchRegisterData;

                List<PinId> allTouchedPins = new List<PinId>();
                List<PinId> allReleasedPins = new List<PinId>();

                foreach (PinId val in Enum.GetValues(typeof(PinId))) //loop through all CapSense Pins
                {
                    if (val != PinId.None)
                    {
                        if (currentReading.HasFlag(val) && !lastReading.HasFlag(val))
                        {
                            allTouchedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(true);
                        }

                        if (!currentReading.HasFlag(val) && lastReading.HasFlag(val))
                        {
                            allReleasedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(false);
                        }
                    }
                }

                allTouchedPins.TrimExcess();
                allReleasedPins.TrimExcess();
                if (allTouchedPins.Count > 0)
                {
                    PinTouchedEventArgs touchedData = new PinTouchedEventArgs(allTouchedPins);
                    OnPinTouched(touchedData);
                }

                if (allReleasedPins.Count>0)
                {
                    PinReleasedEventArgs releasedData = new PinReleasedEventArgs(allReleasedPins);
                    OnPinReleased(releasedData);
                }

                lastReading = currentReading;
            }
        }
Ejemplo n.º 21
0
 /// <inheritdoc />
 public FlowInputPin(PinId pinId)
 {
     PinId = pinId;
 }
Ejemplo n.º 22
0
 public Pin(PinId pinId, PinType pinType)
 {
     this.__pinId     = pinId;
     this.__pinType   = pinType;
     this.__pinNumber = Array.IndexOf(Enum.GetValues(typeof(PinId)), pinId) - 1;
 }
Ejemplo n.º 23
0
        private static RecordingLevel GetRecordingLevel(String ani, String siteId, String inmateId, String calledNumber, String initialRecordingLevel)
        {
            Int32  combinedRecordingLevel = 0;
            String strPinId = inmateId;

            if (!String.IsNullOrEmpty(strPinId))
            {
                strPinId = StringHelper.ApinToPinId(strPinId);
            }

            GlobalNumber global = GetGlobalNumbers(siteId).FirstOrDefault(x => x.Phone == calledNumber);

            using (NexusContext nexusContext = new NexusContext())
            {
                PinId    pin      = nexusContext.PinIds.FirstOrDefault(x => x.Pin == strPinId && x.SiteId == siteId);
                PinPhone pinPhone = nexusContext.PinPhones.FirstOrDefault(x => x.PhoneNumber == calledNumber && x.Pin == strPinId && x.SiteId == siteId);

                if (String.IsNullOrEmpty(initialRecordingLevel) && !String.IsNullOrEmpty((ani)))
                {
                    Circuit circuit = nexusContext.Circuits.FirstOrDefault(x => x.Ani == ani);
                    if (circuit != null)
                    {
                        initialRecordingLevel = circuit.RecordingLevel;
                    }
                }

                if (!String.IsNullOrEmpty(initialRecordingLevel))
                {
                    Int32.TryParse(initialRecordingLevel, out Int32 circuitRecordingLevel);
                    combinedRecordingLevel = circuitRecordingLevel;
                }

                if (pin != null && !String.IsNullOrEmpty(pin.RecordingLevel))
                {
                    Int32.TryParse(pin.RecordingLevel, out Int32 pinRecordingLevel);
                    combinedRecordingLevel |= pinRecordingLevel;
                }

                if (pinPhone != null && !String.IsNullOrEmpty(pinPhone.RecordingLevel))
                {
                    Int32.TryParse(pinPhone.RecordingLevel, out Int32 pinPhoneRecordingLevel);
                    combinedRecordingLevel |= pinPhoneRecordingLevel;
                }
                else if (global != null && global.Allowed)
                {
                    Int32.TryParse(global.RecordingLevelId, out Int32 globalRecordingLevel);
                    combinedRecordingLevel |= globalRecordingLevel;
                }

                if (combinedRecordingLevel == (Int32)RecordingLevel.Record)
                {
                    return(RecordingLevel.Record);
                }

                if ((combinedRecordingLevel & (Int32)RecordingLevel.DoNotRecord) > 0)
                {
                    return(RecordingLevel.DoNotRecord);
                }

                return(RecordingLevel.Impartial);
            }
        }
Ejemplo n.º 24
0
 public CreateConnectionCommand(PinId a, PinId b)
 {
     _a = a;
     _b = b;
 }
Ejemplo n.º 25
0
 public Pin(PinId pinId, PinType pinType)
 {
     this.__pinId = pinId;
     this.__pinType = pinType;
     this.__pinNumber = Array.IndexOf(Enum.GetValues(typeof(PinId)), pinId)-1;
 }     
Ejemplo n.º 26
0
 protected bool Equals(FlowOutputPin other)
 {
     return(PinId.Equals(other.PinId));
 }
Ejemplo n.º 27
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(PinId.GetHashCode());
 }
Ejemplo n.º 28
0
        public static Inmate GetInmate(GetInmateArguments args)
        {
            String strPinId = args.InmateId;

            if (!String.IsNullOrWhiteSpace(strPinId))
            {
                strPinId = StringHelper.ApinToPinId(strPinId);
            }

            if (String.IsNullOrWhiteSpace(strPinId) || String.IsNullOrWhiteSpace(args.SiteId))
            {
                throw new ArgumentException("Invalid inmate ID or site ID");
            }

            using (NexusContext ctx = new NexusContext())
            {
                PinId currentInmate = ctx.PinIds.FirstOrDefault(x => x.SiteId == args.SiteId && x.Pin == strPinId);

                if (currentInmate == null)
                {
                    throw new ArgumentException("Invalid inmate Id");
                }

                Inmate wsInmate = new Inmate
                {
                    PinId = currentInmate.Pin,
                    InmateIdentifierAtFacility = currentInmate.InmateReferenceId.GetValueOrDefault().ToString(),
                    Apin        = currentInmate.Apin,
                    SiteId      = currentInmate.SiteId,
                    DateOfBirth = StringHelper.DobToDateTime(currentInmate.Dob).GetValueOrDefault(),
                    ReleaseDate = (currentInmate.ReleaseDate ?? DateTime.Parse("1/1/1900")),
                    DateEntered = (currentInmate.DateEntered ?? DateTime.Parse("1/1/1900")),
                    Pin2        = currentInmate.Pin2,
                    Location    = currentInmate.Location,
                    Mailbox     = currentInmate.Mailbox,
                    FirstName   = currentInmate.Name,
                    MiddleName  = "",
                    LastName    = ""
                };

                //  split single name field in pin table to first, middle last
                String[] str = StringHelper.NameParts(currentInmate.Name);
                wsInmate.FirstName  = str[0];
                wsInmate.MiddleName = str[1];
                wsInmate.LastName   = str[2];

                if (currentInmate.Active.HasValue && currentInmate.Active.Value)
                {
                    wsInmate.InmateStatus = InmateStatus.Active;
                }
                else
                {
                    if (wsInmate.ReleaseDate > DateTime.Parse("1/1/1900"))
                    {
                        wsInmate.InmateStatus = InmateStatus.Released;
                    }
                    else
                    {
                        wsInmate.InmateStatus = InmateStatus.Inactive;
                    }
                }

                return(wsInmate);
            }
        }