DdDeviceParameter.fromXML constructor

DdDeviceParameter.fromXML(
  1. String xmlSTR
)

Implementation

factory DdDeviceParameter.fromXML(String xmlSTR) {
  final document = XmlDocument.parse(xmlSTR);

  XmlElement? vendorModelInfoElement =
      document.firstChild!.getElement("vendorModelInfo");
  XmlElement? ipAndPortElement = document.firstChild!.getElement("ipAndPort");
  XmlElement? statusElement = document.firstChild!.getElement("ddStatus");

  VendorModelInfo vendorModelInfo =
      VendorModelInfo.fromXML(vendorModelInfoElement!.toXmlString());
  IpAndPort ipAndPort = IpAndPort.fromXML(ipAndPortElement!.toXmlString());
  DdStatus status = DdStatus.fromXML(statusElement!.toXmlString());

  String numCharsPerLine = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "numCharsPerLine")
      .value;
  String numLines = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "numLines")
      .value;
  String supportsAnimation = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "supportsAnimation")
      .value;
  String pixelsTall = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "pixelsTall")
      .value;
  String pixelsWide = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "pixelsWide")
      .value;
  return DdDeviceParameter(
    vendorModelInfo: vendorModelInfo,
    ipAndPort: ipAndPort,
    status: status,
    numCharsPerLine: numCharsPerLine,
    numLines: numLines,
    supportsAnimation: supportsAnimation,
    pixelsTall: pixelsTall,
    pixelsWide: pixelsWide,
  );
}