Ejemplo n.º 1
0
 public MultiDimInStream(IIOFactory factory, InputAttribute attribute)
 {
     FDataContainer    = factory.CreateIOContainer <IInStream <T> >(attribute.DecreaseBinSizeWrapCount(), false);
     FBinSizeContainer = factory.CreateIOContainer <IInStream <int> >(attribute.GetBinSizeInputAttribute(FDataContainer), false);
     FDataStream       = FDataContainer.IOObject;
     FBinSizeStream    = FBinSizeContainer.IOObject;
 }
Ejemplo n.º 2
0
            public QueryInfo(string Name, IIOFactory IOFactory)
            {
                string pinName = Name;        //.Replace("/"," ");

//              if (pinName.StartsWith("/"))
//                  pinName = pinName.Replace("/","|");
                this.Name            = Name;
                QueryExistsContainer = IOFactory.CreateIOContainer <IOutStream <bool> >(new OutputAttribute(pinName + " Available")
                {
                    Visibility = PinVisibility.OnlyInspector
                });
                QueryExistsContainer.IOObject.Length = 0;
                QueryContainer = IOFactory.CreateIOContainer <IOutStream <string> >(new OutputAttribute(pinName));
                QueryContainer.IOObject.Length = 0;
                FirstContainer = IOFactory.CreateIOContainer <IOutStream <XElement> >(new OutputAttribute(pinName + " (Child)")
                {
                    Visibility = PinVisibility.OnlyInspector
                });
                FirstContainer.IOObject.Length = 0;
                AllContainer = IOFactory.CreateIOContainer <IOutStream <IInStream <XElement> > >(
                    new OutputAttribute(pinName + " (Children)")
                {
                    Visibility = PinVisibility.OnlyInspector, BinVisibility = PinVisibility.OnlyInspector
                });

                AllContainer.IOObject.Length = 0;
            }
Ejemplo n.º 3
0
 private void HandleInputCountChanged(IDiffSpread <int> sender)
 {
     if (_controlInputs.SliceCount > sender[0])
     {
         while (_controlInputs.SliceCount > sender[0])
         {
             _nameInputs.Last().Dispose();
             _nameInputs.SliceCount--;
             _controlInputs.Last().Dispose();
             _controlInputs.SliceCount--;
         }
         //_controlInputs.SliceCount = sender[0];
         //_nameInputs.SliceCount = sender[0];
     }
     else
     {
         var i = _nameInputs.SliceCount;
         _controlInputs.SliceCount = sender[0];
         for (_nameInputs.SliceCount = sender[0]; i < sender[0]; i++)
         {
             _nameInputs[i] = IOFactory.CreateIOContainer <IDiffSpread <string> >(new InputAttribute("Name " + (i + 1))
             {
                 IsSingle = true, DefaultString = "Tab " + (i + 1), Order = i + 10
             });
             _controlInputs[i] = IOFactory.CreateIOContainer <IDiffSpread <Control> >(new InputAttribute("Control " + (i + 1))
             {
                 Order = i + 11
             });
         }
     }
 }
Ejemplo n.º 4
0
 public MultiDimInStream(IIOFactory factory, InputAttribute attribute)
 {
     FDataContainer    = factory.CreateIOContainer <IInStream <T> >(attribute, false);
     FBinSizeContainer = factory.CreateIOContainer <IInStream <int> >(attribute.GetBinSizeInputAttribute(), false);
     FDataStream       = FDataContainer.IOObject;
     FBinSizeStream    = (IntInStream)FBinSizeContainer.IOObject;
 }
Ejemplo n.º 5
0
 public bool CreateIO(IIOFactory ioFactory, Dictionary <Field, IOContainer> ioContainers, Field field, bool isInput = true, bool isBinSized = false, int order = 0)
 {
     if (ioContainers.ContainsKey(field))
     {
         ioContainers[field].SetOrder(order);
         return(false);
     }
     else
     {
         if (isInput)
         {
             var inAttr = new InputAttribute(field.Name)
             {
                 Order = order, AutoValidate = false, Visibility = PinVisibility.Hidden
             };
             var ioCont = ioFactory.CreateIOContainer(typeof(INodeIn), inAttr);
             ioContainers.Add(field, new IOContainer(ioCont, isInput, false, order));
         }
         else
         {
             var outAttr = new OutputAttribute(field.Name)
             {
                 Order = order, Visibility = PinVisibility.Hidden
             };                                                                                                  //, AutoFlush = false
             var ioCont = ioFactory.CreateIOContainer(typeof(INodeOut), outAttr);
             ioContainers.Add(field, new IOContainer(ioCont, isInput, false, order));
             //(ioContainers[field].RawIOObject as ISpread).SliceCount = 0;
         }
     }
     return(true);
 }
