Esempio n. 1
0
        private bool IsEqualTo(AssociationClaim other)
        {
            if (other != null)
            {
                var otherInputFields = other.Inputs.Keys;

                if (other.Output.Key == Output.Key)
                {
                    if (other.Output.Value == Output.Value)
                    {
                        if (other.Inputs.Count == Inputs.Count)
                        {
                            if (otherInputFields.All(f => Inputs.ContainsKey(f)))
                            {
                                if (otherInputFields.All(f => other.Inputs[f] == Inputs[f]))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }
        private void ConnectInputs()
        {
            var inputFactory = ActionsGraph.InputContainer;

            foreach (var dependencyName in _dependencies.Keys)
            {
                ActionsGraph[dependencyName].Disconnect();
            }

            //Ensure.AreEqual(Inputs.Count, 0);
            if (Inputs.Count > 0)
            {
                DisconnectInputs();
            }
            foreach (var dependencyName in _dependencies.Keys)
            {
                Ensure.IsTrue(!Inputs.ContainsKey(dependencyName),
                              "Inputs should be cleared before repopulating");
                var input = ActionsGraph[dependencyName];
                input.HasDataNotify   += OnReceiveInputData;
                Inputs[dependencyName] = input;
                if (input is PipeBase)
                {
                    inputFactory.ConnectPipe(input.Name);
                }
            }
            Ensure.AreEqual(Inputs.Count, _dependencies.Count);
            foreach (var dependencyName in _dependencies.Keys)
            {
                ActionsGraph[dependencyName].OnConnect();
            }
        }
Esempio n. 3
0
        private void SetEditor(DataPackage dataPackage)
        {
            if (Inputs.ContainsKey(InputNames.CommandLinePrePusher))
            {
                var pusherInput = Inputs[InputNames.CommandLinePrePusher];
                var pusherData  = (List <object>)pusherInput.GetData(NotificationNames.GetValue).Data;
                if (pusherData.Count > 0)
                {
                    return;
                }
            }

            if (_gizmoContainer != null)
            {
                _gizmoContainer.CurrentGizmoType = _currentGizmoType;
            }

            if (Inputs.ContainsKey(InputNames.SelectionContainerPipe))
            {
                var selectionContainer =
                    Inputs[InputNames.SelectionContainerPipe].GetData(NotificationNames.GetContainer).Get
                    <SelectionContainer>();

                foreach (var editingTool in _editingTools)
                {
                    editingTool.SetViewInfo(_viewInfo, ActionsGraph);
                    editingTool.SetEditor(selectionContainer, ActionsGraph);
                    if (selectionContainer.CurrentSelectionMode == TopAbsShapeEnum.TopAbs_FACE)
                    {
                        break;
                    }
                }
            }
        }
        protected void Send(string inputName, string name)
        {
            Ensure.IsTrue(Inputs.ContainsKey(inputName), "Input Should Exist");
            var input = Inputs[inputName];

            input.Send(name);
        }
        protected T GetData <T>(string inputName, string objectName)
        {
            Ensure.IsTrue(Inputs.ContainsKey(inputName), "Input Should Exist");
            var input = Inputs[inputName];

            return(input.GetData(objectName).Get <T>());
        }
Esempio n. 6
0
        public void SetValue(string property, float value)
        {
            if (!Inputs.ContainsKey(property))
            {
                return;
            }
            var input = Inputs[property];

            Voltages[input] = Voltages[input].Replace(1, value);
        }
Esempio n. 7
0
 public void ConnectTo(InputBase input)
 {
     if (Inputs.ContainsKey(input.Name))
     {
         return;
     }
     Inputs[input.Name]   = input;
     input.HasDataNotify += OnData;
     input.OnConnect();
 }
        private static string GetValue(Inputs input, string argumentName, string fieldTypeName)
        {
            if (input.ContainsKey(argumentName))
            {
                var model = (Dictionary <string, object>)input[argumentName];
                if (model != null && model.ContainsKey(fieldTypeName))
                {
                    return(model[fieldTypeName]?.ToString());
                }
            }

            return(null);
        }
Esempio n. 9
0
        public void AddInput(LayerConstruct input, string alias = "default")
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (Inputs.ContainsKey(alias))
            {
                throw new ArgumentException($"Attempted to add duplicate output to construct {Name} with alias {alias}.");
            }

            Inputs.Add(alias, input);
        }
Esempio n. 10
0
 /// <summary>
 /// Gets the mapper with the given deviceID. If the mapper is not saved in this settings, a new mapper will be returned.
 /// </summary>
 /// <param name="id">DeviceID</param>
 /// <returns></returns>
 public InputMapper GetMapper(string id)
 {
     if (!Inputs.ContainsKey(id))
     {
         if (id == KeyboardKey)
         {
             Inputs[id] = new InputMapper();
         }
         else
         {
             Inputs[id] = new InputMapper();
         }
     }
     return(Inputs[id]);
 }
Esempio n. 11
0
        public override object ReadInputSignal(string signalName)
        {
            if (Inputs.ContainsKey(signalName))
            {
                AdressValueInfo value = (AdressValueInfo)Inputs[signalName];
                value.deviceValue = new ModbusValue();
                switch (value.valueType.Name)
                {
                case "System.UInt16":
                    return(ReadUInt16(value.adress));

                case "System.UInt32":
                    return(ReadUInt32(value.adress));

                case "System.UInt64":
                    return(ReadUInt64(value.adress));

                case "System.Int16":
                    return(ReadInt16(value.adress));

                case "System.Int32":
                    return(ReadInt32(value.adress));

                case "System.Int64":
                    return(ReadInt64(value.adress));

                case "System.Boolean":
                    return(ReadBoolean(value.adress));

                case "System.Byte":
                    return(ReadByte(value.adress));

                case "System.SByte":
                    return(ReadSbyte(value.adress));

                case "System.Double":
                    return(ReadDouble(value.adress));

                case "System.Single":
                    return(ReadSingle(value.adress));

                case "System.String":
                    return(ReadString(value.adress, value.length));
                }
            }
            return(null);
        }
Esempio n. 12
0
        public FluTeCoreInstance BindInput(string name, object value)
        {
            var key = new InputKey(name, InputType.Instance);

            if (!Inputs.ContainsKey(key))
            {
                throw new KeyNotFoundException("Tried to bind an input name that does not exist.");
            }
            var input = Inputs[key];

            if (input is IBoundInput)
            {
                throw new InvalidOperationException("Cannot bind a value to an input that has already been bound.");
            }
            var inputAs = input as IUnboundInput;

            return(new FluTeCoreInstance(Tokens, TokenSequence, Inputs.Set(key, inputAs.Bind(value)), PostProcessingQueue));
        }
Esempio n. 13
0
        public void Draw(Graphics g, SwitchBase sw, DrawableBase parent, RenderingEngine e)
        {
            MainEntry.Draw(g, sw, parent, e);
            for (int i = 0; i < sw.InputsSet.Count; i++)
            {
                if (Inputs.ContainsKey(i))
                {
                    Inputs[i].DrawInput(g, sw, i, e);
                }
            }

            for (int i = 0; i < sw.OutputsSet.Count; i++)
            {
                if (Outputs.ContainsKey(i))
                {
                    Outputs[i].DrawOutput(g, sw, i, e);
                }
            }
        }
        public FluTeCorePrototype DefineStaticInput(string name, Func <object> binding)
        {
            var key = new InputKey(name, InputType.Static);

            if (!Inputs.ContainsKey(key))
            {
                throw new KeyNotFoundException("A static input with the specified name could not be found.");
            }

            var input = Inputs[key];

            if (input is IBoundInput)
            {
                throw new InvalidOperationException("The specified static input is already bound.");
            }
            var unboundInput = (IUnboundStaticInput)input;
            var boundInput   = unboundInput.Define(binding);

            return(new FluTeCorePrototype(Tokens, TokenSequence, Inputs.Set(boundInput.Key, boundInput), PostProcessingQueue));
        }
Esempio n. 15
0
        //Запись результатов компиляции
        public void SaveCompileResults(IRecordAdd rec)
        {
            rec.Put("ErrMess", _errMess);
            rec.Put("ResiltType", Type.ToResString());

            var sb = new StringBuilder("Inputs: ");

            foreach (var v in InputsList)
            {
                sb.Append(v.Code).Append("; ");
            }
            sb.Append("Vars: ");
            foreach (var v in Vars.Values)
            {
                if (!Inputs.ContainsKey(v.Code))
                {
                    sb.Append(v.Code).Append("; ");
                }
            }

            sb.Append("Expr: ");
            foreach (var node in Expr1.Nodes)
            {
                node.SaveCompiled(sb);
            }
            if (Vars["calc"].Type.DataType != DataType.Void)
            {
                sb.Append("Assign!Calc!1; ");
            }
            foreach (var node in Expr2.Nodes)
            {
                node.SaveCompiled(sb);
            }
            rec.Put("CompiledExpr", sb.ToString());
            rec.Update();
        }
 internal bool HasDotNetType(string typeName)
 {
     return(typeMappings.ContainsKey(typeName) || Types.ContainsKey(typeName) || Inputs.ContainsKey(typeName) || Enums.ContainsKey(typeName));
 }
Esempio n. 17
0
        public Variables GetVariableValues(Schema schema, Variables variables, Inputs inputs)
        {
            variables.Apply(v =>
            {
                var input = inputs != null && inputs.ContainsKey(v.Name) ? inputs[v.Name] : null;
                v.Value = GetVariableValue(schema, v, input);
            });

            return variables;
        }
Esempio n. 18
0
        //Семантический разбор поля Inputs
        private void ParseInputs()
        {
            Inputs.Clear();
            InputsList.Clear();
            Vars.Clear();
            var       inputs = (ListNode <InputNode>) new InputsParsing(Keeper, InputsStr).ResultTree;
            TablikVar v      = null;

            foreach (var node in inputs.Nodes)
            {
                var varCode = node.Token.Text;
                if (Inputs.ContainsKey(varCode))
                {
                    Keeper.AddError("Два входа с одинаковыми именами", node);
                }
                else if (varCode.ToLower() == "расчет" || varCode.ToLower() == "calc")
                {
                    Keeper.AddError("Недопустимое имя входа", node);
                }
                switch (node.InputType)
                {
                case InputType.Simple:
                    var dt  = node.TypeNode == null ? DataType.Real : node.TypeNode.Text.ToDataType();
                    var at  = node.SubTypeNode == null ? ArrayType.Single : node.SubTypeNode.Token.Text.ToArrayType();
                    var val = node.ValueNode == null ? null : node.ValueNode.Mean;
                    v = new TablikVar(varCode, new SimpleType(dt, at), val);
                    break;

                case InputType.Param:
                    if (!Module.Params.ContainsKey(node.TypeNode.Text))
                    {
                        Keeper.AddError("Не найден расчетный параметр", node.TypeNode);
                    }
                    else
                    {
                        var par = Module.Params[node.TypeNode.Text];
                        if (node.SubTypeNode == null)
                        {
                            if (!par.IsFun)
                            {
                                Keeper.AddError("Параметр без входов не может быть типом данных входа", node.TypeNode);
                            }
                            else
                            {
                                v = new TablikVar(varCode, par);
                            }
                        }
                        else if (!par.Params.ContainsKey(node.SubTypeNode.Text))
                        {
                            Keeper.AddError("Не найден расчетный подпараметр", node.SubTypeNode);
                        }
                        else
                        {
                            var spar = par.Params[node.SubTypeNode.Text];
                            if (!spar.IsFun)
                            {
                                Keeper.AddError("Подпараметр без входов не может быть типом данных входа", node.SubTypeNode);
                            }
                            else
                            {
                                v = new TablikVar(varCode, spar);
                            }
                        }
                    }
                    break;

                case InputType.Signal:
                    string         scode = node.TypeNode.Text.Substring(1, node.TypeNode.Text.Length - 2);
                    ObjectTypeBase t     = null;
                    foreach (var con in Module.LinkedSources)
                    {
                        if (con.ObjectsTypes.ContainsKey(scode))
                        {
                            if (t == null)
                            {
                                t = con.ObjectsTypes[scode];
                            }
                            else
                            {
                                Keeper.AddError("Одинаковый код типа объекта в двух разных источниках", node);
                            }
                        }
                        else if (con.BaseObjectsTypes.ContainsKey(scode))
                        {
                            if (t == null)
                            {
                                t = con.BaseObjectsTypes[scode];
                            }
                            else
                            {
                                Keeper.AddError("Одинаковый код типа объекта в двух разных источниках", node);
                            }
                        }
                    }
                    if (t != null)
                    {
                        v = new TablikVar(varCode, t)
                        {
                            MetSignals = new SetS(), MetProps = new SetS()
                        }
                    }
                    ;
                    else
                    {
                        Keeper.AddError("Не найден тип объекта или сигнала", node);
                    }
                    break;
                }
                if (v != null)
                {
                    if (Inputs.ContainsKey(v.Code))
                    {
                        Keeper.AddError("Два входа с одинаковыми именами", node);
                    }
                    else
                    {
                        if (v.DefaultValue == null && InputsList.Count > 0 && InputsList[InputsList.Count - 1].DefaultValue != null)
                        {
                            Keeper.AddError("Входы со значениямия по умолчанию должны располагаться в конце списка входов", node);
                        }
                        InputsList.Add(Vars.Add(v.Code, Inputs.Add(v.Code, v)));
                    }
                }
            }
        }