/// <summary>
        /// Retrieves the IO spec from component and updates local IOSpec.
        /// </summary>
        /// <param name="currentNode">The current node.</param>
        private void RetrieveIOSpecFromComponent(IConfigurableAndIOSpecifiable metadata)
        {
            CollectIO(metadata, metadata.IOSpec.Input, InputSettings);
            CollectIO(metadata, metadata.IOSpec.Output, OutputSettings);

            MatchOutputsAndInputsPairs();
        }
Пример #2
0
 /// <summary>
 /// Overrides the config values of the given metadata with values from the this CompositeComponent config values.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="metadata">The metadata.</param>
 private void OverrideConfigValues(String id, IConfigurableAndIOSpecifiable metadata)
 {
     foreach (string configParameter in metadata.ConfigWrapper.ConfigValues.Keys)
     {
         string extendedParameterName = String.Format("{0}:{1}", id, configParameter);
         ConfigPropertyObject overridePropertyObject = m_compositeComponentMetadata.ConfigWrapper.ConfigValues[extendedParameterName];
         metadata.ConfigWrapper.ConfigValues[configParameter] = overridePropertyObject;
     }
 }
 private void RetrieveIOSpecAndConfig(ExperimentNode node)
 {
     if (node != null)
     {
         IConfigurableAndIOSpecifiable metadata = node.Data.Metadata as IConfigurableAndIOSpecifiable;
         if (metadata != null)
         {
             RetrieveIOSpecFromComponent(metadata);
             RetrieveConfigValuesFromComponent(node.ID, metadata);
         }
     }
 }
 private void CollectIO(IConfigurableAndIOSpecifiable metadata, IDictionary <string, IOItem> ioDictionary, SortedDictionary <string, ItemSetting> compositeComponentSettings)
 {
     foreach (IOItem item in ioDictionary.Values)
     {
         var correspondingNodes = CollectCorrespondingNodesForMapping(item.MappedTo, metadata);
         if (compositeComponentSettings.ContainsKey(item.MappedTo) == false)
         {
             var itemSetting = new ItemSetting(item.MappedTo, item.IOItemDefinition.Type, item.IOItemDefinition.Description);
             //set the reference to the list of corresponding nodes that either input or output the same mapping name
             itemSetting.CorrespondingNodes = correspondingNodes;
             compositeComponentSettings.Add(item.MappedTo, itemSetting);
         }
     }
 }
Пример #5
0
        /// <summary>
        /// Validates if the list of outputs from incoming vertices satisfies all the inputs for the current node
        /// </summary>
        /// <param name="node">Node to be validated</param>
        /// <param name="incomingOutputs">List of incoming outputs from the previous nodes</param>
        /// <param name="noErrors">assigns false if error has been detected, otherwise keep it as it was</param>
        private static bool ValidateInputMapping(ExperimentNode node, Dictionary <string, string> incomingOutputs)
        {
            bool noErrors = true;
            IConfigurableAndIOSpecifiable ioSpecMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable;

            if (ioSpecMetadata != null)
            {
                //check if the list of outputs from incoming vertices satisfies all the inputs for the current node
                foreach (IOItem inputItem in ioSpecMetadata.IOSpec.Input.Values)
                {
                    if (incomingOutputs.ContainsKey(inputItem.MappedTo) == false)
                    {
                        noErrors = false;
                        GraphValidator.SetErrorOnNode(node, String.Format(CultureInfo.CurrentCulture, "The component attempts to load '{0}' from the Workspace. However, none of the previous components outputs '{1}' to the Workspace.", inputItem.MappedTo, inputItem.MappedTo));
                    }
                }
            }
            return(noErrors);
        }
        /// <summary>
        /// Retrieves the config values from component's config wrapper.
        /// </summary>
        /// <param name="currentNode">The current node.</param>
        private void RetrieveConfigValuesFromComponent(string nodeIdentifier, IConfigurableAndIOSpecifiable metadata)
        {
            foreach (ConfigPropertyObject configParameter in metadata.ConfigWrapper.ConfigValues.Values)
            {
                string displayParameterName  = String.Format("{0} {1}", metadata.Label, configParameter.DisplayName);
                string extendedParameterName = String.Format("{0}:{1}", nodeIdentifier, configParameter.Name);

                //create property object based on the component's property object
                ConfigPropertyObject propertyObject = new ConfigPropertyObject(configParameter);

                //but change the name - it will be resolved in Nodes factory based on extended parameter name which retNode config parameter is supposed to be overridden
                propertyObject.DisplayName = displayParameterName;
                propertyObject.Name        = extendedParameterName;

                //add it to the compound configWrapperDefinition
                displayParameterName = GetUniqueDisplayName(displayParameterName);
                ConfigSettings.Add(displayParameterName, new ConfigItemSetting(displayParameterName, configParameter.Type, propertyObject));
            }
        }
Пример #7
0
 private void GetPublishableExperimentResults()
 {
     m_publishableExperimentResults = new List <string>();
     foreach (ExperimentNode node in m_baseExperiment.Vertices)
     {
         IConfigurableAndIOSpecifiable metadata = node.Data.Metadata as IConfigurableAndIOSpecifiable;
         if (metadata != null)
         {
             foreach (IOItem outputItem in metadata.IOSpec.Output.Values)
             {
                 //if output item type is an ExperimentResult it can be published
                 if (outputItem.IOItemDefinition.Type.Equals(typeof(TraceLabSDK.Types.Contests.TLExperimentResults).FullName))
                 {
                     //add it to the list of potential publishable results
                     m_publishableExperimentResults.Add(outputItem.MappedTo);
                 }
             }
         }
     }
 }