Ejemplo n.º 6
0
        private void InputCountConfigOnChanged(IDiffSpread <int> sender)
        {
            if (_elementInputs.SliceCount > sender[0])
            {
                for (var i = _elementInputs.SliceCount - 1; i > sender[0]; i--)
                {
                    _elementInputs.RemoveAt(i);
                    _elementInputs.SliceCount = i;
                    _nameInputs.RemoveAt(i);
                    _nameInputs.SliceCount = i;

                    ((TabControl)UIElementOut[0]).Items.RemoveAt(i);
                }
            }
            else if (_elementInputs.SliceCount < sender[0])
            {
                _elementInputs.SliceCount = sender[0];
                _nameInputs.SliceCount    = sender[0];

                for (var i = sender[0] - _elementInputs.SliceCount; i < sender[0]; i++)
                {
                    _elementInputs[i] = IOFactory.CreateIOContainer <IDiffSpread <UIElement> >(new InputAttribute("Element " + (i + 1))
                    {
                        IsSingle = true, Order = i + 11
                    });
                    _nameInputs[i] = IOFactory.CreateIOContainer <IDiffSpread <string> >(new InputAttribute("Name " + (i + 1))
                    {
                        IsSingle = true, DefaultString = "Tab " + (i + 1), Order = i + 10
                    });
                }
            }
        }
Ejemplo n.º 7
0
        private void ManageDiffOutput(IDiffSpread <bool> advanced)
        {
            if (FAdvanced[0])
            {
                Keep.QuickMode = false;

                var ia = new InputAttribute("Include input in Diff");
                ia.Order          = 2;
                ia.IsSingle       = true;
                ia.IsToggle       = true;
                ia.DefaultBoolean = true;

                Type pinType = typeof(IDiffSpread <>).MakeGenericType(typeof(bool));
                DoAllChange = FIOFactory.CreateIOContainer(pinType, ia);
                var pin = DoAllChange.RawIOObject as IDiffSpread <bool>;
                pin.Changed += UpdateChangeAll;

                var attr = new OutputAttribute("Message Diff");
                attr.AutoFlush = false;
                attr.Order     = 2;

                pinType    = typeof(Pin <>).MakeGenericType(typeof(Message));
                Change     = FIOFactory.CreateIOContainer(pinType, attr);
                FChangeOut = Change.RawIOObject as Pin <Message>;

                attr           = new OutputAttribute("Changed Message Index");
                attr.AutoFlush = false;
                attr.Order     = 3;

                pinType         = typeof(ISpread <>).MakeGenericType(typeof(int));
                ChangeIndex     = FIOFactory.CreateIOContainer(pinType, attr);
                FChangeIndexOut = ChangeIndex.RawIOObject as Pin <int>;
            }
            else
            {
                Keep.QuickMode = true;

                if (DoAllChange != null)
                {
                    DoAllChange.Dispose();
                    DoAllChange      = null;
                    ManageAllChanges = true;
                }

                if (ChangeIndex != null)
                {
                    ChangeIndex.Dispose();
                    ChangeIndex     = null;
                    FChangeIndexOut = null;
                }

                if (FChangeOut != null)
                {
                    Change.Dispose();
                    Change     = null;
                    FChangeOut = null;
                }
            }
        }
Ejemplo n.º 8
0
        public void OnImportsSatisfied()
        {
            FInputContainer = FFactory.CreateIOContainer <IInStream <IInStream <T> > >(
                new InputAttribute("Input"));

            FOutputContainer = FFactory.CreateIOContainer <IOutStream <IInStream <T> > >(
                new OutputAttribute("Output"));
        }
Ejemplo n.º 9
0
 public OutputBinSpreadStream(IIOFactory ioFactory, OutputAttribute attribute)
 {
     FDataContainer    = ioFactory.CreateIOContainer <IOutStream <T> >(attribute, false);
     FBinSizeContainer = ioFactory.CreateIOContainer <IOutStream <int> >(attribute.GetBinSizeOutputAttribute(), false);
     FDataStream       = FDataContainer.IOObject;
     FBinSizeStream    = FBinSizeContainer.IOObject;
     Length            = 1;
 }
Ejemplo n.º 10
0
 public MultiDimOutStream(IIOFactory ioFactory, OutputAttribute attribute)
 {
     FDataContainer    = ioFactory.CreateIOContainer <IOutStream <T> >(attribute.DecreaseBinSizeWrapCount(), false);
     FBinSizeContainer = ioFactory.CreateIOContainer <IOutStream <int> >(attribute.GetBinSizeOutputAttribute(FDataContainer), false);
     FDataStream       = FDataContainer.IOObject;
     FBinSizeStream    = FBinSizeContainer.IOObject;
     Length            = 1;
 }
Ejemplo n.º 11
0
        private Struct CreatePins(Definition definition)
        {
            Struct s    = new Struct(FStructDefName);
            var    pins = new Dictionary <string, IIOContainer>();

            foreach (var entry in definition.Types)
            {
                string key = entry.Key + entry.Value;
                if (FPins.ContainsKey(key))
                {
                    pins.Add(key, FPins[key]);
                    s.Data.Add(key, FPins[key].RawIOObject);
                    FPins.Remove(key);

                    if (!FIsJoin)                     //create output bin size
                    {
                        string binKey = "Bin" + key;
                        pins.Add(binKey, FPins[binKey]);
                        FPins.Remove(binKey);
                    }
                }
                else
                {
                    Type        pinType = typeof(ISpread <>).MakeGenericType(entry.Value);
                    IOAttribute attr;
                    if (FIsJoin)
                    {
                        attr = new InputAttribute(entry.Key);
                        attr = TrySetDefault(attr as InputAttribute, entry.Value, definition.Defaults[entry.Key]);
                    }
                    else
                    {
                        attr = new OutputAttribute(entry.Key);
                    }

                    var pin = FIOFactory.CreateIOContainer(pinType, attr);
                    pins.Add(key, pin);
                    s.Data.Add(key, pin.RawIOObject);

                    if (!FIsJoin)                     //create output bin size
                    {
                        attr.Name       = attr.Name + " Bin Size";
                        attr.Visibility = PinVisibility.OnlyInspector;
                        pinType         = typeof(ISpread <>).MakeGenericType(typeof(int));
                        pins.Add("Bin" + key, FIOFactory.CreateIOContainer(pinType, attr));
                    }
                }
            }

            foreach (var oldPin in FPins.Values)
            {
                oldPin.Dispose();
            }

            FPins = pins;
            return(s);
        }
Ejemplo n.º 12
0
        public bool CreateIO(IIOFactory ioFactory, Dictionary <Field, IOContainer> ioContainers, Field field, bool isInput = true, bool isBinSized = false, int order = 0)
        {
            Type t = typeof(IIOStream <IInStream <double> >);

            if (isBinSized)
            {
                t = typeof(IInStream <>).MakeGenericType(field.FieldType);
                if (isInput)
                {
                    t = typeof(IInStream <>).MakeGenericType(t);
                }
                else
                {
                    t = typeof(IIOStream <>).MakeGenericType(t);
                }
            }
            else
            if (isInput)
            {
                t = typeof(IInStream <>).MakeGenericType(field.FieldType);
            }
            else
            {
                t = typeof(IOutStream <>).MakeGenericType(field.FieldType);
            }


            if (ioContainers.ContainsKey(field))
            {
                ioContainers[field].SetOrder(order);
                return(false);
            }
            else
            {
                if (isInput)
                {
                    var inAttr = new InputAttribute(field.Name)
                    {
                        Order = order, BinOrder = order + 1, AutoValidate = false
                    };
                    inAttr.SetDefaultAttribute(field);
                    var ioCont = ioFactory.CreateIOContainer(t, inAttr);
                    ioContainers.Add(field, new IOContainer(ioCont, isInput, isBinSized, order));
                }
                else
                {
                    var outAttr = new OutputAttribute(field.Name)
                    {
                        Order = order, BinOrder = order + 1
                    };                                                                                     //, AutoFlush = false
                    var ioCont = ioFactory.CreateIOContainer(t, outAttr);
                    ioContainers.Add(field, new IOContainer(ioCont, isInput, isBinSized, order));
                    (ioContainers[field].RawIOObject as IOutStream).Length = 0;
                }
            }
            return(true);
        }
