コード例 #1
0
 public FPGAIOInformationContainer(Node DocumentInfo) {
   /*
    * This constructor is used to create an element during the reading of a
    * board information xml file
    */
   MyType = IOComponentTypes.Unknown;
   MyIdentifier = -1;
   MyRectangle = null;
   MyPinLocations = new HashMap<Integer, String>();
   NrOfPins = 0;
   MyPullBehavior = PullBehaviors.Unknown;
   MyActivityLevel = PinActivity.Unknown;
   MyIOStandard = IoStandards.Unknown;
   MyDriveStrength = DriveStrength.Unknown;
   IOComponentTypes SetId = IOComponentTypes.getEnumFromString(DocumentInfo.getNodeName());
   if (IOComponentTypes.KnownComponentSet.contains(SetId)) {
     MyType = SetId;
   } else {
     return;
   }
   NamedNodeMap Attrs = DocumentInfo.getAttributes();
   int x = -1, y = -1, width = -1, height = -1;
   for (int i = 0; i < Attrs.getLength(); i++) {
     Node ThisAttr = Attrs.item(i);
     if (ThisAttr.getNodeName().equals(BoardWriterClass.LocationXString)) {
       x = Integer.parseInt(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(BoardWriterClass.LocationYString)) {
       y = Integer.parseInt(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(BoardWriterClass.WidthString)) {
       width = Integer.parseInt(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(BoardWriterClass.HeightString)) {
       height = Integer.parseInt(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(BoardWriterClass.PinLocationString)) {
       NrOfPins = 1;
       MyPinLocations.put(0, ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(BoardWriterClass.MultiPinInformationString)) {
       NrOfPins = Integer.parseInt(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().startsWith(BoardWriterClass.MultiPinPrefixString)) {
       String Id =
           ThisAttr.getNodeName().substring(BoardWriterClass.MultiPinPrefixString.length());
       MyPinLocations.put(Integer.parseInt(Id), ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(DriveStrength.DriveAttributeString)) {
       MyDriveStrength = DriveStrength.getId(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(PullBehaviors.PullAttributeString)) {
       MyPullBehavior = PullBehaviors.getId(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(IoStandards.IOAttributeString)) {
       MyIOStandard = IoStandards.getId(ThisAttr.getNodeValue());
     }
     if (ThisAttr.getNodeName().equals(PinActivity.ActivityAttributeString)) {
       MyActivityLevel = PinActivity.getId(ThisAttr.getNodeValue());
     }
   }
   if ((x < 0) || (y < 0) || (width < 1) || (height < 1)) {
     MyType = IOComponentTypes.Unknown;
     return;
   }
   boolean PinsComplete = true;
   for (int i = 0; i < NrOfPins; i++) {
     if (!MyPinLocations.containsKey(i)) {
       logger.warn("Bizar missing pin {} of component!", i);
       PinsComplete = false;
     }
   }
   if (!PinsComplete) {
     MyType = IOComponentTypes.Unknown;
     return;
   }
   if (MyType.equals(IOComponentTypes.DIPSwitch) || MyType.equals(IOComponentTypes.PortIO)) {
     MyType.setNbSwitch(NrOfPins);
   }
   MyRectangle = new BoardRectangle(x, y, width, height);
 }