Пример #8
0
        private void IncludeMappingsFromExperiment(IExperiment experiment)
        {
            List <ExperimentNode> allNodes = new List <ExperimentNode>();

            CollectNodesInExperiment(experiment, ref allNodes);

            foreach (ExperimentNode currentNode in allNodes)
            {
                IConfigurableAndIOSpecifiable ioSpecMetadata = currentNode.Data.Metadata as IConfigurableAndIOSpecifiable;
                if (ioSpecMetadata != null)
                {
                    foreach (ExperimentNode otherNode in allNodes)
                    {
                        if (otherNode != currentNode)
                        {
                            foreach (IOItem outputItem in ioSpecMetadata.IOSpec.Output.Values)
                            {
                                AddMapping(otherNode, outputItem.MappedTo, outputItem.IOItemDefinition.Type);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Retrieves the config values from component's config wrapper.
        /// </summary>
        /// <param name="currentNode">The current node.</param>
        private void RetrieveConfigValuesFromComponent(string nodeIdentifier, IConfigurableAndIOSpecifiable metadata)
        {
            foreach (ConfigPropertyObject configParameter in metadata.ConfigWrapper.ConfigValues.Values)
            {
                string displayParameterName = String.Format("{0} {1}", metadata.Label, configParameter.DisplayName);
                string extendedParameterName = String.Format("{0}:{1}", nodeIdentifier, configParameter.Name);

                //create property object based on the component's property object
                ConfigPropertyObject propertyObject = new ConfigPropertyObject(configParameter);

                //but change the name - it will be resolved in Nodes factory based on extended parameter name which retNode config parameter is supposed to be overridden
                propertyObject.DisplayName = displayParameterName;
                propertyObject.Name = extendedParameterName;
                
                //add it to the compound configWrapperDefinition
                displayParameterName = GetUniqueDisplayName(displayParameterName);
                ConfigSettings.Add(displayParameterName, new ConfigItemSetting(displayParameterName, configParameter.Type, propertyObject));
            }   
        }
 private void CollectIO(IConfigurableAndIOSpecifiable metadata, IDictionary<string, IOItem> ioDictionary, SortedDictionary<string, ItemSetting> compositeComponentSettings)
 {
     foreach (IOItem item in ioDictionary.Values)
     {
         var correspondingNodes = CollectCorrespondingNodesForMapping(item.MappedTo, metadata);
         if (compositeComponentSettings.ContainsKey(item.MappedTo) == false)
         {
             var itemSetting = new ItemSetting(item.MappedTo, item.IOItemDefinition.Type, item.IOItemDefinition.Description);
             //set the reference to the list of corresponding nodes that either input or output the same mapping name
             itemSetting.CorrespondingNodes = correspondingNodes;
             compositeComponentSettings.Add(item.MappedTo, itemSetting);
         }
     }
 }
        /// <summary>
        /// Retrieves the IO spec from component and updates local IOSpec.
        /// </summary>
        /// <param name="currentNode">The current node.</param>
        private void RetrieveIOSpecFromComponent(IConfigurableAndIOSpecifiable metadata)
        {
            CollectIO(metadata, metadata.IOSpec.Input, InputSettings);
            CollectIO(metadata, metadata.IOSpec.Output, OutputSettings);

            MatchOutputsAndInputsPairs();
        }
        /// <summary>
        /// Collects corresponding nodes for given mapping name.
        /// </summary>
        /// <param name="mappingName">Name of the mapping.</param>
        /// <param name="metadata">The metadata.</param>
        /// <returns>list of nodes metadata for the mapping name.</returns>
        internal List<IConfigurableAndIOSpecifiable> CollectCorrespondingNodesForMapping(string mappingName, IConfigurableAndIOSpecifiable metadata)
        {
            List<IConfigurableAndIOSpecifiable> correspondingNodes;
            if (m_corespondingNodesForEachMapping.TryGetValue(mappingName, out correspondingNodes) == false)
            {
                correspondingNodes = new List<IConfigurableAndIOSpecifiable>();
                m_corespondingNodesForEachMapping.Add(mappingName, correspondingNodes);
            }

            if (correspondingNodes.Contains(metadata) == false)
            {
                correspondingNodes.Add(metadata);
            }

            return correspondingNodes;
        }
        /// <summary>
        /// Collects corresponding nodes for given mapping name.
        /// </summary>
        /// <param name="mappingName">Name of the mapping.</param>
        /// <param name="metadata">The metadata.</param>
        /// <returns>list of nodes metadata for the mapping name.</returns>
        internal List <IConfigurableAndIOSpecifiable> CollectCorrespondingNodesForMapping(string mappingName, IConfigurableAndIOSpecifiable metadata)
        {
            List <IConfigurableAndIOSpecifiable> correspondingNodes;

            if (m_corespondingNodesForEachMapping.TryGetValue(mappingName, out correspondingNodes) == false)
            {
                correspondingNodes = new List <IConfigurableAndIOSpecifiable>();
                m_corespondingNodesForEachMapping.Add(mappingName, correspondingNodes);
            }

            if (correspondingNodes.Contains(metadata) == false)
            {
                correspondingNodes.Add(metadata);
            }

            return(correspondingNodes);
        }
 /// <summary>
 /// Overrides the config values of the given metadata with values from the this CompositeComponent config values.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="metadata">The metadata.</param>
 private void OverrideConfigValues(String id, IConfigurableAndIOSpecifiable metadata)
 {
     foreach (string configParameter in metadata.ConfigWrapper.ConfigValues.Keys)
     {
         string extendedParameterName = String.Format("{0}:{1}", id, configParameter);
         ConfigPropertyObject overridePropertyObject = m_compositeComponentMetadata.ConfigWrapper.ConfigValues[extendedParameterName];
         metadata.ConfigWrapper.ConfigValues[configParameter] = overridePropertyObject;
     }
 }