Ejemplo n.º 13
0
        public void AddInput(Type T, InputAttribute attr)
        {
            Type pinType = typeof(IDiffSpread <>).MakeGenericType(T);
            var  ioc     = FIOFactory.CreateIOContainer(pinType, attr);
            var  ispread = ioc.ToIDiffSpread();
            var  pin     = new DiffSpreadPin(ispread, attr, ioc);

            InputPins.Add(attr.Name, pin);
            pin.Type = T;
        }
Ejemplo n.º 14
0
        public void OnImportsSatisfied()
        {
            FInputContainer = FFactory.CreateIOContainer <ISpread <ISpread <T> > >(
                new InputAttribute("Input")
            {
                BinSize = 1
            });

            FOutputContainer = FFactory.CreateIOContainer <ISpread <ISpread <T> > >(
                new OutputAttribute("Output"));
        }
Ejemplo n.º 15
0
        public void OnImportsSatisfied()
        {
            FInputContainer = FFactory.CreateIOContainer <IInStream <T> >(
                new InputAttribute("Input")
            {
                BinSize = -2
            });

            FOutputContainer = FFactory.CreateIOContainer <IInStream <IOutStream <T> > >(
                new OutputAttribute("Output")
            {
                IsPinGroup = true
            });
        }
Ejemplo n.º 16
0
        public void OnImportsSatisfied()
        {
            FSpreadContainer = FFactory.CreateIOContainer <ISpread <ISpread <T> > >(
                new InputAttribute("Spread"));

            FInputContainer = FFactory.CreateIOContainer <ISpread <ISpread <T> > >(
                new InputAttribute("Input")
            {
                BinSize = 1, BinName = "Count", BinOrder = 1
            });

            FOutputContainer = FFactory.CreateIOContainer <ISpread <ISpread <T> > >(
                new OutputAttribute("Output"));
        }
Ejemplo n.º 17
0
        #pragma warning restore
        #endregion fields & pins

        public void OnImportsSatisfied()
        {
            FInputContainer = FFactory.CreateIOContainer <IInStream <T> >(
                new InputAttribute("Input")
            {
                CheckIfChanged = true, AutoValidate = false
            });

            FRemainderContainer = FFactory.CreateIOContainer <IOutStream <T> >(
                new OutputAttribute("Remainder"));

            FLastContainer = FFactory.CreateIOContainer <IOutStream <T> >(
                new OutputAttribute("Last Slice"));
        }
Ejemplo n.º 18
0
 private void SetInputs()
 {
     if (FInputCount[0] != FInputs.Count)
     {
         if (FInputCount[0] > FInputs.Count)
         {
             while (FInputCount[0] > FInputs.Count)
             {
                 InputAttribute attr = new InputAttribute("Input " + Convert.ToString(FInputs.Count + 1));
                 attr.CheckIfChanged = true;
                 IIOContainer <Pin <IEntity> > pin = FIOFactory.CreateIOContainer <Pin <IEntity> >(attr);
                 pin.IOObject.SliceCount = 0;
                 FInputs.Add(pin);
             }
         }
         else
         {
             while (FInputCount[0] < FInputs.Count)
             {
                 FInputs[FInputs.Count - 1].Dispose();
                 FInputs.RemoveAt(FInputs.Count - 1);
             }
         }
     }
 }
