com.serialpundit.serial.vendor.FTOpenedDeviceInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sp-tty Show documentation
Show all versions of sp-tty Show documentation
Serial port APIs of SerialPundit
The newest version!
/*
* This file is part of SerialPundit.
*
* Copyright (C) 2014-2016, Rishi Gupta. All rights reserved.
*
* The SerialPundit is DUAL LICENSED. It is made available under the terms of the GNU Affero
* General Public License (AGPL) v3.0 for non-commercial use and under the terms of a commercial
* license for commercial use of this software.
*
* The SerialPundit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
package com.serialpundit.serial.vendor;
import com.serialpundit.core.util.SerialComUtil;
/**
* Represents an opened FT device with information about it.
*
* @author Rishi Gupta
*/
public final class FTOpenedDeviceInfo {
private String type = null;
private String id = null;
private String serialNumber = null;
private String description = null;
/**
* Construct and allocates a new FTOpenedDeviceInfo object with given details.
*
* @param type device type.
* @param id device ID.
* @param serialNumber serial number of this device.
* @param description description of this device.
*/
public FTOpenedDeviceInfo(String type, String id, String serialNumber, String description) {
this.type = type;
this.id = id;
this.serialNumber = serialNumber;
this.description = description;
}
/**
* Retrieves the type for this opened FT device.
*
* @return type for this FT device info node.
* @throws NumberFormatException if the type hex string can not be converted into numerical representation.
*/
public long getType() {
return SerialComUtil.hexStrToLongNumber(type);
}
/**
* Retrieves the id for this opened FT device.
*
* @return id for this FT device info node.
* @throws NumberFormatException if the id hex string can not be converted into numerical representation.
*/
public long getId() {
return SerialComUtil.hexStrToLongNumber(id);
}
/**
* Retrieves the serial number string for this opened FT device.
*
* @return serial number string for this FT device info node.
*/
public String getSerialNumber() {
return serialNumber;
}
/**
* Retrieves the description for this opened FT device.
*
* @return description string for this FT device info node.
*/
public String getDescription() {
return description;
}
/**
* Prints information about this opened FT device on console.
*/
public void dumpDeviceInfo() {
System.out.println("\nType : " + type +
"\nID : 0x" + id +
"\nSerialNumber : " + serialNumber +
"\nDescription : " + description);
}
}