Example #1
0
        private int GetMaxValueLength(ValueSpecification spec)
        {
            var specLength = 0;

            var hasMeta = spec.MetaName.Length > 0;

            var metaLength = 0;

            if (spec.MetaValue.Length > 0)
            {
                metaLength = spec.MetaValue.Length + 1;
            }

            if (hasMeta)
            {
                specLength += spec.MetaName.Length + spec.Index.ToStringInvariant().Length + 8; //METANAME (pos. N)
            }
            else
            {
                specLength += spec.Index.ToStringInvariant().Length + 11; // "value pos. N"
            }
            specLength += metaLength;

            return(specLength);
        }
Example #2
0
 private string AddValueName(int maxLength, ValueSpecification specification)
 {
     return(new StringBuilder(maxLength)
            .BimapIf(
                specification.MetaName.Length > 0,
                it => it.AppendFormat("{0} (pos. {1})", specification.MetaName, specification.Index),
                it => it.AppendFormat("value pos. {0}", specification.Index))
            .AppendFormatWhen(
                specification.MetaValue.Length > 0, " {0}", specification.MetaValue)
            .ToString());
 }
        public IDependencyGraph GetSubgraphProducing(ValueSpecification output)
        {
            string encodedValueSpec = _resolve.EncodeBean(output);
            var subGraphTarget = _resolve.Resolve("subgraphProducing", Tuple.Create("msg", encodedValueSpec));

            var dependencyGraph = subGraphTarget.Get<IDependencyGraph>();
            if (dependencyGraph == null)
            {
                throw new IllegalStateException("Null graph returned, perhaps the cycle dissapeared");
            }
            return dependencyGraph;
        }
Example #4
0
        public IDependencyGraph GetSubgraphProducing(ValueSpecification output)
        {
            string encodedValueSpec = _resolve.EncodeBean(output);
            var    subGraphTarget   = _resolve.Resolve("subgraphProducing", Tuple.Create("msg", encodedValueSpec));

            var dependencyGraph = subGraphTarget.Get <IDependencyGraph>();

            if (dependencyGraph == null)
            {
                throw new IllegalStateException("Null graph returned, perhaps the cycle dissapeared");
            }
            return(dependencyGraph);
        }
Example #5
0
        ComparableOption ToComparableOption(Specification spec, int index)
        {
            OptionSpecification option = spec as OptionSpecification;
            ValueSpecification  value  = spec as ValueSpecification;
            bool required = option?.Required ?? false;

            return(new ComparableOption()
            {
                Required = required,
                IsOption = option != null,
                IsValue = value != null,
                LongName = option?.LongName ?? value?.MetaName,
                ShortName = option?.ShortName,
                Index = index
            });
        }
Example #6
0
 public bool IsSatisfiedBy(ValueSpecification valueSpecification)
 {
     if (ValueName != valueSpecification.ValueName) {
       return false;
     }
     if (! TargetSpecification.Equals(valueSpecification.TargetSpecification)) {
       return false;
     }
     if (!Constraints.IsSatisfiedBy(valueSpecification.Properties)) {
       return false;
     }
     return true;
 }
        public static object GetValue(IFudgeDeserializer deserializer, IFudgeField valueField, ValueSpecification valueSpecification)
        {
            if (valueSpecification.ValueName == "YieldCurveJacobian")
            {
                var fudgeFieldContainer = (IFudgeFieldContainer)valueField.Value;
                //TODO I hope this gets a better type one day?
                return(fudgeFieldContainer.Where(f => !f.Ordinal.HasValue).Select(f => (double[])f.Value).ToList());
            }

            return(Pair.FromField(deserializer, valueField));
        }
Example #8
0
 public ComputedValue(ValueSpecification specification, object value)
 {
     _specification = specification;
     _value = value;
 }
Example #9
0
    // Use this for initialization
    void Start()
    {
        VRApplication mascaret = VRApplication.Instance;

        Dictionary <string, List <Class> > classesList = mascaret.Model.AllClasses;

        PrintSingleton.Instance.log("==== Printing Class List in Model ========");
        foreach (KeyValuePair <string, List <Class> > cl in classesList)
        {
            PrintSingleton.Instance.log(" ============================================= ");
            Class c = cl.Value[0];
            PrintSingleton.Instance.log(c.getFullName());
            Dictionary <string, Property> props = c.Attributes;
            foreach (KeyValuePair <string, Property> p in props)
            {
                Property property = p.Value;
                PrintSingleton.Instance.log("    -> " + property.name + " : " + property.Type.name);
            }

            Dictionary <string, Behavior> behaviors = c.OwnedBehavior;
            PrintSingleton.Instance.log("   ----- Behaviors : ");
            foreach (KeyValuePair <string, Behavior> bhs in behaviors)
            {
                PrintSingleton.Instance.log(bhs.Value.getFullName());
                StateMachine  stm           = (StateMachine)bhs.Value;
                List <Region> regions       = stm.Region;
                Region        initialRegion = regions[0];
                List <Vertex> vertices      = initialRegion.Vertices;
                foreach (Vertex vertex in vertices)
                {
                    PrintSingleton.Instance.log("    * " + vertex.name);
                    List <Transition> outgoing = vertex.Outgoing;
                    foreach (Transition t in outgoing)
                    {
                        PrintSingleton.Instance.log("       --> " + t.Target.name);
                    }
                    List <Transition> incoming = vertex.Incoming;
                    foreach (Transition t in incoming)
                    {
                        PrintSingleton.Instance.log("       <-- " + t.Source.name);
                    }
                    if (vertex.GetType().ToString() == "Mascaret.State")
                    {
                        State     state       = (State)vertex;
                        Operation doOperation = state.DoBehavior;
                        if (doOperation != null)
                        {
                            PrintSingleton.Instance.log("        Do : " + doOperation.getFullName());
                        }
                    }
                }
            }

/*
 *                      Dictionary<string,InstanceSpecification> entities = c.Instances;
 *                      PrintSingleton.Instance.log("   ----- instances : " );
 *                      foreach (KeyValuePair<string, InstanceSpecification> instanceKV in entities)
 *                      {
 *                              PrintSingleton.Instance.log(instanceKV.Value.getFullName());
 *                      }
 */
        }

        Dictionary <string, InstanceSpecification> instances = mascaret.getEnvironment().InstanceSpecifications;

        PrintSingleton.Instance.log("Nb Instances : " + instances.Count);

        PrintSingleton.Instance.log("==== Printing Entity List in Model ========");
        foreach (KeyValuePair <string, InstanceSpecification> instanceKV in instances)
        {
            PrintSingleton.Instance.log(" ============================================= ");
            InstanceSpecification instance = instanceKV.Value;
            PrintSingleton.Instance.log(instance.getFullName() + " : " + instance.Classifier.getFullName());
            Dictionary <string, Slot> slots = instance.Slots;
            foreach (KeyValuePair <string, Slot> propertyValues in slots)
            {
                Slot               propertyValue = propertyValues.Value;
                string             propertyName  = propertyValue.DefiningProperty.name;
                ValueSpecification valueSpecif   = propertyValue.getValue();
                if (valueSpecif != null)
                {
                    string value = "";

                    if (valueSpecif.GetType().ToString() == "Mascaret.LiteralInteger")
                    {
                        LiteralInteger integer  = valueSpecif as LiteralInteger;
                        int            intValue = integer.IValue;
                        value += intValue;
                    }
                    else if (valueSpecif.GetType().ToString() == "Mascaret.InstanceValue")
                    {
                        InstanceValue         instanceValue  = valueSpecif as InstanceValue;
                        InstanceSpecification instanceSpecif = instanceValue.SpecValue;
                        value = instanceSpecif.getFullName();
                    }

                    PrintSingleton.Instance.log(" ----> " + propertyName + " = " + value);
                }
                else
                {
                    PrintSingleton.Instance.log(" ----> " + propertyName + " not set");
                }
            }
            List <StateMachineBehaviorExecution> stmBEs = instance.SmBehaviorExecutions;
            foreach (StateMachineBehaviorExecution stmBE in stmBEs)
            {
                PrintSingleton.Instance.log("    - Execute : " + stmBE.getStateMachine().getFullName());
                //PrintSingleton.Instance.log("        * CurrentState : " + stmBE.CurrentState.name);
            }
        }
    }
Example #10
0
 public static void AssertSensibleValue(ValueSpecification spec)
 {
     Assert.NotNull(spec);
     Assert.NotEmpty(spec.ValueName);
 }
 private static bool Produces(DependencyNode n, ValueSpecification specToTest)
 {
     var targetMatches = n.Target.UniqueId == specToTest.TargetSpecification.Uid && n.Target.Type == specToTest.TargetSpecification.Type;
     return targetMatches && n.OutputValues.Any(s => s.Equals(specToTest));
 }
Example #12
0
        private static bool Produces(DependencyNode n, ValueSpecification specToTest)
        {
            var targetMatches = n.Target.UniqueId == specToTest.TargetSpecification.Uid && n.Target.Type == specToTest.TargetSpecification.Type;

            return(targetMatches && n.OutputValues.Any(s => s.Equals(specToTest)));
        }