Ejemplo n.º 19
0
        private void InputCountConfigOnChanged(IDiffSpread <int> sender)
        {
            if (_elementInputs.SliceCount > sender[0])
            {
                for (var i = _elementInputs.SliceCount - 1; i >= sender[0]; i--)
                {
                    if (((Grid)UIElementOut[0]).Children.Contains(_elementInputs[i].IOObject[0]))
                    {
                        ((Grid)UIElementOut[0]).Children.Remove(_elementInputs[i].IOObject[0]);
                    }

                    _elementInputs[i].Dispose();
                    _elementInputs.SliceCount = i;
                }
            }
            else if (_elementInputs.SliceCount < sender[0])
            {
                var oldCount = _elementInputs.SliceCount;

                _elementInputs.SliceCount = sender[0];

                for (var i = oldCount; i < sender[0]; i++)
                {
                    _elementInputs[i] = IOFactory.CreateIOContainer <IDiffSpread <UIElement> >(new InputAttribute("Element " + (i + 1))
                    {
                        IsSingle = true, Order = i + 11
                    });
                }
            }
        }
Ejemplo n.º 20
0
        void KeyMatchChangedCB(IDiffSpread <string> sender)
        {
            var keys = FKeyMatch[0].Split(',').ToList().Select(s => s.Trim()).Where(s => s.Length > 0).Select(s => FormatNicely(s)).ToArray();

            //add new pins
            foreach (var key in keys)
            {
                var lowerKey = key.ToLower();
                if (!string.IsNullOrWhiteSpace(key) && !FOutputInfos.Any(info => info.Key == key))
                {
                    var outAttr = new OutputAttribute(key);
                    outAttr.IsSingle = true;
                    var outputInfo = new OutputInfo()
                    {
                        Key        = key,
                        KeyToLower = lowerKey,
                        Container  = FIOFactory.CreateIOContainer <ISpread <bool> >(outAttr),
                    };
                    FOutputInfos.Add(outputInfo);
                }
            }

            //remove obsolete pins
            foreach (var outputInfo in FOutputInfos.ToArray())
            {
                if (!keys.Contains(outputInfo.Key))
                {
                    FOutputInfos.Remove(outputInfo);
                    outputInfo.Container.Dispose();
                }
            }
        }
Ejemplo n.º 21
0
        //pin management
        void HandleCountSpreadChanged(IDiffSpread <int> spread)
        {
            int oldCount = FIOContainers.Count;
            int newCount = Math.Max(spread[0], 0);

            for (int i = oldCount; i < newCount; i++)
            {
                var attribute = CreateAttribute(i + 1);
                attribute.IsPinGroup = false;
                var order = FAttribute.Order + FOffsetCounter * 1000 + 2 * i;
                attribute.Order    = order;
                attribute.BinOrder = order + 1;
                var io = FFactory.CreateIOContainer <TSpread>(attribute, false);
                FIOContainers.Add(io);
            }

            for (int i = oldCount - 1; i >= newCount; i--)
            {
                var io = FIOContainers[i];
                FIOContainers.Remove(io);
                io.Dispose();
            }

            SliceCount = FIOContainers.Count;
            using (var writer = Stream.GetWriter())
            {
                foreach (var io in FIOContainers)
                {
                    writer.Write(io.RawIOObject as TSpread);
                }
            }

            FForceOnNextFlush = true;
        }
Ejemplo n.º 22
0
        void HandleCountSpreadChanged(IDiffSpread <int> spread)
        {
            int oldCount = FIOContainers.Count;
            int newCount = Math.Max(spread[0], 0);

            for (int i = oldCount; i < newCount; i++)
            {
                var attribute = new OutputAttribute(string.Format("{0} {1}", FOutputAttribute.Name, i + 1))
                {
                    IsPinGroup = false,
                    Order      = FOutputAttribute.Order + FOffsetCounter * 1000 + i,
                    BinOrder   = FOutputAttribute.Order + FOffsetCounter * 1000 + i
                };
                var io = FFactory.CreateIOContainer(typeof(IOutStream <T>), attribute, false);
                FIOContainers.Add(io);
            }

            for (int i = oldCount - 1; i >= newCount; i--)
            {
                var io = FIOContainers[i];
                FIOContainers.Remove(io);
                io.Dispose();
            }

            FStreams.Length = FIOContainers.Count;
            using (var writer = FStreams.GetWriter())
            {
                foreach (var io in FIOContainers)
                {
                    writer.Write(io.RawIOObject as IOutStream <T>);
                }
            }
        }
