コード例 #1
0
        /// <summary>
        /// Creates a copy of the current instance.
        /// </summary>
        /// <returns>Copy of the instance</returns>
        public object Clone()
        {
            LinearConversionDataOperation clone = new LinearConversionDataOperation();

            clone._a           = _a;
            clone._b           = _b;
            clone._isActivated = _isActivated;
            clone._arguments   = new Argument[ArgumentCount];
            for (int i = 0; i < ArgumentCount; i++)
            {
                clone._arguments[i]             = new HydroNumerics.OpenMI.Sdk.Backbone.Argument();
                clone._arguments[i].Description = _arguments[i].Description;
                clone._arguments[i].Key         = _arguments[i].Key;
                clone._arguments[i].ReadOnly    = _arguments[i].ReadOnly;
                clone._arguments[i].Value       = _arguments[i].Value;
            }
            return(clone);
        }
コード例 #2
0
        /// <summary>
        /// Initialize will create buffers, prepare data operations and create the mapping matrice when georeferenced links are used.
        /// The initialize method should be invoked in the ILinkableComponent prepare method (is done from the LinkableRunEngine).
        /// </summary>
        public void Initialize()
        {
            _bufferStates = new Hashtable();

            smartBuffer          = new SmartBuffer();
            _useSpatialMapping   = false;
            _linearDataOperation = null;



            //Setup Spatial mapper - mapping method is set to default for now!
            int    index       = -1;
            string description = " ";

            for (int i = 0; i < link.DataOperationsCount; i++)
            {
                for (int n = 0; n < link.GetDataOperation(i).ArgumentCount; n++)
                {
                    if (link.GetDataOperation(i).GetArgument(n).Key == "Type" && link.GetDataOperation(i).GetArgument(n).Value == "SpatialMapping")
                    {
                        for (int m = 0; m < link.GetDataOperation(i).ArgumentCount; m++)
                        {
                            if (link.GetDataOperation(i).GetArgument(m).Key == "Description")
                            {
                                description = link.GetDataOperation(i).GetArgument(m).Value;
                                break;
                            }
                        }
                        index = i;
                        break;
                    }
                }
                if (index == i)
                {
                    break;
                }
            }

            if (index >= 0)
            {
                if (description == " ")
                {
                    throw new Exception("Missing key: \"Description\" in spatial dataoperation arguments");
                }
                _useSpatialMapping = true;
                elementMapper      = new ElementMapper();
                elementMapper.Initialise(description, link.SourceElementSet, link.TargetElementSet);
            }

            //Prepare linear data operation
            for (int i = 0; i < link.DataOperationsCount; i++)
            {
                if (link.GetDataOperation(i).ID == (new LinearConversionDataOperation()).ID)
                {
                    _linearDataOperation = (LinearConversionDataOperation)link.GetDataOperation(i);
                    _linearDataOperation.Prepare();
                    break;
                }
            }

            //prepare SmartBufferDataOperation
            for (int i = 0; i < link.DataOperationsCount; i++)
            {
                if (link.GetDataOperation(i).ID == (new SmartBufferDataOperation()).ID)
                {
                    ((SmartBufferDataOperation)link.GetDataOperation(i)).Prepare();
                    smartBuffer.DoExtendedDataVerification = ((SmartBufferDataOperation)link.GetDataOperation(i)).DoExtendedValidation;
                    smartBuffer.RelaxationFactor           = ((SmartBufferDataOperation)link.GetDataOperation(i)).RelaxationFactor;
                    break;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// get a output exchange item
        /// </summary>
        /// <param name="index">index number of the requested output exchange item</param>
        /// <returns>The requested exchange item</returns>
        public override IOutputExchangeItem GetOutputExchangeItem(int index)
        {
            OutputExchangeItem outputExchangeItem = ((IEngine)_engineApiAccess).GetOutputExchangeItem(index);

            //Add dataoperations to outputExchangeItems
            ElementMapper elementMapper  = new ElementMapper();
            ArrayList     dataOperations = new ArrayList();

            dataOperations = elementMapper.GetAvailableDataOperations(outputExchangeItem.ElementSet.ElementType);
            bool spatialDataOperationExists;
            bool linearConversionDataOperationExists;
            bool smartBufferDataOperationExists;

            foreach (IDataOperation dataOperation in dataOperations)
            {
                spatialDataOperationExists = false;
                foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
                {
                    if (dataOperation.ID == existingDataOperation.ID)
                    {
                        spatialDataOperationExists = true;
                    }
                }

                if (!spatialDataOperationExists)
                {
                    outputExchangeItem.AddDataOperation(dataOperation);
                }
            }

            IDataOperation linearConversionDataOperation = new LinearConversionDataOperation();

            linearConversionDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
            {
                if (linearConversionDataOperation.ID == existingDataOperation.ID)
                {
                    linearConversionDataOperationExists = true;
                }
            }

            if (!linearConversionDataOperationExists)
            {
                outputExchangeItem.AddDataOperation(new LinearConversionDataOperation());
            }

            IDataOperation smartBufferDataOperaion = new SmartBufferDataOperation();

            smartBufferDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
            {
                if (smartBufferDataOperaion.ID == existingDataOperation.ID)
                {
                    smartBufferDataOperationExists = true;
                }
            }

            if (!smartBufferDataOperationExists)
            {
                outputExchangeItem.AddDataOperation(new SmartBufferDataOperation());
            }

            return((IOutputExchangeItem)outputExchangeItem);
        }
コード例 #4
0
		/// <summary>
		/// get a output exchange item
		/// </summary>
		/// <param name="index">index number of the requested output exchange item</param>
		/// <returns>The requested exchange item</returns>
        public override IOutputExchangeItem GetOutputExchangeItem(int index)
		{
			OutputExchangeItem outputExchangeItem = ((IEngine)_engineApiAccess).GetOutputExchangeItem(index);

			//Add dataoperations to outputExchangeItems
			ElementMapper elementMapper = new ElementMapper();
			ArrayList dataOperations = new ArrayList();
			dataOperations = elementMapper.GetAvailableDataOperations(outputExchangeItem.ElementSet.ElementType);
			bool spatialDataOperationExists;
			bool linearConversionDataOperationExists;
			bool smartBufferDataOperationExists;
			foreach (IDataOperation dataOperation in dataOperations)
			{
				spatialDataOperationExists = false;
				foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
				{
					if (dataOperation.ID == existingDataOperation.ID)
					{
						spatialDataOperationExists = true;
					}
				}

				if (!spatialDataOperationExists)
				{
					outputExchangeItem.AddDataOperation(dataOperation);
				}
			}

			IDataOperation linearConversionDataOperation = new LinearConversionDataOperation();
			linearConversionDataOperationExists = false;
			foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
			{
				if (linearConversionDataOperation.ID == existingDataOperation.ID)
				{
					linearConversionDataOperationExists = true;
				}
			}

			if (!linearConversionDataOperationExists)
			{
				outputExchangeItem.AddDataOperation(new LinearConversionDataOperation());
			}

			IDataOperation smartBufferDataOperaion = new SmartBufferDataOperation();
			smartBufferDataOperationExists = false;
			foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
			{
				if (smartBufferDataOperaion.ID == existingDataOperation.ID)
				{
					smartBufferDataOperationExists = true;
				}
			}

			if (!smartBufferDataOperationExists)
			{
				outputExchangeItem.AddDataOperation(new SmartBufferDataOperation());
			}

			return (IOutputExchangeItem) outputExchangeItem;
		}
コード例 #5
0
 /// <summary>
 /// Creates a copy of the current instance.
 /// </summary>
 /// <returns>Copy of the instance</returns>
 public object Clone()
 {
   LinearConversionDataOperation clone = new LinearConversionDataOperation();
   clone._a = _a;
   clone._b = _b;
   clone._isActivated = _isActivated;
   clone._arguments = new Argument[ArgumentCount];
   for(int i=0; i<ArgumentCount; i++)
   {
     clone._arguments[i] = new HydroNumerics.OpenMI.Sdk.Backbone.Argument();
     clone._arguments[i].Description = _arguments[i].Description;
     clone._arguments[i].Key = _arguments[i].Key;
     clone._arguments[i].ReadOnly = _arguments[i].ReadOnly;
     clone._arguments[i].Value = _arguments[i].Value;
   }
   return clone;
 }
コード例 #6
0
        /// <summary>
        /// Initialize will create buffers, prepare data operations and create the mapping matrice when georeferenced links are used.
        /// The initialize method should be invoked in the ILinkableComponent prepare method (is done from the LinkableRunEngine).
        /// </summary>
        public void Initialize()
        {
            _bufferStates = new Hashtable();

            smartBuffer = new SmartBuffer();
            _useSpatialMapping = false;
            _linearDataOperation = null;

            

            //Setup Spatial mapper - mapping method is set to default for now!
            int index = -1;
            string description = " ";
            for (int i = 0; i < link.DataOperationsCount; i++)
            {
                for (int n = 0; n < link.GetDataOperation(i).ArgumentCount; n++)
                {
                    if (link.GetDataOperation(i).GetArgument(n).Key == "Type" && link.GetDataOperation(i).GetArgument(n).Value == "SpatialMapping")
                    {
                        for (int m = 0; m < link.GetDataOperation(i).ArgumentCount; m++)
                        {
                            if (link.GetDataOperation(i).GetArgument(m).Key == "Description")
                            {
                                description = link.GetDataOperation(i).GetArgument(m).Value;
                                break;
                            }
                        }
                        index = i;
                        break;
                    }
                }
                if (index == i)
                {
                    break;
                }
            }

            if (index >= 0)
            {
                if (description == " ")
                {
                    throw new Exception("Missing key: \"Description\" in spatial dataoperation arguments");
                }
                _useSpatialMapping = true;
                elementMapper =new ElementMapper();
                elementMapper.Initialise(description,link.SourceElementSet, link.TargetElementSet);
            }

            //Prepare linear data operation
            for(int i = 0; i < link.DataOperationsCount; i++)
            {
                if (link.GetDataOperation(i).ID == (new LinearConversionDataOperation()).ID)
                {
                    _linearDataOperation = (LinearConversionDataOperation) link.GetDataOperation(i);
                    _linearDataOperation.Prepare();
                    break;
                }
            }

            //prepare SmartBufferDataOperation
            for(int i = 0; i < link.DataOperationsCount; i++)
            {
                if (link.GetDataOperation(i).ID == (new SmartBufferDataOperation()).ID)
                {
                    ((SmartBufferDataOperation)link.GetDataOperation(i)).Prepare();
                    smartBuffer.DoExtendedDataVerification = ((SmartBufferDataOperation)link.GetDataOperation(i)).DoExtendedValidation;
                    smartBuffer.RelaxationFactor = ((SmartBufferDataOperation)link.GetDataOperation(i)).RelaxationFactor;
                    break;
                }
            }

        }