Adapter is an object own by a given device controller that handle data connection
348758
function DevAdapter (controller) {
    this.id        = controller.svc;
    this.uid       = "//" + controller.svcopts.adapter + "/" + controller.svc + ":" +  controller.svcopts.port;;
    this.info      = 'aistcp';
    this.control   = 'tcpsock';                 // this wait for AIS clients to connect via TCP  
    this.debug     =  controller.svcopts.debug; // inherit debug from controller
    this.controller =  controller;              // keep a link to device controller and TCP socket
    this.clients   =  [];                       // array to keep track of client
    this.count     =  0;                        // index for incomming client
    this.uport     =  controller.svcopts.uport;
    this.uhost     =  controller.svcopts.uhost || "127.0.0.1";
    this.Debug (1,"uid=%s", this.uid);

    // create UDP port to push packet out
    if (this.uport) this.usock = dgram.createSocket('udp4');

    HookBackendEvent(this, controller.gateway.backend);
}
716047
function loadAdapter(type, location) {
    var options = adapterConfig[type];
    try {
        var modulePath = adapterModulePath(type, options);

        global.JuttleAdapterAPI = JuttleAdapterAPI;

        var start = new Date();

        if (!options.builtin) {
            checkCompatible(type, modulePath, location);
        }

        var init = require(modulePath);

        var loaded = new Date();
        var adapter = init(options);

        global.JuttleAdapterAPI = undefined;

        if (adapter.name !== type) {
            throw new Error('adapter name ', adapter.name, ' != type ', type);
        }
        var initialized = new Date();

        logger.debug(adapter.name, 'adapter loaded in', (loaded - start), 'ms,',
                     'initialized in', (initialized - loaded), 'ms');

        register(adapter.name, adapter);

        return adapter;
    } catch (err) {
        logger.error('error loading adapter ' + type + ': ' + err.message);
        throw err;
    }
}
563555
public URL copyWithDevice(String deviceAddress, String attrName, String attrValue) {
        return new URL(this.protocol, this.adapterAddress, deviceAddress, Collections.singletonMap(attrName, attrValue),
                this.serviceUUID, this.characteristicUUID, this.fieldName);
    }
718828
def createDevice(self, deviceCfg):
        
        ioCfg = deviceCfg['io']
        type = deviceCfg['type']
        if type == 'mpu6050':
            fs = deviceCfg.get('fs')
            name = deviceCfg.get('name')
            if ioCfg['type'] == 'mock':
                provider = ioCfg.get('provider')
                if provider is not None and provider == 'white noise':
                    dataProvider = WhiteNoiseProvider()
                else:
                    raise ValueError(provider + " is not a supported mock io data provider")
                self.logger.warning("Loading mock data provider for mpu6050")
                io = mock_io(dataProvider=dataProvider.provide)
            elif ioCfg['type'] == 'smbus':
                busId = ioCfg['busId']
                self.logger.warning("Loading smbus %d", busId)
                io = smbus_io(busId)
            else:
                raise ValueError(ioCfg['type'] + " is not a supported io provider")
            self.logger.warning("Loading mpu6050 " + name + "/" + str(fs))
            return mpu6050(io, name=name, fs=fs) if name is not None else mpu6050(io, fs=fs)
        else:
            raise ValueError(type + " is not a supported device")
518695
function (controlPoint, uuid, location, desc, localAddress) {
    EventEmitter.call(this);

    if (TRACE) {
        logger.info({
            method: "UpnpDevice",
            uuid: uuid,
        }, "new device object");
    }
    this.controlPoint = controlPoint;

    this.uuid = uuid;
    this.udn = desc.UDN[0];

    this.forgotten = false
    this.last_seen = (new Date()).getTime();

    this.location = location;

    this.deviceType = desc.deviceType ? desc.deviceType[0] : null;
    this.friendlyName = desc.friendlyName ? desc.friendlyName[0] : null;
    this.manufacturer = desc.manufacturer ? desc.manufacturer[0] : null;
    this.manufacturerUrl = desc.manufacturerURL ? desc.manufacturerURL[0] : null;
    this.modelNumber = desc.modelNumber ? desc.modelNumber[0] : null;
    this.modelDescription = desc.modelDescription ? desc.modelDescription[0] : null;
    this.modelName = desc.modelName ? desc.modelName[0] : null;
    this.modelUrl = desc.modelURL ? desc.modelURL[0] : null;
    this.softwareVersion = desc.softwareVersion ? desc.softwareVersion[0] : null;
    this.hardwareVersion = desc.hardwareVersion ? desc.hardwareVersion[0] : null;
    this.serialNum = desc.serialNum ? desc.serialNum[0] : null;

    var u = url.parse(this.location);
    this.host = u.hostname;
    this.port = u.port;

    this.localAddress = localAddress;

    this.devices = {}; // sub-devices

    this.services = {};

    this._handleDeviceInfo(desc);

    if (seend[this.uuid] === undefined) {
        seend[this.uuid] = true;
        logger.info({
            method: "UpnpDevice",
            device: {
                loction: this.location,
                uuid: this.uuid,
                deviceType: this.deviceType,
                friendlyName: this.friendlyName,
                manufacturer: this.manufacturer,
                manufacturerUrl: this.manufacturerURL,
                modelNumber: this.modelNumber,
                modelDescription: this.modelDescription,
                modelName: this.modelName,
                modelUrl: this.modelURL,
            }
        }, "previously unseen UPnP device");
    }
    // var self = this;
    // this._getDeviceDetails(function(desc) {
    // self._handleDeviceInfo(desc);
    // });

}
1031511
function use(adapter) {
  if (~adapters.indexOf(adapter)) return false;

  adapters.push(adapter);
  return true;
}
576698
function EventHandlerAccept (device, data){
        console.log ("#%d- Action Devid:[%s] Name:[%s] Cmd:[%s] Lat:%d Lon:%d Speed=%d", count, device.devid, device.name, data.cmd, data.lat, data.lon, data.sog);
    }
1200572
async def get_controller(self):
        
        from juju.controller import Controller
        controller = Controller(jujudata=self._connector.jujudata)
        kwargs = self.connection().connect_params()
        kwargs.pop('uuid')
        await controller._connect_direct(**kwargs)
        return controller
244397
private GVRCursorController getUniqueControllerId(int deviceId) {
        GVRCursorController controller = controllerIds.get(deviceId);
        if (controller != null) {
            return controller;
        }
        return null;
    }
966997
function createDeviceConnectionObj(dt, ct, id) {
            var obj = {
                'dt': dt,
                'ct': ct,
                'id': id,
                'connectionType': ct,
                'connectionTypeStr': driver_const.DRIVER_CONNECTION_TYPE_NAMES[ct],
                'connectionTypeName': driver_const.CONNECTION_TYPE_NAMES[ct],
                'name': driver_const.CONNECTION_TYPE_NAMES[ct],
                'isVerified': false,
                'verified': false,
                'isScanned': false,
                'insertionMethod': 'unknown',
                'foundByAttribute': false,
                'isActive': false,
                'isMockDevice': false,
            };
            var usbCT = driver_const.connectionTypes.usb;
            var ethCT = driver_const.connectionTypes.ethernet;
            var wifiCT = driver_const.connectionTypes.wifi;

            if((ct == ethCT)||(ct == wifiCT)) {
                obj.ip = id;
                obj.ipAddress = id;
                // Define the port as the modbus 502 port.
                obj.port = driver_const.LJM_MODBUS_PORT;
            } else if(ct == usbCT) {
                obj.ip = '0.0.0.0';
                obj.ipAddress = '0.0.0.0';
                obj.port = 0;
            }
            return obj;
        }
