001package Torello.Browser; 002 003import java.util.*; 004import javax.json.*; 005import javax.json.stream.*; 006import java.io.*; 007 008import java.lang.reflect.Method; 009import java.lang.reflect.Parameter; 010import java.util.function.Function; 011 012import Torello.Java.Additional.*; 013 014import static Torello.Java.Additional.JFlag.*; 015 016import Torello.Java.StrCmpr; 017import Torello.JavaDoc.StaticFunctional; 018import Torello.JavaDoc.JDHeaderBackgroundImg; 019import Torello.JavaDoc.Excuse; 020 021/** 022 * <SPAN CLASS=CopiedJDK><B>The SystemInfo domain defines methods and events for querying low-level system information.</B></SPAN> 023 * 024 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 025 */ 026@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 027@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 028public class SystemInfo 029{ 030 // ******************************************************************************************** 031 // ******************************************************************************************** 032 // Class Header Stuff 033 // ******************************************************************************************** 034 // ******************************************************************************************** 035 036 037 // No Pubic Constructors 038 private SystemInfo () { } 039 040 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 041 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 042 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 043 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 044 045 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 046 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 047 // offically, two empty-vectors. One for String's, and the other for Classes. 048 049 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 050 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 051 052 static 053 { 054 for (Method m : SystemInfo.class.getMethods()) 055 { 056 // This doesn't work! The parameter names are all "arg0" ... "argN" 057 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 058 // 059 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 060 061 Vector<Class<?>> parameterTypesList = new Vector<>(); 062 063 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 064 065 parameterTypes.put( 066 m.getName(), 067 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 068 ); 069 } 070 } 071 072 static 073 { 074 Vector<String> v = null; 075 076 parameterNames.put("getInfo", EMPTY_VEC_STR); 077 078 parameterNames.put("getProcessInfo", EMPTY_VEC_STR); 079 } 080 081 082 // ******************************************************************************************** 083 // ******************************************************************************************** 084 // Types - Static Inner Classes 085 // ******************************************************************************************** 086 // ******************************************************************************************** 087 088 /** YUV subsampling type of the pixels of a given image. */ 089 public static final String[] SubsamplingFormat = 090 { "yuv420", "yuv422", "yuv444", }; 091 092 /** Image format of a given image. */ 093 public static final String[] ImageType = 094 { "jpeg", "webp", "unknown", }; 095 096 /** Describes a single graphics processor (GPU). */ 097 public static class GPUDevice extends BaseType 098 { 099 /** For Object Serialization. java.io.Serializable */ 100 protected static final long serialVersionUID = 1; 101 102 public boolean[] optionals() 103 { return new boolean[] { false, false, true, true, false, false, false, false, }; } 104 105 /** PCI ID of the GPU vendor, if available; 0 otherwise. */ 106 public final Number vendorId; 107 108 /** PCI ID of the GPU device, if available; 0 otherwise. */ 109 public final Number deviceId; 110 111 /** 112 * Sub sys ID of the GPU, only available on Windows. 113 * <BR /> 114 * <BR /><B>OPTIONAL</B> 115 */ 116 public final Number subSysId; 117 118 /** 119 * Revision of the GPU, only available on Windows. 120 * <BR /> 121 * <BR /><B>OPTIONAL</B> 122 */ 123 public final Number revision; 124 125 /** String description of the GPU vendor, if the PCI ID is not available. */ 126 public final String vendorString; 127 128 /** String description of the GPU device, if the PCI ID is not available. */ 129 public final String deviceString; 130 131 /** String description of the GPU driver vendor. */ 132 public final String driverVendor; 133 134 /** String description of the GPU driver version. */ 135 public final String driverVersion; 136 137 /** 138 * Constructor 139 * 140 * @param vendorId PCI ID of the GPU vendor, if available; 0 otherwise. 141 * 142 * @param deviceId PCI ID of the GPU device, if available; 0 otherwise. 143 * 144 * @param subSysId Sub sys ID of the GPU, only available on Windows. 145 * <BR /><B>OPTIONAL</B> 146 * 147 * @param revision Revision of the GPU, only available on Windows. 148 * <BR /><B>OPTIONAL</B> 149 * 150 * @param vendorString String description of the GPU vendor, if the PCI ID is not available. 151 * 152 * @param deviceString String description of the GPU device, if the PCI ID is not available. 153 * 154 * @param driverVendor String description of the GPU driver vendor. 155 * 156 * @param driverVersion String description of the GPU driver version. 157 */ 158 public GPUDevice( 159 Number vendorId, Number deviceId, Number subSysId, Number revision, 160 String vendorString, String deviceString, String driverVendor, String driverVersion 161 ) 162 { 163 // Exception-Check(s) to ensure that if any parameters which are not declared as 164 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 165 166 if (vendorId == null) BRDPC.throwNPE("vendorId"); 167 if (deviceId == null) BRDPC.throwNPE("deviceId"); 168 if (vendorString == null) BRDPC.throwNPE("vendorString"); 169 if (deviceString == null) BRDPC.throwNPE("deviceString"); 170 if (driverVendor == null) BRDPC.throwNPE("driverVendor"); 171 if (driverVersion == null) BRDPC.throwNPE("driverVersion"); 172 173 this.vendorId = vendorId; 174 this.deviceId = deviceId; 175 this.subSysId = subSysId; 176 this.revision = revision; 177 this.vendorString = vendorString; 178 this.deviceString = deviceString; 179 this.driverVendor = driverVendor; 180 this.driverVersion = driverVersion; 181 } 182 183 /** 184 * JSON Object Constructor 185 * @param jo A Json-Object having data about an instance of {@code 'GPUDevice'}. 186 */ 187 public GPUDevice (JsonObject jo) 188 { 189 this.vendorId = ReadJSON.getNUMBER(jo, "vendorId", false, true); 190 this.deviceId = ReadJSON.getNUMBER(jo, "deviceId", false, true); 191 this.subSysId = ReadJSON.getNUMBER(jo, "subSysId", true, false); 192 this.revision = ReadJSON.getNUMBER(jo, "revision", true, false); 193 this.vendorString = ReadJSON.getString(jo, "vendorString", false, true); 194 this.deviceString = ReadJSON.getString(jo, "deviceString", false, true); 195 this.driverVendor = ReadJSON.getString(jo, "driverVendor", false, true); 196 this.driverVersion = ReadJSON.getString(jo, "driverVersion", false, true); 197 } 198 199 } 200 201 /** Describes the width and height dimensions of an entity. */ 202 public static class Size extends BaseType 203 { 204 /** For Object Serialization. java.io.Serializable */ 205 protected static final long serialVersionUID = 1; 206 207 public boolean[] optionals() 208 { return new boolean[] { false, false, }; } 209 210 /** Width in pixels. */ 211 public final int width; 212 213 /** Height in pixels. */ 214 public final int height; 215 216 /** 217 * Constructor 218 * 219 * @param width Width in pixels. 220 * 221 * @param height Height in pixels. 222 */ 223 public Size(int width, int height) 224 { 225 this.width = width; 226 this.height = height; 227 } 228 229 /** 230 * JSON Object Constructor 231 * @param jo A Json-Object having data about an instance of {@code 'Size'}. 232 */ 233 public Size (JsonObject jo) 234 { 235 this.width = ReadJSON.getInt(jo, "width"); 236 this.height = ReadJSON.getInt(jo, "height"); 237 } 238 239 } 240 241 /** 242 * Describes a supported video decoding profile with its associated minimum and 243 * maximum resolutions. 244 */ 245 public static class VideoDecodeAcceleratorCapability extends BaseType 246 { 247 /** For Object Serialization. java.io.Serializable */ 248 protected static final long serialVersionUID = 1; 249 250 public boolean[] optionals() 251 { return new boolean[] { false, false, false, }; } 252 253 /** Video codec profile that is supported, e.g. VP9 Profile 2. */ 254 public final String profile; 255 256 /** Maximum video dimensions in pixels supported for this |profile|. */ 257 public final SystemInfo.Size maxResolution; 258 259 /** Minimum video dimensions in pixels supported for this |profile|. */ 260 public final SystemInfo.Size minResolution; 261 262 /** 263 * Constructor 264 * 265 * @param profile Video codec profile that is supported, e.g. VP9 Profile 2. 266 * 267 * @param maxResolution Maximum video dimensions in pixels supported for this |profile|. 268 * 269 * @param minResolution Minimum video dimensions in pixels supported for this |profile|. 270 */ 271 public VideoDecodeAcceleratorCapability 272 (String profile, SystemInfo.Size maxResolution, SystemInfo.Size minResolution) 273 { 274 // Exception-Check(s) to ensure that if any parameters which are not declared as 275 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 276 277 if (profile == null) BRDPC.throwNPE("profile"); 278 if (maxResolution == null) BRDPC.throwNPE("maxResolution"); 279 if (minResolution == null) BRDPC.throwNPE("minResolution"); 280 281 this.profile = profile; 282 this.maxResolution = maxResolution; 283 this.minResolution = minResolution; 284 } 285 286 /** 287 * JSON Object Constructor 288 * @param jo A Json-Object having data about an instance of {@code 'VideoDecodeAcceleratorCapability'}. 289 */ 290 public VideoDecodeAcceleratorCapability (JsonObject jo) 291 { 292 this.profile = ReadJSON.getString(jo, "profile", false, true); 293 this.maxResolution = ReadJSON.XL.getObject(jo, "maxResolution", SystemInfo.Size.class, false, true); 294 this.minResolution = ReadJSON.XL.getObject(jo, "minResolution", SystemInfo.Size.class, false, true); 295 } 296 297 } 298 299 /** 300 * Describes a supported video encoding profile with its associated maximum 301 * resolution and maximum framerate. 302 */ 303 public static class VideoEncodeAcceleratorCapability extends BaseType 304 { 305 /** For Object Serialization. java.io.Serializable */ 306 protected static final long serialVersionUID = 1; 307 308 public boolean[] optionals() 309 { return new boolean[] { false, false, false, false, }; } 310 311 /** Video codec profile that is supported, e.g H264 Main. */ 312 public final String profile; 313 314 /** Maximum video dimensions in pixels supported for this |profile|. */ 315 public final SystemInfo.Size maxResolution; 316 317 /** 318 * Maximum encoding framerate in frames per second supported for this 319 * |profile|, as fraction's numerator and denominator, e.g. 24/1 fps, 320 * 24000/1001 fps, etc. 321 */ 322 public final int maxFramerateNumerator; 323 324 /** <CODE>[No Description Provided by Google]</CODE> */ 325 public final int maxFramerateDenominator; 326 327 /** 328 * Constructor 329 * 330 * @param profile Video codec profile that is supported, e.g H264 Main. 331 * 332 * @param maxResolution Maximum video dimensions in pixels supported for this |profile|. 333 * 334 * @param maxFramerateNumerator 335 * Maximum encoding framerate in frames per second supported for this 336 * |profile|, as fraction's numerator and denominator, e.g. 24/1 fps, 337 * 24000/1001 fps, etc. 338 * 339 * @param maxFramerateDenominator - 340 */ 341 public VideoEncodeAcceleratorCapability( 342 String profile, SystemInfo.Size maxResolution, int maxFramerateNumerator, 343 int maxFramerateDenominator 344 ) 345 { 346 // Exception-Check(s) to ensure that if any parameters which are not declared as 347 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 348 349 if (profile == null) BRDPC.throwNPE("profile"); 350 if (maxResolution == null) BRDPC.throwNPE("maxResolution"); 351 352 this.profile = profile; 353 this.maxResolution = maxResolution; 354 this.maxFramerateNumerator = maxFramerateNumerator; 355 this.maxFramerateDenominator = maxFramerateDenominator; 356 } 357 358 /** 359 * JSON Object Constructor 360 * @param jo A Json-Object having data about an instance of {@code 'VideoEncodeAcceleratorCapability'}. 361 */ 362 public VideoEncodeAcceleratorCapability (JsonObject jo) 363 { 364 this.profile = ReadJSON.getString(jo, "profile", false, true); 365 this.maxResolution = ReadJSON.XL.getObject(jo, "maxResolution", SystemInfo.Size.class, false, true); 366 this.maxFramerateNumerator = ReadJSON.getInt(jo, "maxFramerateNumerator"); 367 this.maxFramerateDenominator = ReadJSON.getInt(jo, "maxFramerateDenominator"); 368 } 369 370 } 371 372 /** 373 * Describes a supported image decoding profile with its associated minimum and 374 * maximum resolutions and subsampling. 375 */ 376 public static class ImageDecodeAcceleratorCapability extends BaseType 377 { 378 /** For Object Serialization. java.io.Serializable */ 379 protected static final long serialVersionUID = 1; 380 381 public boolean[] optionals() 382 { return new boolean[] { false, false, false, false, }; } 383 384 /** Image coded, e.g. Jpeg. */ 385 public final String imageType; 386 387 /** Maximum supported dimensions of the image in pixels. */ 388 public final SystemInfo.Size maxDimensions; 389 390 /** Minimum supported dimensions of the image in pixels. */ 391 public final SystemInfo.Size minDimensions; 392 393 /** Optional array of supported subsampling formats, e.g. 4:2:0, if known. */ 394 public final String[] subsamplings; 395 396 /** 397 * Constructor 398 * 399 * @param imageType Image coded, e.g. Jpeg. 400 * 401 * @param maxDimensions Maximum supported dimensions of the image in pixels. 402 * 403 * @param minDimensions Minimum supported dimensions of the image in pixels. 404 * 405 * @param subsamplings Optional array of supported subsampling formats, e.g. 4:2:0, if known. 406 */ 407 public ImageDecodeAcceleratorCapability( 408 String imageType, SystemInfo.Size maxDimensions, SystemInfo.Size minDimensions, 409 String[] subsamplings 410 ) 411 { 412 // Exception-Check(s) to ensure that if any parameters which are not declared as 413 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 414 415 if (imageType == null) BRDPC.throwNPE("imageType"); 416 if (maxDimensions == null) BRDPC.throwNPE("maxDimensions"); 417 if (minDimensions == null) BRDPC.throwNPE("minDimensions"); 418 if (subsamplings == null) BRDPC.throwNPE("subsamplings"); 419 420 // Exception-Check(s) to ensure that if any parameters which must adhere to a 421 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 422 423 BRDPC.checkIAE("imageType", imageType, "SystemInfo.ImageType", SystemInfo.ImageType); 424 425 this.imageType = imageType; 426 this.maxDimensions = maxDimensions; 427 this.minDimensions = minDimensions; 428 this.subsamplings = subsamplings; 429 } 430 431 /** 432 * JSON Object Constructor 433 * @param jo A Json-Object having data about an instance of {@code 'ImageDecodeAcceleratorCapability'}. 434 */ 435 public ImageDecodeAcceleratorCapability (JsonObject jo) 436 { 437 this.imageType = ReadJSON.getString(jo, "imageType", false, true); 438 this.maxDimensions = ReadJSON.XL.getObject(jo, "maxDimensions", SystemInfo.Size.class, false, true); 439 this.minDimensions = ReadJSON.XL.getObject(jo, "minDimensions", SystemInfo.Size.class, false, true); 440 this.subsamplings = (jo.getJsonArray("subsamplings") == null) 441 ? null 442 : ReadArrJSON.DimN.strArr(jo.getJsonArray("subsamplings"), null, 0, String[].class); 443 } 444 445 } 446 447 /** Provides information about the GPU(s) on the system. */ 448 public static class GPUInfo extends BaseType 449 { 450 /** For Object Serialization. java.io.Serializable */ 451 protected static final long serialVersionUID = 1; 452 453 public boolean[] optionals() 454 { return new boolean[] { false, true, true, false, false, false, false, }; } 455 456 /** The graphics devices on the system. Element 0 is the primary GPU. */ 457 public final SystemInfo.GPUDevice[] devices; 458 459 /** 460 * An optional dictionary of additional GPU related attributes. 461 * <BR /> 462 * <BR /><B>OPTIONAL</B> 463 */ 464 public final JsonObject auxAttributes; 465 466 /** 467 * An optional dictionary of graphics features and their status. 468 * <BR /> 469 * <BR /><B>OPTIONAL</B> 470 */ 471 public final JsonObject featureStatus; 472 473 /** An optional array of GPU driver bug workarounds. */ 474 public final String[] driverBugWorkarounds; 475 476 /** Supported accelerated video decoding capabilities. */ 477 public final SystemInfo.VideoDecodeAcceleratorCapability[] videoDecoding; 478 479 /** Supported accelerated video encoding capabilities. */ 480 public final SystemInfo.VideoEncodeAcceleratorCapability[] videoEncoding; 481 482 /** Supported accelerated image decoding capabilities. */ 483 public final SystemInfo.ImageDecodeAcceleratorCapability[] imageDecoding; 484 485 /** 486 * Constructor 487 * 488 * @param devices The graphics devices on the system. Element 0 is the primary GPU. 489 * 490 * @param auxAttributes An optional dictionary of additional GPU related attributes. 491 * <BR /><B>OPTIONAL</B> 492 * 493 * @param featureStatus An optional dictionary of graphics features and their status. 494 * <BR /><B>OPTIONAL</B> 495 * 496 * @param driverBugWorkarounds An optional array of GPU driver bug workarounds. 497 * 498 * @param videoDecoding Supported accelerated video decoding capabilities. 499 * 500 * @param videoEncoding Supported accelerated video encoding capabilities. 501 * 502 * @param imageDecoding Supported accelerated image decoding capabilities. 503 */ 504 public GPUInfo( 505 SystemInfo.GPUDevice[] devices, JsonObject auxAttributes, JsonObject featureStatus, 506 String[] driverBugWorkarounds, 507 SystemInfo.VideoDecodeAcceleratorCapability[] videoDecoding, 508 SystemInfo.VideoEncodeAcceleratorCapability[] videoEncoding, 509 SystemInfo.ImageDecodeAcceleratorCapability[] imageDecoding 510 ) 511 { 512 // Exception-Check(s) to ensure that if any parameters which are not declared as 513 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 514 515 if (devices == null) BRDPC.throwNPE("devices"); 516 if (driverBugWorkarounds == null) BRDPC.throwNPE("driverBugWorkarounds"); 517 if (videoDecoding == null) BRDPC.throwNPE("videoDecoding"); 518 if (videoEncoding == null) BRDPC.throwNPE("videoEncoding"); 519 if (imageDecoding == null) BRDPC.throwNPE("imageDecoding"); 520 521 this.devices = devices; 522 this.auxAttributes = auxAttributes; 523 this.featureStatus = featureStatus; 524 this.driverBugWorkarounds = driverBugWorkarounds; 525 this.videoDecoding = videoDecoding; 526 this.videoEncoding = videoEncoding; 527 this.imageDecoding = imageDecoding; 528 } 529 530 /** 531 * JSON Object Constructor 532 * @param jo A Json-Object having data about an instance of {@code 'GPUInfo'}. 533 */ 534 public GPUInfo (JsonObject jo) 535 { 536 this.devices = (jo.getJsonArray("devices") == null) 537 ? null 538 : ReadArrJSON.DimN.objArr(jo.getJsonArray("devices"), null, 0, SystemInfo.GPUDevice[].class); 539 this.auxAttributes = jo.getJsonObject("auxAttributes"); 540 this.featureStatus = jo.getJsonObject("featureStatus"); 541 this.driverBugWorkarounds = (jo.getJsonArray("driverBugWorkarounds") == null) 542 ? null 543 : ReadArrJSON.DimN.strArr(jo.getJsonArray("driverBugWorkarounds"), null, 0, String[].class); 544 this.videoDecoding = (jo.getJsonArray("videoDecoding") == null) 545 ? null 546 : ReadArrJSON.DimN.objArr(jo.getJsonArray("videoDecoding"), null, 0, SystemInfo.VideoDecodeAcceleratorCapability[].class); 547 this.videoEncoding = (jo.getJsonArray("videoEncoding") == null) 548 ? null 549 : ReadArrJSON.DimN.objArr(jo.getJsonArray("videoEncoding"), null, 0, SystemInfo.VideoEncodeAcceleratorCapability[].class); 550 this.imageDecoding = (jo.getJsonArray("imageDecoding") == null) 551 ? null 552 : ReadArrJSON.DimN.objArr(jo.getJsonArray("imageDecoding"), null, 0, SystemInfo.ImageDecodeAcceleratorCapability[].class); 553 } 554 555 } 556 557 /** Represents process info. */ 558 public static class ProcessInfo extends BaseType 559 { 560 /** For Object Serialization. java.io.Serializable */ 561 protected static final long serialVersionUID = 1; 562 563 public boolean[] optionals() 564 { return new boolean[] { false, false, false, }; } 565 566 /** Specifies process type. */ 567 public final String type; 568 569 /** Specifies process id. */ 570 public final int id; 571 572 /** 573 * Specifies cumulative CPU usage in seconds across all threads of the 574 * process since the process start. 575 */ 576 public final Number cpuTime; 577 578 /** 579 * Constructor 580 * 581 * @param type Specifies process type. 582 * 583 * @param id Specifies process id. 584 * 585 * @param cpuTime 586 * Specifies cumulative CPU usage in seconds across all threads of the 587 * process since the process start. 588 */ 589 public ProcessInfo(String type, int id, Number cpuTime) 590 { 591 // Exception-Check(s) to ensure that if any parameters which are not declared as 592 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 593 594 if (type == null) BRDPC.throwNPE("type"); 595 if (cpuTime == null) BRDPC.throwNPE("cpuTime"); 596 597 this.type = type; 598 this.id = id; 599 this.cpuTime = cpuTime; 600 } 601 602 /** 603 * JSON Object Constructor 604 * @param jo A Json-Object having data about an instance of {@code 'ProcessInfo'}. 605 */ 606 public ProcessInfo (JsonObject jo) 607 { 608 this.type = ReadJSON.getString(jo, "type", false, true); 609 this.id = ReadJSON.getInt(jo, "id"); 610 this.cpuTime = ReadJSON.getNUMBER(jo, "cpuTime", false, true); 611 } 612 613 } 614 615 616 // Counter for keeping the WebSocket Request ID's distinct. 617 private static int counter = 1; 618 619 /** 620 * Returns information about the system. 621 * 622 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 623 * {@link Ret4}></CODE> 624 * 625 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 626 * {@link Script#exec()}), and a {@link Promise} returned. 627 * 628 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 629 * (using {@link Promise#await()}), the {@code Ret4} will subsequently 630 * be returned from that call. 631 * 632 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 633 * in an instance of <B>{@link Ret4}</B> 634 * 635 * <BR /><BR /><UL CLASS=JDUL> 636 * <LI><CODE><B>Ret4.a:</B> {@link SystemInfo.GPUInfo} (<B>gpu</B>)</CODE> 637 * <BR />Information about the GPUs on the system. 638 * <BR /><BR /></LI> 639 * <LI><CODE><B>Ret4.b:</B> String (<B>modelName</B>)</CODE> 640 * <BR />A platform-dependent description of the model of the machine. On Mac OS, this is, for 641 * example, 'MacBookPro'. Will be the empty string if not supported. 642 * <BR /><BR /></LI> 643 * <LI><CODE><B>Ret4.c:</B> String (<B>modelVersion</B>)</CODE> 644 * <BR />A platform-dependent description of the version of the machine. On Mac OS, this is, for 645 * example, '10.1'. Will be the empty string if not supported. 646 * <BR /><BR /></LI> 647 * <LI><CODE><B>Ret4.d:</B> String (<B>commandLine</B>)</CODE> 648 * <BR />The command line string used to launch the browser. Will be the empty string if not 649 * supported. 650 * </LI> 651 * </UL> 652 */ 653 public static Script<String, JsonObject, Ret4<SystemInfo.GPUInfo, String, String, String>> getInfo() 654 { 655 final int webSocketID = 38000000 + counter++; 656 final boolean[] optionals = new boolean[0]; 657 658 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 659 String requestJSON = WriteJSON.get( 660 parameterTypes.get("getInfo"), 661 parameterNames.get("getInfo"), 662 optionals, webSocketID, 663 "SystemInfo.getInfo" 664 ); 665 666 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret4' 667 Function<JsonObject, Ret4<SystemInfo.GPUInfo, String, String, String>> 668 responseProcessor = (JsonObject jo) -> new Ret4<>( 669 ReadJSON.XL.getObject(jo, "gpu", SystemInfo.GPUInfo.class, false, true), 670 ReadJSON.getString(jo, "modelName", false, true), 671 ReadJSON.getString(jo, "modelVersion", false, true), 672 ReadJSON.getString(jo, "commandLine", false, true) 673 ); 674 675 // Pass the 'defaultSender' to Script-Constructor 676 // The sender that is used can be changed before executing script. 677 return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor); 678 } 679 680 /** 681 * Returns information about all running processes. 682 * 683 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 684 * {@link SystemInfo.ProcessInfo}[]></CODE> 685 * 686 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 687 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 688 * {@link SystemInfo.ProcessInfo}[]></CODE> will be returned. 689 * 690 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 691 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 692 * may be retrieved.</I> 693 * 694 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 695 * <BR /><BR /><UL CLASS=JDUL> 696 * <LI><CODE>{@link SystemInfo.ProcessInfo}[] (<B>processInfo</B></CODE>) 697 * <BR />An array of process info blocks. 698 * </LI> 699 * </UL> */ 700 public static Script<String, JsonObject, SystemInfo.ProcessInfo[]> getProcessInfo() 701 { 702 final int webSocketID = 38001000 + counter++; 703 final boolean[] optionals = new boolean[0]; 704 705 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 706 String requestJSON = WriteJSON.get( 707 parameterTypes.get("getProcessInfo"), 708 parameterNames.get("getProcessInfo"), 709 optionals, webSocketID, 710 "SystemInfo.getProcessInfo" 711 ); 712 713 // 'JSON Binding' ... Converts Browser Response-JSON to 'SystemInfo.ProcessInfo[]' 714 Function<JsonObject, SystemInfo.ProcessInfo[]> responseProcessor = (JsonObject jo) -> 715 (jo.getJsonArray("processInfo") == null) 716 ? null 717 : ReadArrJSON.DimN.objArr(jo.getJsonArray("processInfo"), null, 0, SystemInfo.ProcessInfo[].class); 718 719 // Pass the 'defaultSender' to Script-Constructor 720 // The sender that is used can be changed before executing script. 721 return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor); 722 } 723 724}