/// <summary>
        /// Initialize plugin, providing arguments from setup, see <see cref="P:DHI.Mike1D.Mike1DDataAccess.Mike1DPluginInfo.Arguments"/>
        /// </summary>
        /// <param name="arguments">Arguments stored in setup</param>
        /// <param name="mike1DData">MIKE 1D data object</param>
        public void Initialize(IList <Mike1DPluginArgument> arguments, Mike1DData mike1DData)
        {
            _arguments = arguments;

            // (*1) Register for the ControllerCreated event
            mike1DData.ControllerCreatedEvent += ControllerCreated;

            // (*1) Store list of MyStructure and original weir coefficient, used in PreTimeStepEvent
            _myStructures = new List <MyStructure>();
            _myStructuresWeirCoefficients = new List <double>();

            // (*2) Add structure output to HD result file. This works together with the
            //      implementation of Offers and ValueGetter in MyStructure class
            AddStructureOutput(mike1DData);

            // Culture used when parsing arguments
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            // Process each argument
            foreach (Mike1DPluginArgument argument in _arguments)
            {
                // Process only arguments with key == "Struc"
                if (!System.StringComparer.OrdinalIgnoreCase.Equals(argument.Key, "Struc"))
                {
                    continue;
                }

                string[] values = argument.Value.Split(';');

                // Create a new MyStructure
                MyStructure structure = new MyStructure();

                // This must be a unique ID!!!
                structure.ID = values[0];
                // Location in network
                structure.Location = new Location(values[1], double.Parse(values[2], invariantCulture));
                // Use TopoID of reach
                structure.TopoID = values[3];

                // Structure parameters - structure dependent.
                structure.CrestLevel      = double.Parse(values[4], invariantCulture);
                structure.CrestWidth      = double.Parse(values[5], invariantCulture);
                structure.WeirCoefficient = double.Parse(values[6], invariantCulture);

                // Add it to Mike 1D setup
                mike1DData.Network.StructureCollection.Structures.Add(structure);

                // (*1) Store structure locally
                _myStructures.Add(structure);
                _myStructuresWeirCoefficients.Add(structure.WeirCoefficient);
            }
        }
        /// <summary>
        /// (*1) Method that is called before every time step
        /// </summary>
        /// <param name="timeN">Time at beginning of time step</param>
        /// <param name="timeNp1">Time at end of time step</param>
        /// <param name="redoCount">redo-counter, incremented when an adaptive time step is redone. Initially zero.</param>
        private void PreTimeStepEvent(DateTime timeN, DateTime timeNp1, int redoCount)
        {
            // In this method we will vary the WeirCoefficient as a function of time.
            // This method can add many kinds of user defined control of structures
            // (or other simulation parameters), as eg. functionality for closing
            // gates, starting pumps etc.

            // Calculate number of hours since simulation start
            DateTime startTime = _controller.Mike1DData.SimulationStart;
            double   hours     = (timeNp1 - startTime).TotalHours;

            // Vary the weir-coefficient in a 2-hour loop with +/- 0.5, though never smaller than 0.4
            for (int i = 0; i < _myStructures.Count; i++)
            {
                MyStructure myStructure = _myStructures[i];
                myStructure.WeirCoefficient = Math.Max(_myStructuresWeirCoefficients[0] + 0.5 * Math.Sin(2 * Math.PI * hours / 2), 0.4);
            }
        }