38956
function Adapter(clientPtcl, serverPtcl, fingerprint) {
  this._clientPtcl = clientPtcl;
  this._serverPtcl = serverPtcl;
  this._fingerprint = fingerprint; // Convenience.
  this._rsvs = clientPtcl.equals(serverPtcl) ? null : this._createResolvers();
}
509356
public void setAdapter(ListAdapter adapter) {
        if (mAdapter != null) {
            mAdapter.unregisterDataSetObserver(mDataObserver);
        }

        mAdapter = adapter;

        if (mAdapter != null) {
            mAdapter.registerDataSetObserver(mDataObserver);
            mAreAllItemsSelectable = mAdapter.areAllItemsEnabled();
        }

        setupChildren();

    }
495334
public void connectDevice(Device device) throws ShanksException {
        if (this.linkedDevices.size() < deviceCapacity) {
            if (!this.linkedDevices.contains(device)) {
                this.linkedDevices.add(device);
                device.connectToLink(this);
                logger.finer("Link " + this.getID() + " has Device "
                        + device.getID() + " in its linked device list.");
            } else {
                logger.finer("Link " + this.getID() + " already has Device "
                        + device.getID() + " in its linked device list.");
            }
        } else {
            if (!this.linkedDevices.contains(device)) {
                logger.warning("Link " + this.getID()
                        + " is full of its capacity. Device " + device.getID()
                        + " was not included in its linked device list.");
                throw new TooManyConnectionException(this);
            } else {
                logger.finer("Link " + this.getID() + " already has Device "
                        + device.getID() + " in its linked device list.");
            }
        }
    }
174891
function SerialDevice(port, settings, Connection) {

  // call super class
  Device.call(this, Connection);

  this.set('portName', port);
  this.set('settings', settings);

  this.set('state', 'close');
}
218102
def get_referenced_object(self):
        

        if self._DeviceServer is not None:
            return self._DeviceServer

        raise exception.BunqException(self._ERROR_NULL_FIELDS)
196650
function getAdapter(serviceInfo, resource, moduleStack) {
        var adapterName = serviceInfo.adapterName;

        // if adapter name is 'service' and there is a default, switch to the default
        if (adapterName === 'service' && resource.adapters[this.injector.container]) {
            adapterName = serviceInfo.adapterName = resource.adapters[this.injector.container];
            serviceInfo.adapterImpl = this.injector.adapterMap[adapterName];
            serviceInfo.serviceName = utils.getCamelCase(serviceInfo.resourceName + '.' +
                serviceInfo.adapterName + '.service');
        }

        // if that doesn't work, we will assume the adapter is in the current codebase, so go get it
        var overridePath = '/resources/' + serviceInfo.resourceName + '/' + serviceInfo.resourceName + '.' +
            (adapterName === 'service' ? adapterName : adapterName + '.service');
        var adapterPath = '/adapters/' + adapterName + '/' +
            serviceInfo.adapterImpl + '.' + adapterName + '.adapter';

        // if override exists, use that one, else use the lower level adapter
        var Adapter =
            this.loadIfExists(overridePath, moduleStack, null) ||
            this.injector.adapters[serviceInfo.adapterImpl] ||
            this.loadIfExists(adapterPath, moduleStack, null);

        // if still no adapter found, then there is an issue
        if (!Adapter) {
            throw new Error('ServiceFactory could not find adapter ' + adapterName +
            ' paths ' + overridePath + ' and ' + adapterPath);
        }

        return new Adapter(resource);
    }
959840
def _handle_adapter(self, app):
        
        if 'IMAGINE_ADAPTER' in app.config \
                and 'name' in app.config['IMAGINE_ADAPTER'] \
                and app.config['IMAGINE_ADAPTER']['name'] in self._adapters.keys():
            self._adapter = self._adapters[app.config['IMAGINE_ADAPTER']['name']](
                **app.config['IMAGINE_ADAPTER']
            )
        else:
            raise ValueError('Unknown _adapter: %s' % str(app.config['IMAGINE_ADAPTER']))