es.ants.felixgm.trmsim_wsn.trm.peertrust
Class PeerTrust_Sensor

java.lang.Object
  extended by es.ants.felixgm.trmsim_wsn.network.Sensor
      extended by es.ants.felixgm.trmsim_wsn.trm.peertrust.PeerTrust_Sensor
All Implemented Interfaces:
java.lang.Runnable

public class PeerTrust_Sensor
extends Sensor

This class models a Sensor implementing PeerTrust

Since:
0.2
Version:
0.3
Author:
Félix Gómez Mármol, Gregorio Martínez Pérez and Antonio Bernárdez

Field Summary
protected static int _windowSize
          Window size for storing transactions outcomes
protected  java.util.Collection<Transaction> transactions
          Collection of Transactions this sensor has had
 
Fields inherited from class es.ants.felixgm.trmsim_wsn.network.Sensor
_maxDistance, activeState, collusion, dynamic, id, idCount, links, numRequests, numRequestsThreshold, numRequestsTimer, outcome, requiredService, runningSimulation, servicesGoodness, sleepTimer, sleepTimerAux, transmittedDistance, trmmodelWSN, xPosition, yPosition
 
Constructor Summary
PeerTrust_Sensor()
          This constructor creates a new Sensor implementing PeerTrust
PeerTrust_Sensor(int id, double x, double y)
          This constructor creates a new Sensor implementing PeerTrust
 
Method Summary
 void addNewTransaction(PeerTrust_Sensor client, PeerTrust_Sensor server, Outcome outcome)
          This method adds a new Transaction to the collection of transactions of this sensor
static boolean collusion()
          Indicates if ther is a collusion or not
 Service get_requiredService()
          Returns the service requested by the client
 int getNumTransactions()
          Returns the number of Transactions this sensor has had
 java.util.Collection<Transaction> getTransactions()
          This method gets the collection of Transactions this sensor has had
 void reset()
          This method resets a Sensor to its initial state
static void set_windowSize(int windowSize)
          Sets the window size for storing transactions outcomes
 
Methods inherited from class es.ants.felixgm.trmsim_wsn.network.Sensor
addLink, addService, addTransmittedDistance, cancelAllTimers, distance, distanceInHops, equals, findSensors, get_goodness, get_numServices, get_outcome, get_services, get_transmittedDistance, get_TRModel_WSN, getNeighbors, getService, getX, getY, id, isActive, isNeighbor, isRunningSimulation, offersService, offersService, removeAllNeighbors, removeLink, removeService, resetId, run, serve, set_goodness, set_requiredService, set_TRModel_WSN, setActiveState, setCollusion, setDynamic, setMaxDistance, setRunningSimulation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_windowSize

protected static int _windowSize
Window size for storing transactions outcomes


transactions

protected java.util.Collection<Transaction> transactions
Collection of Transactions this sensor has had

Constructor Detail

PeerTrust_Sensor

public PeerTrust_Sensor()
This constructor creates a new Sensor implementing PeerTrust


PeerTrust_Sensor

public PeerTrust_Sensor(int id,
                        double x,
                        double y)
This constructor creates a new Sensor implementing PeerTrust

Parameters:
id - Identifier of the new sensor
x - X coordinate of the new sensor
y - Y coordinate of the new sensor
Method Detail

addNewTransaction

public void addNewTransaction(PeerTrust_Sensor client,
                              PeerTrust_Sensor server,
                              Outcome outcome)
This method adds a new Transaction to the collection of transactions of this sensor

Parameters:
client - The client who requested the service
server - The server who provided the service
outcome - Outcome of the trnsaction to be added

getTransactions

public java.util.Collection<Transaction> getTransactions()
This method gets the collection of Transactions this sensor has had

Returns:
The collection of Transactions this sensor has had

getNumTransactions

public int getNumTransactions()
Returns the number of Transactions this sensor has had

Returns:
The number of Transactions this sensor has had

reset

public void reset()
Description copied from class: Sensor
This method resets a Sensor to its initial state

Specified by:
reset in class Sensor

collusion

public static boolean collusion()
Indicates if ther is a collusion or not

Returns:
true, if there is a collusion, false otherwise

get_requiredService

public Service get_requiredService()
Returns the service requested by the client

Overrides:
get_requiredService in class Sensor
Returns:
The service requested by the client

set_windowSize

public static void set_windowSize(int windowSize)
Sets the window size for storing transactions outcomes

Parameters:
windowSize - New window size for storing transactions outcomes