Ejemplo n.º 23
0
        private static IIOContainer CreateConfig(IIOFactory factory, IOBuildContext <ConfigAttribute> context)
        {
            var container  = factory.CreateIOContainer(context.ReplaceIOType(typeof(IEnumConfig)));
            var streamType = typeof(EnumConfigStream <>).MakeGenericType(context.DataType);
            var stream     = Activator.CreateInstance(streamType, container.RawIOObject) as IIOStream;

            return(IOContainer.Create(context, stream, container, null, s => s.Flush(), s => s.Sync()));
        }
 private void HandlePinCountChanged <T>(ISpread <int> countSpread, Spread <IIOContainer <T> > pinSpread, Func <int, IOAttribute> ioAttributeFactory) where T : class
 {
     pinSpread.ResizeAndDispose(countSpread[0], i =>
     {
         var ioAttribute = ioAttributeFactory(i + 1);
         return(FIOFactory.CreateIOContainer <T>(ioAttribute));
     });
 }
Ejemplo n.º 25
0
        public void ChangePins()
        {
            TypesAndFields.Clear();

            string def = "";

            if (FDefinition[0] != null)
            {
                def = FDefinition[0];
            }
            string[] tempfields = def.Trim().Split(',');

            int           order      = 100;
            List <string> fieldnames = new List <string>();

            foreach (string field in tempfields)
            {
                string[] typefieldpair = field.Trim().Split(' ');
                if (typefieldpair.Length == 2)
                {
                    typefieldpair[0] = typefieldpair[0].Trim();
                    typefieldpair[0] = typefieldpair[0].ToLower();
                    typefieldpair[1] = typefieldpair[1].Trim();

                    if (IdentityType.Instance.ContainsKey(typefieldpair[0]) && (!fieldnames.Contains(typefieldpair[1].ToLower())))
                    {
                        fieldnames.Add(typefieldpair[1].ToLower());
                        TypesAndFields.Add(typefieldpair);

                        if (!Spreads.ContainsKey(typefieldpair[1]))
                        {
                            Type         currtype   = IdentityType.Instance[typefieldpair[0]];
                            Type         pinType    = typeof(ISpread <>).MakeGenericType((typeof(ISpread <>)).MakeGenericType(currtype));
                            IIOContainer currpin    = FIOFactory.CreateIOContainer(pinType, PinAttribute(typefieldpair[1], order));
                            NGISpread    currspread = currpin.ToISpread();
                            Spreads.Add(typefieldpair[1], currspread);
                            Pins.Add(typefieldpair[1], currpin);
                        }
                    }
                }
                order++;
            }
            List <string> Removable = new List <string>();

            foreach (string k in Spreads.Keys)
            {
                if (!fieldnames.Contains(k.ToLower()))
                {
                    Removable.Add(k);
                }
            }
            foreach (string k in Removable)
            {
                Spreads.Remove(k);
                Pins[k].Dispose();
                Pins.Remove(k);
            }
        }
Ejemplo n.º 26
0
 public OutputBinSpreadStream(IIOFactory ioFactory, OutputAttribute attribute, Func <IIOContainer, IIOContainer <IOutStream <int> > > binSizeIOContainerFactory)
 {
     if (attribute.IsBinSizeEnabled)
     {
         var container = ioFactory.CreateIOContainer <ISpread <T> >(attribute.DecreaseBinSizeWrapCount(), false); // Ask for a spread, otherwise we lose track of bin size wrapping
         FDataContainer = container;
         FDataStream    = container.IOObject.Stream;
     }
     else
     {
         var container = ioFactory.CreateIOContainer <IOutStream <T> >(attribute, false); // No need for another indirection, access the node output directly
         FDataContainer = container;
         FDataStream    = container.IOObject;
     }
     FBinSizeContainer = binSizeIOContainerFactory(FDataContainer);
     FBinSizeStream    = FBinSizeContainer.IOObject;
     Length            = 1;
 }
