⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 espotbasestation.java

📁 无线传感器网络节点Sun SPOT管理工具
💻 JAVA
字号:
/* * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.  *  * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is * described in this document. In particular, and without limitation, these intellectual property rights may * include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents * or pending patent applications in the U.S. and in other countries. *  * U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. * standard license agreement and applicable provisions of the FAR and its supplements. *  * Use is subject to license terms.  *  * This distribution may include materials developed by third parties. Sun, Sun Microsystems, the Sun logo and * Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  *  * Copyright (c) 2006 Sun Microsystems, Inc. Tous droits r?serv?s. *  * Sun Microsystems, Inc. d?tient les droits de propri?t? intellectuels relatifs ? la technologie incorpor?e dans * le produit qui est d?crit dans ce document. En particulier, et ce sans limitation, ces droits de propri?t? * intellectuelle peuvent inclure un ou plus des brevets am?ricains list?s ? l'adresse http://www.sun.com/patents * et un ou les brevets suppl?mentaires ou les applications de brevet en attente aux Etats - Unis et dans les * autres pays. *  * L'utilisation est soumise aux termes du contrat de licence. *  * Cette distribution peut comprendre des composants d?velopp?s par des tierces parties. * Sun, Sun Microsystems, le logo Sun et Java sont des marques de fabrique ou des marques d?pos?es de Sun * Microsystems, Inc. aux Etats-Unis et dans d'autres pays. */package com.sun.spot.spotworld.participants;import com.sun.spot.spotworld.common.IStateListener;import com.sun.spot.spotworld.common.LocaleUtil;import com.sun.spot.spotworld.gui.IUIObject;import java.lang.reflect.Method;import java.util.LinkedHashMap;import java.util.Vector;/** * Proxy for a Basestation.  NOT YET USED. * * This object listens to the USBSpotChecker's sole instance to receive updates in  * its state (like the basestaion being unplugged, etc.) * * This object has potentially many UI object attempting to depict this basetation. * The UI objecys are listeners and are told to noteState() when a change happens.  * * @author randy */public class ESpotBasestation extends ESpot implements IStateListener {        private String basestationPort;    // A cache, filled during the noteState() callback.    private boolean firstTime;         // The first time the basestation is told to noteState() this is true, else false        public void init(){        super.init();        basestationPort = "";//        USBSpotChecker.getInstance().addListener(this);        firstTime = true;    }        public LinkedHashMap<Method, String> getBasestationMethods() {        return new LinkedHashMap<Method, String>();    }            /*     * This representative listens to the USPSpotChecker      * We only use the first of any basestions. So far there is only one per host anyway.     */    public void noteState(Object obj){        //For now we only expect to be listening to USBSpotCheker singleton.        if(firstTime){             notifyListeners();            firstTime = false;            return;        }//        if( !(obj instanceof USBSpotChecker) ) return;  //        //Update the cache of the basestation port.//        USBSpotChecker x = (USBSpotChecker) obj; //        String[] bases = x.getFoundBasestations();//        Vector<String> bases = x.getKnownBasestationAddresses();//        if(bases.length == 0){//            basestationPort = "";//        } else {//            basestationPort = bases[0];//        }//        if (bases.size() == 0) basestationPort = "";//        else basestationPort = bases.firstElement();        //Tell the UI so it can update.         notifyListeners();            }        /*     * We expect UI objects to be listening to this object.     */    public void notifyListeners(){         // Changed the code to use getUIObjectsCopy() rather than        // getUIIterator. -- Robert        Vector<IUIObject> uiObjects = getUIObjectsCopy();        if (uiObjects == null) return;        for (IUIObject uio : uiObjects)            uio.noteState(this);    }    public String getBasestationPort() {        return basestationPort;    }        public boolean isBasestationConnected(){        return ! basestationPort.equals("");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -