/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package i2client;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.io.IOException; 
import java.io.StringReader;
import org.jdom.Attribute;
import org.jdom.Document; 
import org.jdom.Element; 
import org.jdom.JDOMException; 
import org.jdom.input.SAXBuilder; 
import org.xml.sax.InputSource;

/**
 *
 * @author LENOVO
 */
public class GenerateXml {
    //解析xml
    public static TreeMap<String, String> xmlElements(String xmlDoc) throws JDOMException, IOException {
        if (xmlDoc!=null && !xmlDoc.equals("")) {
            Pattern p = Pattern.compile("\r|\n");
            Matcher m = p.matcher(xmlDoc);
            xmlDoc = m.replaceAll("");
        }//创建一个新的字符串
        StringReader read = new StringReader(xmlDoc);
        //创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入
        InputSource source = new InputSource(read);
        //创建一个新的SAXBuilder
        SAXBuilder sb = new SAXBuilder();
        TreeMap<String, String> rtnMap = new TreeMap<String, String>();
        SAXBuilder builder = new SAXBuilder();
        Document doc = (Document) builder.build(new StringReader(xmlDoc));
        // 得到根节点
        Element root = doc.getRootElement();
        String rootName = root.getName();
        rtnMap.put("root.name", rootName);
        // 调用递归函数，得到所有最底层元素的名称和值，加入map中
        convert(root, rtnMap, rootName);
        return rtnMap;
    }
    public static void convert(Element e, Map<String, String> map, String lastname) {
            if (e.getAttributes().size() > 0) {
                    Iterator it_attr = e.getAttributes().iterator();
                    while (it_attr.hasNext()) {
                            Attribute attribute = (Attribute) it_attr.next();
                            String attrname = attribute.getName();
                            String attrvalue = e.getAttributeValue(attrname);
                            // map.put( attrname, attrvalue);
                            map.put(lastname + "." + attrname, attrvalue); // key 根据根节点 进行生成
                    }
            }
            List children = e.getChildren();
            Iterator it = children.iterator();
            while (it.hasNext()) {
                    Element child = (Element) it.next();
                    /* String name = lastname + "." + child.getName(); */
                    String name = child.getName();
                    // 如果有子节点，则递归调用
                    if (child.getChildren().size() > 0) {
                            convert(child, map, lastname + "." + child.getName());
                    } else {
                            // 如果没有子节点，则把值加入map
                            map.put(name, child.getText());
                            // 如果该节点有属性，则把所有的属性值也加入map
                            if (child.getAttributes().size() > 0) {
                                    Iterator attr = child.getAttributes().iterator();
                                    while (attr.hasNext()) {
                                            Attribute attribute = (Attribute) attr.next();
                                            String attrname = attribute.getName();
                                            String attrvalue = child.getAttributeValue(attrname);
                                            map.put(lastname + "." + child.getName() + "." + attrname, attrvalue);
                                    }
                            }
                    }
            }
    }
    public static String createCACData_moa(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue){
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>023001</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\""+phase+"\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"SystemVoltage\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"TotalCurrent\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "<attr name=\"ResistiveCurrent\" value=\"" + datavalue[2][0] + "\" alarm=\"" + datavalue[2][1] + "\"/> ";
        cacdata += "<attr name=\"ActionCount\" value=\"" + datavalue[3][0] + "\" alarm=\"" + datavalue[3][1] + "\"/> ";
        cacdata += "<attr name=\"LastActionTime\" value=\"" + datavalue[4][0] + "\" alarm=\"" + datavalue[4][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_eaif(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue,String code){
        String cacdata = "";
        cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>" + code + "</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\""+phase+"\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"MaxTmp\" value=\""+ datavalue[0][0] + "\" alarm=\"" +datavalue[0][1] + "\"/> "; 
        cacdata += "<attr name=\"MinTmp\" value=\""+ datavalue[1][0] + "\" alarm=\"" +datavalue[1][1] + "\"/> ";    
        cacdata += "<attr name=\"AvgTmp\" value=\""+ datavalue[2][0] + "\" alarm=\"" +datavalue[2][1] + "\"/> ";           
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_tx(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue){
        String cacdata = "";
        cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>021004</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"TotalCoreCurrent\" value=\""+ datavalue[0][0] + "\" alarm=\"" +datavalue[0][1] + "\"/> ";         
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_eia(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue){
        String cacdata = "";
        cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>022001</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"Capacitance\" value=\""+ datavalue[0][0] + "\" alarm=\"" +datavalue[0][1] + "\"/> ";         
        cacdata += "<attr name=\"LossFactor\" value=\""+ datavalue[1][0] + "\" alarm=\"" +datavalue[1][1] + "\"/> ";         
        cacdata += "<attr name=\"UnbalanceCurrent\" value=\""+ datavalue[2][0] + "\" alarm=\"" +datavalue[2][1] + "\"/> ";         
        cacdata += "<attr name=\"UnbalanceVoltage\" value=\""+ datavalue[3][0] + "\" alarm=\"" +datavalue[3][1] + "\"/> ";         
        cacdata += "<attr name=\"TotalCurrent\" value=\""+ datavalue[4][0] + "\" alarm=\"" +datavalue[4][1] + "\"/> ";         
        cacdata += "<attr name=\"SystemVoltage\" value=\""+ datavalue[5][0] + "\" alarm=\"" +datavalue[5][1] + "\"/> ";         
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_sf6pressure(String cacid, String sensorid, String equipmentid, String timestamp,String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>024004</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\""+phase+"\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"Temperature\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"AbsolutePressure\" value=\"" + (datavalue[1][0] +900)+ "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "<attr name=\"Density\" value=\"" + datavalue[2][0] + "\" alarm=\"" + datavalue[2][1] + "\"/> ";
        cacdata += "<attr name=\"Moisture\" value=\"" + datavalue[3][0] + "\" alarm=\"" + datavalue[3][1] + "\"/> ";
        cacdata += "<attr name=\"Pressure20C\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_sf6moisture(String cacid, String sensorid, String equipmentid, String timestamp,String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        //A相
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>024005</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\""+phase+"\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"Temperature\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"Moisture\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";         
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_yw(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>021005</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"OilTemperature\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_mlh(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue,String code)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>"+code+"</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"AirTemperature\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"AirPressure\" value=\"" + datavalue[3][0] + "\" alarm=\"" + datavalue[3][1] + "\"/> ";
        cacdata += "<attr name=\"Humidity\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "<attr name=\"Precipitation\" value=\"" + datavalue[5][0] + "\" alarm=\"" + datavalue[5][1] + "\"/> ";
        cacdata += "<attr name=\"PrecipitationIntensity\" value=\"" + datavalue[4][0] + "\" alarm=\"" + datavalue[4][1] + "\"/> ";
        cacdata += "<attr name=\"RadiationIntensity\" value=\"" + datavalue[2][0] + "\" alarm=\"" + datavalue[2][1] + "\"/> ";
        cacdata += "<attr name=\"wdgustspd\" value=\"" + datavalue[6][0] + "\" alarm=\"" + datavalue[6][1] + "\"/> ";
        cacdata += "<attr name=\"wddir\" value=\"" + datavalue[7][0] + "\" alarm=\"" + datavalue[7][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_dmh(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>025001</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"OilTemperature\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_pd_h(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue,String code)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>" + code + "</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"DischargeCapacity\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"DischargePosition\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "<attr name=\"PulseCount\" value=\"" + datavalue[2][0] + "\" alarm=\"" + datavalue[2][1] + "\"/> ";
        cacdata += "<attr name=\"DischargeWaveform\" value=\"" + datavalue[3][0] + "\" alarm=\"" + datavalue[3][1] + "\"/> ";
        cacdata += "<attr name=\"PaDschAlm\" value=\"" + datavalue[4][0] + "\" alarm=\"" + datavalue[4][1] + "\"/> ";
        cacdata += "<attr name=\"DschType\" value=\"" + datavalue[5][0] + "\" alarm=\"" + datavalue[5][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_DLQWave(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        //A相
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>024002</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"Action\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"CoilWaveform\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    
    public static String createCACData_YSP(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>021002</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"H2\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"CH4\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "<attr name=\"C2H6\" value=\"" + datavalue[2][0] + "\" alarm=\"" + datavalue[2][1] + "\"/> ";
        cacdata += "<attr name=\"C2H4\" value=\"" + datavalue[3][0] + "\" alarm=\"" + datavalue[3][1] + "\"/> ";
        cacdata += "<attr name=\"C2H2\" value=\"" + datavalue[4][0] + "\" alarm=\"" + datavalue[4][1] + "\"/> ";
        cacdata += "<attr name=\"CO\" value=\"" + datavalue[5][0] + "\" alarm=\"" + datavalue[5][1] + "\"/> ";
        cacdata += "<attr name=\"CO2\" value=\"" + datavalue[6][0] + "\" alarm=\"" + datavalue[6][1] + "\"/> ";
        cacdata += "<attr name=\"O2\" value=\"" + datavalue[7][0] + "\" alarm=\"" + datavalue[7][1] + "\"/> ";
        cacdata += "<attr name=\"N2\" value=\"" + datavalue[8][0] + "\" alarm=\"" + datavalue[8][1] + "\"/> ";
        cacdata += "<attr name=\"TotalHydrocarbon\" value=\"" + datavalue[9][0] + "\" alarm=\"" + datavalue[9][1] + "\"/> ";
        cacdata += "<attr name=\"GasPress\" value=\"" + datavalue[10][0] + "\" alarm=\"" + datavalue[10][1] + "\"/> ";
        cacdata += "<attr name=\"H2O\" value=\"" + datavalue[11][0] + "\" alarm=\"" + datavalue[11][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    
    public static String createCACData_KGG(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>026001</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"OlTmpA\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "<attr name=\"OlTmpB\" value=\"" + datavalue[1][0] + "\" alarm=\"" + datavalue[1][1] + "\"/> ";
        cacdata += "<attr name=\"OlTmpC\" value=\"" + datavalue[2][0] + "\" alarm=\"" + datavalue[2][1] + "\"/> ";
        cacdata += "<attr name=\"IlTmpA\" value=\"" + datavalue[3][0] + "\" alarm=\"" + datavalue[3][1] + "\"/> ";
        cacdata += "<attr name=\"IlTmpB\" value=\"" + datavalue[4][0] + "\" alarm=\"" + datavalue[4][1] + "\"/> ";
        cacdata += "<attr name=\"IlTmpC\" value=\"" + datavalue[5][0] + "\" alarm=\"" + datavalue[5][1] + "\"/> ";
        cacdata += "<attr name=\"OntologyTmp\" value=\"" + datavalue[6][0] + "\" alarm=\"" + datavalue[6][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
      public static String createCACData_TMT(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>026002</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"Tmp\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }
    public static String createCACData_scur(String cacid, String sensorid, String equipmentid, String timestamp, String phase,String[][] datavalue,String code)
    {    //电缆环流
        String cacdata = "";
        cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>"+ code +"</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"TotalCoreCurrent\" value=\""+ datavalue[0][0] + "\" alarm=\"" +datavalue[0][1] + "\"/> ";         
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;   
    }
    public static String createCACData_DLQChargeTime(String cacid, String sensorid, String equipmentid, String timestamp, String phase, String[][] datavalue)
    {
        String cacdata = "";
        cacdata += "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
        cacdata += "<request> ";
        cacdata += "<monitordata cacid=\"" + cacid + "\" datanodenum=\"1\"> ";
        //A相
        cacdata += "<datanode sensorid=\"" + sensorid + "\"> ";
        cacdata += "<type>024006</type> ";
        cacdata += "<equipmentid>" + equipmentid + "</equipmentid> ";
        cacdata += "<timestamp>" + timestamp + "</timestamp> ";
        cacdata += "<attrs> ";
        cacdata += "<attr name=\"Phase\" value=\"" + phase + "\" alarm=\"FALSE\" /> ";
        cacdata += "<attr name=\"ChargeTime\" value=\"" + datavalue[0][0] + "\" alarm=\"" + datavalue[0][1] + "\"/> ";
        cacdata += "</attrs> ";
        cacdata += "</datanode>";
        cacdata += "</monitordata> ";
        cacdata += "</request> ";
        return cacdata;
    }

}
    



