/// <summary>
 /// Initialize data. </summary>
 /// <param name="initialize_defaults"> If true, the time series are set to null and other
 /// information is empty strings - this is suitable for the StateMod GUI.  If false,
 /// the data are set to missing - this is suitable for StateDMI where data will be filled. </param>
 private void initialize(bool initialize_defaults)
 {
     _smdata_type         = StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS;
     _cgoto               = "";
     _baseflow_MonthTS    = null;
     _baseflow_DayTS      = null;
     _related_smdata_type = StateMod_DataSet.COMP_UNKNOWN;
     if (initialize_defaults)
     {
         // Reasonable defaults...
         _crunidy = "0";         // Estimate average daily from monthly data.
     }
     else
     {
         // Missing...
         _crunidy = "";
     }
     _georecord = null;
 }
 /// <summary>
 /// Initialize data. </summary>
 /// <param name="initialize_defaults"> If true, the time series are set to null and other
 /// information to empty strings or other reasonable defaults - this is suitable
 /// for the StateMod GUI when creating new instances.  If false, the
 /// data values are set to missing - this is suitable for use with StateDMI, where
 /// data will be filled with commands. </param>
 private void initialize(bool initialize_defaults)
 {
     _smdata_type        = StateMod_DataSet.COMP_STREAMGAGE_STATIONS;
     _cgoto              = "";
     _historical_MonthTS = null;
     _historical_DayTS   = null;
     _baseflow_MonthTS   = null;
     _baseflow_DayTS     = null;
     if (initialize_defaults)
     {
         // Set to reasonable defaults...
         _crunidy = "0";         // Use monthly data
     }
     else
     {
         // Initialize to missing
         _crunidy = "";
     }
     _georecord = null;
 }
 /// <summary>
 /// Initialize data. </summary>
 /// <param name="initializeDefaults"> If true, then data values are initialized to
 /// reasonable defaults - this is suitable for adding a new instance in the
 /// StateMod GUI.  If false, data values are initialized to missing - this is
 /// suitable for a new instance in StateDMI. </param>
 private void initialize(bool initializeDefaults)
 {
     _smdata_type = StateMod_DataSet.COMP_INSTREAM_STATIONS;
     _ifrrdn      = "";
     if (initializeDefaults)
     {
         _cifridy = "0";      // Estimate average daily data from monthly
         _iifcom  = 2;        // Default to annual
     }
     else
     {
         _cifridy = "";
         _iifcom  = StateMod_Util.MISSING_INT;
     }
     _rights                 = new List <StateMod_InstreamFlowRight>();
     _demand_DayTS           = null;
     _demand_MonthTS         = null;
     _demand_average_MonthTS = null;
     _georecord              = null;
 }
 /// <summary>
 /// Set the geographic information object associated with the diversion. </summary>
 /// <param name="georecord"> Geographic record associated with the diversion. </param>
 public virtual void setGeoRecord(GeoRecord georecord)
 {
     _georecord = georecord;
 }
Example #5
0
        public void NdefMultipleWithNoise()
        {
            // Arrange
            // Extract the data from the Mifare card dump
            var extract = ExtractAllBlocksFromCardDump(CardDumpExamples.Memory1KDump2RecordsWithNoise);
            // Get the NDEF section from the card dump
            var ndef = ExtractAllMessage(extract);
            // Act
            // Get the NDEF Message
            NdefMessage message = new NdefMessage(ndef);
            var         geo     = new GeoRecord(message.Records.First());
            // Create a new Geo Record with same data
            var geoNew = new GeoRecord(48.853231, 2.349207);

            // Set same header as for the previous one with the first message
            geoNew.Header.MessageFlag |= MessageFlag.MessageBegin;
            Span <byte> geoNewSerialized = new byte[geoNew.Length];
            Span <byte> geoSerialized    = new byte[geo.Length];

            geoNew.Serialize(geoNewSerialized);
            message.Records.First().Serialize(geoSerialized);

            // Assert
            // Check if all is ok
            Assert.Equal(2, message.Records.Count);
            Assert.True(message.Records.First().Header.IsFirstMessage);
            Assert.True(message.Records.Last().Header.IsLastMessage);
            Assert.True(GeoRecord.IsGeoRecord(message.Records.First()));
            Assert.Equal(48.853231, geo.Latitude);
            Assert.Equal(2.349207, geo.Longitude);
            Assert.Equal(geoSerialized.ToArray(), geoNewSerialized.ToArray());

            // Act
            // Create a new MEdia record which is the same
            var mediaNew = new MediaRecord("image/jpeg", Encoding.UTF8.GetBytes("Test but not an image"));

            mediaNew.Header.MessageFlag |= MessageFlag.MessageEnd;
            Span <byte> mediaNewSerialized = new byte[mediaNew.Length];
            Span <byte> mediaSerialized    = new byte[message.Records.Last().Length];

            mediaNew.Serialize(mediaNewSerialized);
            message.Records.Last().Serialize(mediaSerialized);
            // Assert
            Assert.Equal(mediaSerialized.ToArray(), mediaNewSerialized.ToArray());

            // Arrange
            // Now create a new message and add the 2 records. We will before remove the
            // message begin and begin end flags to make sure they're properly create by
            // The serialize function
            geoNew.Header.MessageFlag   &= ~MessageFlag.MessageBegin;
            mediaNew.Header.MessageFlag &= ~MessageFlag.MessageEnd;
            var messageNew = new NdefMessage();

            messageNew.Records.Add(geoNew);
            messageNew.Records.Add(mediaNew);
            Span <byte> messageNewSerialiazed = new byte[messageNew.Length];

            // Act
            messageNew.Serialize(messageNewSerialiazed);
            // Assert
            Assert.Equal(ndef, messageNewSerialiazed.ToArray());

            // Act
            // Check that the serialized buffer is the same at the raw record
            Span <byte> serializedMessage = new byte[message.Length];

            message.Serialize(serializedMessage);
            // Assert
            Assert.Equal(ndef, serializedMessage.ToArray());
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string routine = "StateMod_RiverNetworkNode_JFrame.actionPerformed";

            if (Message.isDebugOn)
            {
                Message.printDebug(1, routine, "In actionPerformed: " + e.getActionCommand());
            }
            object source = e.getSource();

            if (source == __closeJButton)
            {
                saveCurrentRecord();
                int size = __riverNetworkNodesVector.Count;
                StateMod_RiverNetworkNode r = null;
                bool changed = false;
                for (int i = 0; i < size; i++)
                {
                    r = __riverNetworkNodesVector[i];
                    if (!changed && r.changed())
                    {
                        changed = true;
                    }
                    r.acceptChanges();
                }
                if (changed)
                {
                    __dataset.setDirty(StateMod_DataSet.COMP_RIVER_NETWORK, true);
                }
                if (__dataset_wm != null)
                {
                    __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK);
                }
                else
                {
                    JGUIUtil.close(this);
                }
            }
            else if (source == __applyJButton)
            {
                saveCurrentRecord();
                int size = __riverNetworkNodesVector.Count;
                StateMod_RiverNetworkNode r = null;
                bool changed = false;
                for (int i = 0; i < size; i++)
                {
                    r = __riverNetworkNodesVector[i];
                    if (!changed && r.changed())
                    {
                        changed = true;
                    }
                    r.createBackup();
                }
                if (changed)
                {
                    __dataset.setDirty(StateMod_DataSet.COMP_RIVER_NETWORK, true);
                }
            }
            else if (source == __cancelJButton)
            {
                int size = __riverNetworkNodesVector.Count;
                StateMod_RiverNetworkNode r = null;
                for (int i = 0; i < size; i++)
                {
                    r = __riverNetworkNodesVector[i];
                    r.restoreOriginal();
                }
                if (__dataset_wm != null)
                {
                    __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK);
                }
                else
                {
                    JGUIUtil.close(this);
                }
            }
            else if (source == __helpJButton)
            {
                // REVISIT HELP (JTS - 2003-08-18)
            }
            else if (source == __searchIDJRadioButton)
            {
                __searchName.setEditable(false);
                __searchID.setEditable(true);
            }
            else if (source == __searchNameJRadioButton)
            {
                __searchName.setEditable(true);
                __searchID.setEditable(false);
            }
            else if (source == __showOnMap_JButton)
            {
                GeoRecord geoRecord = getSelectedRiverNetworkNode().getGeoRecord();
                GRShape   shape     = geoRecord.getShape();
                __dataset_wm.showOnMap(getSelectedRiverNetworkNode(), "Node: " + getSelectedRiverNetworkNode().getID() + " - " + getSelectedRiverNetworkNode().getName(), new GRLimits(shape.xmin, shape.ymin, shape.xmax, shape.ymax), geoRecord.getLayer().getProjection());
            }
            else if (source == __showOnNetwork_JButton)
            {
                StateMod_Network_JFrame networkEditor = __dataset_wm.getNetworkEditor();
                if (networkEditor != null)
                {
                    HydrologyNode node = networkEditor.getNetworkJComponent().findNode(getSelectedRiverNetworkNode().getID(), false, false);
                    if (node != null)
                    {
                        __dataset_wm.showOnNetwork(getSelectedRiverNetworkNode(), "Node: " + getSelectedRiverNetworkNode().getID() + " - " + getSelectedRiverNetworkNode().getName(), new GRLimits(node.getX(), node.getY(), node.getX(), node.getY()));
                    }
                }
            }
            else if (source == __findNext)
            {
                searchWorksheet(__worksheet.getSelectedRow() + 1);
            }
            else if (source == __searchID || source == __searchName)
            {
                searchWorksheet(0);
            }
        }