📄 consoletest.java
字号:
Context.printStorageInfo(); break; case 'p': case 'P': Context.printPowerInfo(); continue; case 'i': case 'I': Context.printDisplay(); continue; case 'b': case 'B': Context.printBandwidthInfo(); break; case 'q': case 'Q': Context = null; break; case 'h': case 'H': StringBuffer strBuf = new StringBuffer(); strBuf.append("\n") .append(" - 'Q' - Return to main menu\n") .append(" - 'C' - Connectivity\n") .append(" - 'S' - Storage\n") .append(" - 'P' - Power\n") .append(" - 'B' - Bandwidth\n") .append(" - 'I' - Display\n") .append(" - 'H' - Help\n\n"); System.out.print( strBuf.toString() ); break; default: continue; } } catch (IOException ex) { ex.printStackTrace(); } System.out.print("------------Enter Context SubCommand ('H' for help)------------\n"); } System.out.print("------------Leaving Context SubCommand------------\n"); } private void registerEvents() throws IntelMobileException { //===== Power events ===== PowerInstance myPowerInstance = (PowerInstance) myContextClass.GetInstance( "Power" ); if (myPowerInstance != null) { myPowerInstance.InternallyPowered.AddObserver( theObserver ); myPowerInstance.ExternallyPowered.AddObserver( theObserver ); myPowerInstance.FullyCharged.AddObserver( theObserver ); } //===== Power events ===== //===== Platform events ===== PlatformInstance myPlatformInstance = (PlatformInstance) myPlatformClass.GetInstance( "Platform" ); if (myPlatformInstance != null) { myPlatformInstance.ShutdownRequested.AddObserver( theObserver ); myPlatformInstance.SuspendRequested.AddObserver( theObserver ); myPlatformInstance.ShuttingDown.AddObserver( theObserver ); myPlatformInstance.Suspending.AddObserver( theObserver ); myPlatformInstance.ResumedCritically.AddObserver( theObserver ); myPlatformInstance.ResumedNormally.AddObserver( theObserver ); } //===== Platform events ===== //===== Connectivity events ===== ConnectivityInstance myConnectivityInstance = (ConnectivityInstance) myContextClass.GetInstance("Connectivity"); if (myConnectivityInstance != null) { myConnectivityInstance.Connected.AddObserver( theObserver ); myConnectivityInstance.Disconnected.AddObserver( theObserver ); myConnectivityInstance.IpAddressChanged.AddObserver( theObserver ); myConnectivityInstance.RouteTableChanged.AddObserver( theObserver ); } //===== Connectivity events ===== //===== Bandwidth events ===== BandwidthInstance myBandwidthInstance = (BandwidthInstance) myContextClass.GetInstance("Bandwidth"); if (myBandwidthInstance != null) { myBandwidthInstance.BandwidthChanged.AddObserver( theObserver ); } //===== Bandwidth events ===== //===== Network Adapter events ===== myAdapterClass.Added.AddObserver( theObserver ); myAdapterClass.Removed.AddObserver( theObserver ); myRadioClass.Added.AddObserver( theObserver ); myRadioClass.Removed.AddObserver( theObserver ); myWiredClass.Added.AddObserver( theObserver ); myWiredClass.Removed.AddObserver( theObserver ); //===== Network Adapter events ===== //===== Link Protocol events ===== LinkProtocolCollection myProtocolCollection = (LinkProtocolCollection)myProtocolClass.GetInstances(); myProtocolCollection.Reset(); LinkProtocolInstance myProtocolInstance = null; while ( myProtocolCollection.HasNext() ) { myProtocolInstance = (LinkProtocolInstance)myProtocolCollection.Next(); myProtocolInstance.MediaConnected.AddObserver( theObserver ); myProtocolInstance.MediaDisconnected.AddObserver( theObserver ); } //===== Link Protocol events ===== //===== Battery events ===== myBatteryClass.Added.AddObserver( theObserver ); myBatteryClass.Removed.AddObserver( theObserver ); myPhysicalDiskClass.Added.AddObserver( theObserver ); myPhysicalDiskClass.Removed.AddObserver( theObserver ); myLogicalDiskClass.Added.AddObserver( theObserver ); myLogicalDiskClass.Removed.AddObserver( theObserver ); BatteryCollection myBatteryCollection = (BatteryCollection)myBatteryClass.GetInstances(); myBatteryCollection.Reset(); BatteryInstance myBatteryInstance = null; while ( myBatteryCollection.HasNext() ) { myBatteryInstance = (BatteryInstance)myBatteryCollection.Next(); myBatteryInstance.StatusChanged.AddObserver( theObserver ); myBatteryInstance.FullyCharged.AddObserver( theObserver ); myBatteryInstance.GoingOffline.AddObserver( theObserver ); if (myBatteryInstance.PoweringSystem.IsAvailable()) { System.out.println("PoweringSystem is supported by Battery"); } myBatteryInstance.PoweringSystem.AddObserver( theObserver ); } //===== Battery events ===== } private void unregisterEvents() throws IntelMobileException { //===== Power events ===== PowerInstance myPowerInstance = (PowerInstance) myContextClass.GetInstance( "Power" ); if (myPowerInstance != null) { myPowerInstance.InternallyPowered.RemoveObserver( theObserver ); myPowerInstance.ExternallyPowered.RemoveObserver( theObserver ); myPowerInstance.FullyCharged.RemoveObserver( theObserver ); } //===== Power events ===== //===== Platform events ===== PlatformInstance myPlatformInstance = (PlatformInstance) myPlatformClass.GetInstance( "Platform" ); if (myPlatformInstance != null) { myPlatformInstance.ShutdownRequested.RemoveObserver( theObserver ); myPlatformInstance.SuspendRequested.RemoveObserver( theObserver ); myPlatformInstance.ShuttingDown.RemoveObserver( theObserver ); myPlatformInstance.Suspending.RemoveObserver( theObserver ); myPlatformInstance.ResumedCritically.RemoveObserver( theObserver ); myPlatformInstance.ResumedNormally.RemoveObserver( theObserver ); } //===== Platform events ===== //===== Connectivity events ===== ConnectivityInstance myConnectivityInstance = (ConnectivityInstance) myContextClass.GetInstance("Connectivity"); if (myConnectivityInstance != null) { myConnectivityInstance.Connected.RemoveObserver( theObserver ); myConnectivityInstance.Disconnected.RemoveObserver( theObserver ); myConnectivityInstance.IpAddressChanged.RemoveObserver( theObserver ); myConnectivityInstance.RouteTableChanged.RemoveObserver( theObserver ); } //===== Connectivity events ===== //===== Bandwidth events ===== BandwidthInstance myBandwidthInstance = (BandwidthInstance) myContextClass.GetInstance("Bandwidth"); if (myBandwidthInstance != null) { myBandwidthInstance.BandwidthChanged.RemoveObserver( theObserver ); } //===== Bandwidth events ===== //===== Network Adapter events ===== myAdapterClass.Added.RemoveObserver( theObserver ); myAdapterClass.Removed.RemoveObserver( theObserver ); myRadioClass.Added.RemoveObserver( theObserver ); myRadioClass.Removed.RemoveObserver( theObserver ); myWiredClass.Added.RemoveObserver( theObserver ); myWiredClass.Removed.RemoveObserver( theObserver ); //===== Network Adapter events ===== //===== Link Protocol events ===== LinkProtocolCollection myProtocolCollection = (LinkProtocolCollection)myProtocolClass.GetInstances(); myProtocolCollection.Reset(); LinkProtocolInstance myProtocolInstance = null; while ( myProtocolCollection.HasNext() ) { myProtocolInstance = (LinkProtocolInstance)myProtocolCollection.Next(); myProtocolInstance.MediaConnected.RemoveObserver( theObserver ); myProtocolInstance.MediaDisconnected.RemoveObserver( theObserver ); } //===== Link Protocol events ===== //===== Battery events ===== myBatteryClass.Added.RemoveObserver( theObserver ); myBatteryClass.Removed.RemoveObserver( theObserver ); myPhysicalDiskClass.Added.RemoveObserver( theObserver ); myPhysicalDiskClass.Removed.RemoveObserver( theObserver ); myLogicalDiskClass.Added.RemoveObserver( theObserver ); myLogicalDiskClass.Removed.RemoveObserver( theObserver ); BatteryCollection myBatteryCollection = (BatteryCollection)myBatteryClass.GetInstances(); myBatteryCollection.Reset(); BatteryInstance myBatteryInstance = null; while ( myBatteryCollection.HasNext() ) { myBatteryInstance = (BatteryInstance)myBatteryCollection.Next(); myBatteryInstance.StatusChanged.RemoveObserver( theObserver ); myBatteryInstance.FullyCharged.RemoveObserver( theObserver ); myBatteryInstance.GoingOffline.RemoveObserver( theObserver ); myBatteryInstance.PoweringSystem.RemoveObserver( theObserver ); } //===== Battery events ===== } private void platformCmd() throws IntelMobileException { try { PlatformCollection myCollection = (PlatformCollection)myPlatformClass.GetInstances(); myCollection.Reset(); PlatformInstance myInstance = null; System.out.println("-----Enter Platform SubCommand (\'H\' for help)-----\n"); while (myCollection.HasNext()) { myInstance = (PlatformInstance)myCollection.Next(); while (myInstance != null) { switch (System.in.read()) { case 'q': case 'Q': myInstance = null; break; case 'h': case 'H': System.out.println(); System.out.println(" - \'Q\' - Return to main menu"); System.out.println(" - \'S\' - Shutdown the System"); //System.out.println(" - \'R\' - Restart the System"); //System.out.println(" - \'L\' - Logoff the System"); System.out.println(" - \'U\' - Suspend the System"); System.out.println(" - \'B\' - Hibernate the System"); System.out.println(" - \'H\' - Help"); System.out.println(); System.out.println(); break; case 's': case 'S': myInstance.RequestShutdown(); break; /*case 'r': case 'R': mySSCInstance.RequestRestart(); break; case 'l': case 'L': mySSCInstance.RequestLogoff(); break;*/ case 'u': case 'U': myInstance.RequestSuspend(); break; case 'b': case 'B': myInstance.RequestHibernate(); break; default: } } }//while }//try catch (IOException ex) { ex.printStackTrace(); } } private void thresholdCmd() throws IntelMobileException { // Get a Battery instance. /* BatteryCollection myCollection = (BatteryCollection)myBatteryClass.GetInstances(); myCollection.Reset(); BatteryInstance myInstance = null; if ( myCollection.HasNext() ) { myInstance = (BatteryInstance)myCollection.Next(); } else { return; } BatteryThresholdTest thresholdTest = new BatteryThresholdTest(myInstance, theObserver); */ // Get a Processor instance. ProcessorCollection myCollection = (ProcessorCollection)myProcessorClass.GetInstances(); myCollection.Reset(); ProcessorInstance myInstance = null; if ( myCollection.HasNext() ) { myInstance = (ProcessorInstance)myCollection.Next(); } else { return; } ProcessorThresholdTest thresholdTest = new ProcessorThresholdTest(myInstance, theObserver); try { System.out.print("------------Enter Threshold SubCommand ('H' for help)------------\n"); boolean bExit = false; while ( !bExit ) { switch (System.in.read()) { case 'q': case 'Q': thresholdTest.removeThresholds(); bExit = true; break; case 'a': case 'A': thresholdTest.addThresholds(); break; case 'r': case 'R': thresholdTest.removeThresholds(); break; case 'o': case 'O': thresholdTest.changeOffset(); break; case 'h': case 'H': printThresholdHelp(); break; default: continue; } System.out.print("------------Enter Threshold SubCommand ('H' for help)------------\n"); } System.out.print("------------Leaving Threshold SubCommand------------\n"); } catch (Exception ex) { ex.printStackTrace(); } } private void printThresholdHelp() { StringBuffer strBuf = new StringBuffer(); strBuf.append("\n") .append(" - 'Q' - Return to main menu\n") .append(" - 'A' - Add Thresholds\n") .append(" - 'R' - Remove Thresholds\n") .append(" - 'O' - Change Offset\n") .append(" - 'H' - Help\n\n"); System.out.print( strBuf.toString() ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -