001    /**
002     *  "TRMSim-WSN, Trust and Reputation Models Simulator for Wireless
003     * Sensor Networks" is free software: you can redistribute it and/or
004     * modify it under the terms of the GNU Lesser General Public License
005     * as published by the Free Software Foundation, either version 3 of
006     * the License, or (at your option) any later version always keeping
007     * the additional terms specified in this license.
008     *
009     * This program is distributed in the hope that it will be useful,
010     * but WITHOUT ANY WARRANTY; without even the implied warranty of
011     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012     * GNU Lesser General Public License for more details.
013     *
014     *
015     * Additional Terms of this License
016     * --------------------------------
017     *
018     * 1. It is Required the preservation of specified reasonable legal notices
019     *   and author attributions in that material and in the Appropriate Legal
020     *   Notices displayed by works containing it.
021     *
022     * 2. It is limited the use for publicity purposes of names of licensors or
023     *   authors of the material.
024     *
025     * 3. It is Required indemnification of licensors and authors of that material
026     *   by anyone who conveys the material (or modified versions of it) with
027     *   contractual assumptions of liability to the recipient, for any liability
028     *   that these contractual assumptions directly impose on those licensors
029     *   and authors.
030     *
031     * 4. It is Prohibited misrepresentation of the origin of that material, and it is
032     *   required that modified versions of such material be marked in reasonable
033     *   ways as different from the original version.
034     *
035     * 5. It is Declined to grant rights under trademark law for use of some trade
036     *   names, trademarks, or service marks.
037     *
038     * You should have received a copy of the GNU Lesser General Public License
039     * along with this program (lgpl.txt).  If not, see <http://www.gnu.org/licenses/>
040    */
041    
042    package es.ants.felixgm.trmsim_wsn.trm.templatetrm;
043    
044    import es.ants.felixgm.trmsim_wsn.network.Network;
045    import es.ants.felixgm.trmsim_wsn.network.Sensor;
046    import es.ants.felixgm.trmsim_wsn.network.Service;
047    import java.util.Collection;
048    
049    /**
050     * <p>This class models a network composed by sensors implementing TemplateTRM</p>
051     * @author <a href="http://ants.dif.um.es/~felixgm/en" target="_blank">F&eacute;lix G&oacute;mez M&aacute;rmol</a>, <a href="http://webs.um.es/gregorio" target="_blank">Gregorio Mart&iacute;nez P&eacute;rez</a>
052     * @version 0.3
053     * @since 0.3
054     */
055    public class TemplateTRM_Network extends Network {
056        /**
057         * This constructor creates a new random TemplateTRM Network using the given parameters
058         * @param numSensors Network number sensors
059         * @param probClients The network will have a number of clients depending of this parameter.
060         * @param rangeFactor Range Factor.
061         * @param probServices Probability of servers offers services.
062         * @param probGoodness Probability of servers being good.
063         * @param services Services that servers offers to clients.
064         */
065        public TemplateTRM_Network(
066                int numSensors,
067                double probClients,
068                double rangeFactor,
069                Collection<Double> probServices,
070                Collection<Double> probGoodness,
071                Collection<Service> services) {
072            super(numSensors, probClients, rangeFactor, probServices, probGoodness, services);
073            reset();
074        }
075    
076        /**
077         * This method loads a network from a XML file and creates the specific
078         * corresponding TemplateTRM Network
079         * @param xmlFilePath Path of the XML to load the network from
080         * @throws java.lang.Exception If the XML file given does not have the appropriate structure, or if
081         * a sensor links to an undefined sensor, or if a sensor links to itself
082         */
083        public TemplateTRM_Network(String xmlFilePath) throws Exception {
084            super(xmlFilePath);
085            reset();
086        }
087    
088        @Override
089        public Sensor newSensor(){
090            return new TemplateTRM_Sensor();
091        }
092    
093        @Override
094        public Sensor newSensor(int id, double x, double y) {
095            return new TemplateTRM_Sensor(id,x,y);
096        }
097    }