📄 consoletest.java
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/import java.io.IOException;import com.intel.mobile.base.*;import com.intel.mobile.battery.*;import com.intel.mobile.storage.*;import com.intel.mobile.context.*;import com.intel.mobile.network.*;import com.intel.mobile.processor.*;import com.intel.mobile.display.*;import com.intel.mobile.platform.*;/** * <class or interface desc> */public class ConsoleTest{ private ProcessorClass myProcessorClass = null; private BatteryClass myBatteryClass = null; private PhysicalDiskClass myPhysicalDiskClass = null; private LogicalDiskClass myLogicalDiskClass = null; private MemoryClass myMemoryClass = null; private DisplayAdapterClass myDisplayAdapterClass = null; private NetworkAdapterClass myAdapterClass = null; private WiredAdapterClass myWiredClass = null; private RadioAdapterClass myRadioClass = null; private LinkProtocolClass myProtocolClass = null; private Protocol802_3Class my802_3Class = null; private Protocol802_11Class my802_11Class = null; private ProtocolBluetoothPanClass myBluetoothPanClass = null; private ProtocolWwanClass myWwanClass = null; private ProtocolGprsClass myGprsClass = null; private ProtocolCdmaClass myCdmaClass = null; private ContextClass myContextClass = null; private PlatformClass myPlatformClass = null; private ClientObserver theObserver = null; /** * Main entry * @param args */ public static void main(String[] args) { try { new ConsoleTest().test(); } catch (IntelMobileException ex) { System.out.println(ex); System.out.println("Message: " + ex.getMessage()); System.out.println("GeneralMessage: " + ex.GetGeneralMessage()); System.out.println("Source: " + ex.GetSource()); System.out.println("TargetSite: " + ex.GetTargetSite()); System.out.println("ErrorCode: " + ex.GetErrorCode()); System.out.println("DetailErrorInfo: " + ex.GetDetailErrorInfo()); //ex.printStackTrace(); } } public void test() throws IntelMobileException { System.out.print("Loading Processor\n"); //System.out.print("Skip Processor\n"); //myProcessorClass = null; myProcessorClass = new ProcessorClass(); System.out.print("Loaded Processor\n"); System.out.print("Loading Battery\n"); //System.out.print("Skip Battery\n"); //myBatteryClass = null; myBatteryClass = new BatteryClass(); System.out.print("Loaded Battery\n"); System.out.print("Loading DisplayAdapter\n"); //System.out.print("Skip DisplayAdapter\n"); //myDisplayAdapterClass = null; myDisplayAdapterClass = new DisplayAdapterClass(); System.out.print("Loaded DisplayAdapter\n"); System.out.print("Loading Storage\n"); myPhysicalDiskClass = new PhysicalDiskClass(); myLogicalDiskClass = new LogicalDiskClass(); myMemoryClass = new MemoryClass(); System.out.print("Loaded Storage\n"); System.out.print("Loading Context\n"); //System.out.print("Skip Context\n"); myContextClass = new ContextClass(); //It is too slow. System.out.print("Loaded Context\n"); System.out.print("Loading NetworkAdapters\n"); //System.out.print("Skip NetworkAdapters\n"); myAdapterClass = new NetworkAdapterClass(); myWiredClass = new WiredAdapterClass(); myRadioClass = new RadioAdapterClass(); System.out.print("Loaded NetworkAdapters\n"); System.out.print("Loading LinkProtocols\n"); myProtocolClass = new LinkProtocolClass(); my802_3Class = new Protocol802_3Class(); my802_11Class = new Protocol802_11Class();//fbi myGprsClass = new ProtocolGprsClass();//fbi myCdmaClass = new ProtocolCdmaClass();//fbi myWwanClass = new ProtocolWwanClass(); myBluetoothPanClass = new ProtocolBluetoothPanClass(); System.out.print("Loaded LinkProtocols\n"); myPlatformClass = new PlatformClass(); theObserver = new ClientObserver(); try { System.out.print("------------Enter COMMAND ('H' for help)------------\n"); boolean bExit = false; boolean regFlag = false; do { switch (System.in.read()) { case 'g': case 'G': System.gc(); break; case 'q': case 'Q': if (regFlag == true) { unregisterEvents(); regFlag = false; } bExit = true; continue; case 'h': case 'H': printHelp(); break; case 'e': case 'E': if (regFlag == false) { registerEvents(); regFlag = true; } break; case 'u': case 'U': if (regFlag == true) { unregisterEvents(); regFlag = false; } break; case 'c': case 'C': printContext(); break; case 'a': case 'A': printNetworkAdapter(); break; case 'p': case 'P': printLinkProtocol(); break; case 'b': case 'B': printBattery(); break; case 'n': case 'N': printDisplayAdapter(); break; case 'z': case 'Z': printPhysicalDisk(); break; case 'x': case 'X': printLogicalDisk(); break; case 'm': case 'M': printMemory(); break; case 'r': case 'R': ProcessorTest.printInfo(myProcessorClass); break; case 't': case 'T': thresholdCmd(); break; case 'f': case 'F': printPlatform(); platformCmd(); break; case 's': case 'S': serverComtextCmd(); break; default: continue; } System.out.print("------------Enter COMMAND ('H' for help)------------\n"); } while (!bExit); System.out.print("------------Leaving COMMAND------------\n"); } catch (IOException ex) { ex.printStackTrace(); } finally { //theObserver.close(); } } private void printHelp() { StringBuffer strBuf = new StringBuffer(); strBuf.append("\n") .append(" - 'G' - Garbage Collect\n") .append(" - 'Q' - Quit\n") .append(" - 'E' - Register Events\n") .append(" - 'U' - Unregister Events\n") .append(" - 'A' - Adapters\n") .append(" - 'P' - Protocols\n") .append(" - 'B' - Batteries\n") .append(" - 'N' - DisplayAdapters\n") .append(" - 'Z' - PhysicalDisks\n") .append(" - 'X' - LogicalDisks\n") .append(" - 'M' - Memory\n") .append(" - 'R' - Processor\n") .append(" - 'C' - Context\n") .append(" - 'S' - ServerContext\n") .append(" - 'T' - Threshold Sub Menu\n") .append(" - 'F' - Platform Sub Menu\n") .append(" - 'H' - Help\n\n"); System.out.print( strBuf.toString() ); } /* private void printProcessor() throws IntelMobileException { ProcessorTest processor = new ProcessorTest(myProcessorClass); processor.printInfo(); } */ private void printBattery() throws IntelMobileException { BatteryTest battery = new BatteryTest(myBatteryClass); battery.printInfo(); } private void printPlatform() throws IntelMobileException { PlatformTest platform = new PlatformTest(myPlatformClass); platform.printInfo(); } private void printDisplayAdapter() throws IntelMobileException { DisplayAdapterTest displayAdapter = new DisplayAdapterTest(myDisplayAdapterClass); displayAdapter.printInfo(); } private void printPhysicalDisk() throws IntelMobileException { PhysicalDiskTest physicaldisk = new PhysicalDiskTest(myPhysicalDiskClass); physicaldisk.printInfo(); } private void printLogicalDisk() throws IntelMobileException { LogicalDiskTest logicaldisk = new LogicalDiskTest(myLogicalDiskClass); logicaldisk.printInfo(); } private void printMemory() throws IntelMobileException { MemoryTest memory = new MemoryTest(myMemoryClass); memory.printInfo(); } private void printLinkProtocol() throws IntelMobileException { LinkProtocolTest protocol = new LinkProtocolTest(myProtocolClass, my802_3Class, my802_11Class, myWwanClass, myGprsClass, myCdmaClass, myBluetoothPanClass); protocol.printInfo(); } private void printNetworkAdapter() throws IntelMobileException { NetworkAdapterTest adapter = new NetworkAdapterTest(myAdapterClass, myWiredClass, myRadioClass); adapter.printInfo(); } private void serverComtextCmd() throws IntelMobileException { ServerContext MyServerContext = new ServerContext(); System.out.println("Server Status : " + (MyServerContext.IsServerRunning() ? "Running" : "Stop")); System.out.println("Battery : " + (MyServerContext.IsAvailable(ProviderTypeEnum.Battery) ? "Running" : "Stop")); System.out.println("Processor : " + (MyServerContext.IsAvailable(ProviderTypeEnum.Processor) ? "Running" : "Stop")); System.out.println("NetworkAdapter : " + (MyServerContext.IsAvailable(ProviderTypeEnum.NetworkAdapter) ? "Running" : "Stop")); System.out.println("LinkProtocol : " + (MyServerContext.IsAvailable(ProviderTypeEnum.LinkProtocol) ? "Running" : "Stop")); //System.out.println("Test : " + (MyServerContext.IsAvailable("Test") ? "Running" : "Stop")); System.out.println("Server Version : " + MyServerContext.GetServerVersion()); } private void printContext() throws IntelMobileException { ContextTest Context = new ContextTest(myContextClass); System.out.print("------------Enter Context SubCommand ('H' for help)------------\n"); while (Context != null) { try { switch (System.in.read()) { case 'c': case 'C': Context.printConnectivityInfo(); break; case 's': case 'S':
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -