ModbusDeviceImpl.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:Ptoceti 作者:
public ModbusDriverCommunicator( String modbusPort, int modbusId, int  modbusPoolingRateS ) {
    this.id = modbusId;
    this.portName = modbusPort;
    this.poolingTimeMill = ((long)modbusPoolingRateS);

    // We first need to get a reference to the modbus driver service. We try to get this reference dynamically
    // by constructing a listener that will detect when the modbus driver service appear or disapear.
    String filter = "(&(objectclass=" + modbusDriverServiceName + ")"
        + "(" + ModbusDriver.MODBUS_DRIVER_SERVICE_PORT + "=" + modbusPort + "))";

    try {
        Activator.bc.addServiceListener( this, filter);
        // in case the service is already registered, we send a REGISTERED event to its listener.
        ServiceReference srModbus[] = Activator.bc.getServiceReferences( modbusDriverServiceName, filter );
        if( srModbus != null ) {
            this.serviceChanged(new ServiceEvent( ServiceEvent.REGISTERED, srModbus[0] ));
        }
    } catch ( InvalidSyntaxException e ) {
        // We known there shouldn't be an exception thrown here since we made the filter string.
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号