Changeset 25:9a1b9ec9e11a in finroc_plugins_tcp-java


Ignore:
Timestamp:
16.12.2010 00:36:43 (9 years ago)
Author:
Max Reichardt <reichardt@…>
Branch:
default
Phase:
public
Convert:
svn:ccfa142a-2ffc-4be5-9ac5-93ef5ea46e35/trunk@26
Message:

Adapted to changes in finroc core

Location:
org/finroc/plugin/tcp
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • org/finroc/plugin/tcp/RemoteServer.java

    r24 r25  
    358358        //JavaOnlyBlock 
    359359        if (adminInterface != null && adminInterface.isReady()) { 
    360             adminInterface.managedDelete(); 
     360            adminInterface.delete(); 
    361361        } 
    362362 
     
    759759                    FrameworkElement fe = getChildElement(AdminServer.QUALIFIED_PORT_NAME, false); 
    760760                    if (fe != null && fe.isPort() && fe.isReady()) { 
    761                         ((AbstractPort)fe).connectToTarget(adminInterface); 
     761                        ((AbstractPort)fe).connectToTarget(adminInterface.getWrapped()); 
    762762                    } 
    763763                } 
     
    954954                    // check ping times 
    955955                    long startTime = System.currentTimeMillis(); 
    956                     long mayWait = TCPSettings.criticalPingThreshold.get(); 
     956                    long mayWait = TCPSettings.getInstance().criticalPingThreshold.get(); 
    957957                    mayWait = Math.min(mayWait, ctExpress.checkPingForDisconnect()); 
    958958                    mayWait = Math.min(mayWait, ctBulk.checkPingForDisconnect()); 
  • org/finroc/plugin/tcp/TCPConnection.java

    r24 r25  
    5757import org.finroc.core.buffer.CoreOutput; 
    5858import org.finroc.core.buffer.CoreInput; 
     59import org.finroc.core.parameter.ParameterNumeric; 
    5960import org.finroc.core.port.AbstractPort; 
    6061import org.finroc.core.port.ThreadLocalCache; 
     
    6869import org.finroc.core.portdatabase.DataType; 
    6970import org.finroc.core.portdatabase.SerializableReusable; 
    70 import org.finroc.core.setting.IntSetting; 
    7171import org.finroc.core.thread.CoreLoopThreadBase; 
    7272 
     
    104104 
    105105    /** References to Connection parameters */ 
    106     @Const @Ref private IntSetting minUpdateInterval; 
    107     @Const @Ref private IntSetting maxNotAcknowledgedPackets; 
     106    @Const @Ref private ParameterNumeric<Integer> minUpdateInterval; 
     107    @Const @Ref private ParameterNumeric<Integer> maxNotAcknowledgedPackets; 
    108108 
    109109    /** Index of last acknowledged sent packet */ 
     
    164164 
    165165        // set params 
    166         minUpdateInterval = (type == TCP.TCP_P2P_ID_BULK) ? TCPSettings.minUpdateIntervalBulk : TCPSettings.minUpdateIntervalExpress; 
    167         maxNotAcknowledgedPackets = (type == TCP.TCP_P2P_ID_BULK) ? TCPSettings.maxNotAcknowledgedPacketsBulk : TCPSettings.maxNotAcknowledgedPacketsExpress; 
     166        minUpdateInterval = (type == TCP.TCP_P2P_ID_BULK) ? TCPSettings.getInstance().minUpdateIntervalBulk : TCPSettings.getInstance().minUpdateIntervalExpress; 
     167        maxNotAcknowledgedPackets = (type == TCP.TCP_P2P_ID_BULK) ? TCPSettings.getInstance().maxNotAcknowledgedPacketsBulk : TCPSettings.getInstance().maxNotAcknowledgedPacketsExpress; 
    168168 
    169169        RuntimeSettings.getInstance().addUpdateTimeChangeListener(this); 
     
    678678        @SharedPtr Writer lockedWriter = writer; 
    679679        if (lockedWriter == null) { 
    680             return TCPSettings.criticalPingThreshold.get(); 
     680            return TCPSettings.getInstance().criticalPingThreshold.get(); 
    681681        } 
    682682        if (lastAcknowledgedPacket != lockedWriter.curPacketIndex) { 
    683683            long criticalPacketTime = sentPacketTime[(lastAcknowledgedPacket + 1) & TCPSettings.MAX_NOT_ACKNOWLEDGED_PACKETS]; 
    684             long timeLeft = criticalPacketTime + TCPSettings.criticalPingThreshold.get() - System.currentTimeMillis(); 
     684            long timeLeft = criticalPacketTime + TCPSettings.getInstance().criticalPingThreshold.get() - System.currentTimeMillis(); 
    685685            if (timeLeft < 0) { 
    686686                handlePingTimeExceed(); 
    687                 return TCPSettings.criticalPingThreshold.get(); 
     687                return TCPSettings.getInstance().criticalPingThreshold.get(); 
    688688            } 
    689689            return timeLeft; 
    690690        } else { 
    691             return TCPSettings.criticalPingThreshold.get(); 
     691            return TCPSettings.getInstance().criticalPingThreshold.get(); 
    692692        } 
    693693    } 
     
    726726        if (lastAcknowledgedPacket != lockedWriter.curPacketIndex) { 
    727727            long criticalPacketTime = sentPacketTime[(lastAcknowledgedPacket + 1) & TCPSettings.MAX_NOT_ACKNOWLEDGED_PACKETS]; 
    728             long timeLeft = criticalPacketTime + TCPSettings.criticalPingThreshold.get() - System.currentTimeMillis(); 
     728            long timeLeft = criticalPacketTime + TCPSettings.getInstance().criticalPingThreshold.get() - System.currentTimeMillis(); 
    729729            return timeLeft < 0; 
    730730        } else { 
  • org/finroc/plugin/tcp/TCPPeer.java

    r15 r25  
    3434import org.finroc.log.LogDomain; 
    3535import org.finroc.log.LogLevel; 
    36 import org.finroc.core.ChildIterator; 
    3736import org.finroc.core.CoreFlags; 
    3837import org.finroc.core.FrameworkElement; 
  • org/finroc/plugin/tcp/TCPPort.java

    r24 r25  
    173173 
    174174        // 5. runtime default 
    175         return (short)RuntimeSettings.DEFAULT_MINIMUM_NETWORK_UPDATE_TIME.get(); 
     175        int res = RuntimeSettings.DEFAULT_MINIMUM_NETWORK_UPDATE_TIME.get(); 
     176        return (short)res; 
    176177    } 
    177178 
  • org/finroc/plugin/tcp/TCPServerConnection.java

    r24 r25  
    4242import org.finroc.log.LogLevel; 
    4343 
    44 import org.finroc.core.ChildIterator; 
    4544import org.finroc.core.CoreFlags; 
    4645import org.finroc.core.FrameworkElement; 
     
    477476 
    478477            long startTime = Time.getCoarse(); 
    479             long mayWait = TCPSettings.criticalPingThreshold.get(); 
     478            long mayWait = TCPSettings.getInstance().criticalPingThreshold.get(); 
    480479 
    481480            @Ptr ArrayWrapper<TCPServerConnection> it = connections.getIterable(); 
  • org/finroc/plugin/tcp/TCPSettings.java

    r24 r25  
    2323 
    2424import org.finroc.jc.annotation.Const; 
     25import org.finroc.jc.annotation.Ptr; 
     26import org.finroc.core.FrameworkElement; 
    2527import org.finroc.core.RuntimeSettings; 
    2628import org.finroc.core.datatype.Bounds; 
    2729import org.finroc.core.datatype.Constant; 
    2830import org.finroc.core.datatype.Unit; 
    29 import org.finroc.core.setting.IntSetting; 
    30 import org.finroc.core.setting.Settings; 
     31import org.finroc.core.parameter.ParameterNumeric; 
    3132 
    3233/** 
     
    3536 * TCP Settings 
    3637 */ 
    37 public class TCPSettings extends Settings { 
     38public class TCPSettings extends FrameworkElement { 
    3839 
    3940    /** Singleton Instance */ 
    40     private static final TCPSettings inst = new TCPSettings(); 
     41    private static TCPSettings inst = null; 
    4142 
    4243    /** Loop Interval for Connector Thread... currently only 1ms since waiting is done depending on critical ping times instead */ 
     
    6566 
    6667    // Port settings 
    67     static final IntSetting maxNotAcknowledgedPacketsExpress = 
    68         inst.add("Maximum not acknowledged express packets", 4, true, Unit.NO_UNIT, new Bounds(1, 40, true)); 
     68    final ParameterNumeric<Integer> maxNotAcknowledgedPacketsExpress = 
     69        new ParameterNumeric<Integer>("Maximum not acknowledged express packets", this, Unit.NO_UNIT, 4, new Bounds(1, 40, true)); 
    6970 
    70     static final IntSetting maxNotAcknowledgedPacketsBulk = 
    71         inst.add("Maximum not acknowledged bulk packets", 2, true, Unit.NO_UNIT, new Bounds(1, 40, true)); 
     71    final ParameterNumeric<Integer> maxNotAcknowledgedPacketsBulk = 
     72        new ParameterNumeric<Integer>("Maximum not acknowledged bulk packets", this, Unit.NO_UNIT, 2, new Bounds(1, 40, true)); 
    7273 
    73     static final IntSetting minUpdateIntervalExpress = 
    74         inst.add("Minimum Express Update Interval", 25, true, Unit.ms, new Bounds(1, 2000, Constant.NO_MIN_TIME_LIMIT)); 
     74    final ParameterNumeric<Integer> minUpdateIntervalExpress = 
     75        new ParameterNumeric<Integer>("Minimum Express Update Interval", this, Unit.ms, 25, new Bounds(1, 2000, Constant.NO_MIN_TIME_LIMIT)); 
    7576 
    76     static final IntSetting minUpdateIntervalBulk = 
    77         inst.add("Minimum Bulk Update Interval", 50, true, Unit.ms, new Bounds(1, 2000, Constant.NO_MIN_TIME_LIMIT)); 
     77    final ParameterNumeric<Integer> minUpdateIntervalBulk = 
     78        new ParameterNumeric<Integer>("Minimum Bulk Update Interval", this, Unit.ms, 50, new Bounds(1, 2000, Constant.NO_MIN_TIME_LIMIT)); 
    7879 
    79     static final IntSetting criticalPingThreshold = 
    80         inst.add("Critical Ping Threshold", 1500, true, Unit.ms, new Bounds(50, 20000, Constant.NO_MAX_TIME_LIMIT)); 
     80    final ParameterNumeric<Integer> criticalPingThreshold = 
     81        new ParameterNumeric<Integer>("Critical Ping Threshold", this, Unit.ms, 1500, new Bounds(50, 20000, Constant.NO_MAX_TIME_LIMIT)); 
    8182 
    8283    /** Debug Settings */ 
     
    8586 
    8687    private TCPSettings() { 
    87         super("TCP Settings", "tcp", true); 
     88        super(RuntimeSettings.getInstance(), "TCP Settings"); 
    8889    } 
    8990 
    9091    static void initInstance() { 
    91         inst.init(RuntimeSettings.getInstance()); 
     92        getInstance().init(); 
     93    } 
     94 
     95    public static @Ptr TCPSettings getInstance() { 
     96        if (inst == null) { 
     97            inst = new TCPSettings(); 
     98        } 
     99        return inst; 
    92100    } 
    93101} 
Note: See TracChangeset for help on using the changeset viewer.