Ejemplo n.º 27
0
        public void OnImportsSatisfied()
        {
            FInputContainer = FFactory.CreateIOContainer <IInStream <IInStream <T> > >(
                new InputAttribute("Input")
            {
                IsPinGroup = true
            });

            FOutputContainer = FFactory.CreateIOContainer <IOutStream <T> >(
                new OutputAttribute("Output"));

            FAllowEmptySpreadsConfig = FFactory.CreateDiffSpread <bool>(
                new InputAttribute("Allow Empty Spreads")
            {
                IsSingle = true, Visibility = PinVisibility.OnlyInspector
            });

            FAllowEmptySpreadsConfig.Changed += (s) => FAllowEmptySpreads = s[0];
        }
Ejemplo n.º 28
0
        public void OnImportsSatisfied()
        {
            AutomataUI.Connected    += Input_Connected;
            AutomataUI.Disconnected += Input_Disconnected;

            //new way of enums
            InputAttribute attr = new InputAttribute("State");

            StatesEnum = FIOFactory.CreateIOContainer <IDiffSpread <EnumEntry> >(attr, true);
        }
Ejemplo n.º 29
0
        private void HandleTransitionPins(IDiffSpread <string> sender)
        {
            //FLogger.Log(LogType.Debug, "Update Pins");

            //empty automata tree ? -> create a reset pin
            if (TransitionNames[0] == "")
            {
                TransitionNames[0] = "Init";
            }

            // CREATE INIT
            if (stateList.Count == 0)
            {
                stateList.Add(new State()
                {
                    ID     = "Init",
                    Name   = "Init",
                    Bounds = new Rectangle(new Point(0, 0), new Size(p.StateSize, p.StateSize))
                });
            }

            //delete pins which are not in the new list
            foreach (var name in FPins.Keys)
            {
                if (TransitionNames.IndexOf(name) == -1)
                {
                    FPins[name].Dispose();
                }
            }

            Dictionary <string, IIOContainer> newPins = new Dictionary <string, IIOContainer>();

            foreach (var name in TransitionNames)
            {
                if (!string.IsNullOrEmpty(name)) //ignore empty slices
                {
                    if (FPins.ContainsKey(name)) //pin already exists, copy to new dict
                    {
                        newPins.Add(name, FPins[name]);
                        FPins.Remove(name);
                    }
                    else if (!newPins.ContainsKey(name)) //just checking in case of duplicate names
                    {
                        var attr = new InputAttribute(name);
                        attr.IsBang = true;
                        var type      = typeof(IDiffSpread <bool>);
                        var container = FIOFactory.CreateIOContainer(type, attr);
                        newPins.Add(name, container);
                    }
                }
            }

            //FPins now only holds disposed IIOContainers, since we copied the reusable ones to newPins
            FPins = newPins;
        }
Ejemplo n.º 30
0
        void AttributeNamesPin_Changed(IDiffSpread <string> spread)
        {
            if (spread.SliceCount == 0)
            {
                return;
            }

            AttributeNames = AttributeNamesPin[0].Split(',').ToList().Select(s => s.Trim()).Where(s => s.Length > 0).ToArray();

            //add new pins
            foreach (var attributeName in AttributeNames)
            {
                if (!AttributeInfos.Any(info => info.AttributeName == attributeName))
                {
                    var outputInfo = new AttributeInfo()
                    {
                        AttributeName            = attributeName,
                        AttributeContainer       = IOFactory.CreateIOContainer <ISpread <string> >(new OutputAttribute(attributeName + " Value")),
                        AttributeExistsContainer = IOFactory.CreateIOContainer <ISpread <bool> >(
                            new OutputAttribute(attributeName + " Available")
                        {
                            Visibility = PinVisibility.Hidden
                        }
                            ),
                    };
                    AttributeInfos.Add(outputInfo);
                }
            }

            //remove obsolete pins
            foreach (var outputInfo in AttributeInfos.ToArray())
            {
                if (!AttributeNames.Contains(outputInfo.AttributeName))
                {
                    AttributeInfos.Remove(outputInfo);
                    outputInfo.AttributeContainer.Dispose();
                    outputInfo.AttributeExistsContainer.Dispose();
                }
            }

            ConfigChanged = true;
        }