phoenixplcscadahelper.AnaEkran.java Source code

Java tutorial

Introduction

Here is the source code for phoenixplcscadahelper.AnaEkran.java

Source

/*
 * 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 phoenixplcscadahelper;

import java.awt.Toolkit;
import java.awt.datatransfer.*;
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

/**
 *
 * @author ujk
 */
public class AnaEkran extends javax.swing.JFrame {

    int digitalTagCount = 0;
    int analogTagCount = 0;
    int modbusInNr = 1000; //dijital girilerin balad modbus adresi
    int modbusOutNr = 0; //dijital klarn balad modbus adresi
    int modbusAnalogInNr = 2000; //analog girilerin balad modbus adresi
    int modbusAnalogOutNr = 2100; //analog klarn balad modbus adresi
    String opcName = ""; //Visu deikenleri iin OPC ad
    HSSFWorkbook esaWb; //ESA tag import iin xls dosyas
    int esaRowNr; //ESA tag dosyas satr no
    HSSFWorkbook esaAnalogWb; //ESA analog tag import iin xls dosyas
    int esaAnalogRowNr; //ESA analog tag dosyas satr no
    HSSFWorkbook esaAWb; //ESA alarm import iin xls dosyas
    int esaARowNr; //ESA alarm dosyas satr no
    String modbusMasterName = ""; //Modbus master ad

    /**
     * Creates new form AnaEkran
     */
    public AnaEkran() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dosyaSecButton = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        plcGlobalLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        plcGlobalTextArea = new javax.swing.JTextArea();
        plcGlobalButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        girislerTextArea = new javax.swing.JTextArea();
        plcGirislerButton = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        plcCikislarButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        cikislarTextArea = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        initMbGirislerTextArea = new javax.swing.JTextArea();
        plcInitmbInButton = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        initMbCikislarTextArea = new javax.swing.JTextArea();
        plcInitmbOutButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        opcNameLabel = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        visuOpcTextArea = new javax.swing.JTextArea();
        visuOpcAllButton = new javax.swing.JButton();
        visuOpcLineButton = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        visuVarTextArea = new javax.swing.JTextArea();
        visuVarAllButton = new javax.swing.JButton();
        visuVarLineButton = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        visuAlTextArea = new javax.swing.JTextArea();
        jButton11 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        esaScriptTextArea = new javax.swing.JTextArea();
        esaScriptCopyButton = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane10 = new javax.swing.JScrollPane();
        esaAlarmScriptTextArea = new javax.swing.JTextArea();
        esaAlarmScriptCopyButton = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        esaAnalogScriptCopyButton = new javax.swing.JButton();
        jScrollPane18 = new javax.swing.JScrollPane();
        esaAnalogScriptTextArea = new javax.swing.JTextArea();
        jPanel5 = new javax.swing.JPanel();
        plcAnalogGlobalLabel = new javax.swing.JLabel();
        plcAnalogGlobalButton = new javax.swing.JButton();
        jScrollPane11 = new javax.swing.JScrollPane();
        plcAnalogGlobalTextArea = new javax.swing.JTextArea();
        jLabel9 = new javax.swing.JLabel();
        plcAnalogGirislerButton = new javax.swing.JButton();
        jScrollPane12 = new javax.swing.JScrollPane();
        girislerAnalogTextArea = new javax.swing.JTextArea();
        jLabel10 = new javax.swing.JLabel();
        plcAnalogCikislarButton = new javax.swing.JButton();
        jScrollPane13 = new javax.swing.JScrollPane();
        cikislarAnalogTextArea = new javax.swing.JTextArea();
        jPanel6 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        plcAnalogInitmbInButton = new javax.swing.JButton();
        jScrollPane14 = new javax.swing.JScrollPane();
        initAnalogMbGirislerTextArea = new javax.swing.JTextArea();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane15 = new javax.swing.JScrollPane();
        initAnalogMbCikislarTextArea = new javax.swing.JTextArea();
        plcAnalogInitmbOutButton = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        opcAnalogNameLabel = new javax.swing.JLabel();
        visuAnalogOpcAllButton = new javax.swing.JButton();
        visuAnalogOpcLineButton = new javax.swing.JButton();
        jScrollPane16 = new javax.swing.JScrollPane();
        visuAnalogOpcTextArea = new javax.swing.JTextArea();
        jLabel13 = new javax.swing.JLabel();
        visuAnalogVarAllButton = new javax.swing.JButton();
        visuAnalogVarLineButton = new javax.swing.JButton();
        jScrollPane17 = new javax.swing.JScrollPane();
        visuAnalogVarTextArea = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        dosyaSecButton.setText("IO Dosyas Se");
        dosyaSecButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dosyaSecButtonActionPerformed(evt);
            }
        });

        jTabbedPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.LEFT);
        jTabbedPane1.setToolTipText("");
        jTabbedPane1.setName(""); // NOI18N

        plcGlobalLabel.setText("Dijital Global Deikenler x Adet");

        plcGlobalTextArea.setColumns(20);
        plcGlobalTextArea.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        plcGlobalTextArea.setRows(5);
        jScrollPane1.setViewportView(plcGlobalTextArea);

        plcGlobalButton.setText("Panoya Kopyala");
        plcGlobalButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcGlobalButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("GIRISLER stl dosyas");

        girislerTextArea.setColumns(20);
        girislerTextArea.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        girislerTextArea.setRows(5);
        jScrollPane2.setViewportView(girislerTextArea);

        plcGirislerButton.setText("Panoya Kopyala");
        plcGirislerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcGirislerButtonActionPerformed(evt);
            }
        });

        jLabel2.setText("CIKISLAR stl dosyas");

        plcCikislarButton.setText("Panoya Kopyala");
        plcCikislarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcCikislarButtonActionPerformed(evt);
            }
        });

        cikislarTextArea.setColumns(20);
        cikislarTextArea.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        cikislarTextArea.setRows(5);
        jScrollPane3.setViewportView(cikislarTextArea);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1)
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(plcGlobalLabel)
                                .addGap(106, 106, 106)
                                .addComponent(plcGlobalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addGroup(
                                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel1)
                                                .addGap(186, 186, 186).addComponent(plcGirislerButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 455,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78,
                                        Short.MAX_VALUE)
                                .addGroup(jPanel1Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel2)
                                                .addGap(186, 186, 186).addComponent(plcCikislarButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 455,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                                        .addComponent(plcGlobalLabel))
                                .addComponent(plcGlobalButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 193,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel1).addComponent(plcGirislerButton))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane2))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel2).addComponent(plcCikislarButton))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        280, Short.MAX_VALUE)))
                        .addContainerGap()));

        jTabbedPane1.addTab("Dijital PLC", jPanel1);

        jLabel3.setText("Dijital giriler iin INITMB dosyasna");

        initMbGirislerTextArea.setColumns(20);
        initMbGirislerTextArea.setRows(5);
        jScrollPane4.setViewportView(initMbGirislerTextArea);

        plcInitmbInButton.setText("Panoya Kopyala");
        plcInitmbInButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcInitmbInButtonActionPerformed(evt);
            }
        });

        jLabel4.setText("Dijital klar iin INITMB dosyasna");

        initMbCikislarTextArea.setColumns(20);
        initMbCikislarTextArea.setRows(5);
        jScrollPane5.setViewportView(initMbCikislarTextArea);

        plcInitmbOutButton.setText("Panoya Kopyala");
        plcInitmbOutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcInitmbOutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel3).addGap(153, 153, 153)
                                .addComponent(plcInitmbInButton, javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jScrollPane4)).addGap(26, 26, 26)
                        .addGroup(jPanel2Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel4)
                                        .addGap(153, 153, 153).addComponent(plcInitmbOutButton,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jScrollPane5))
                        .addContainerGap()));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel3).addComponent(plcInitmbInButton).addComponent(jLabel4)
                                .addComponent(plcInitmbOutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 256,
                                                Short.MAX_VALUE)
                                        .addComponent(jScrollPane5))
                        .addContainerGap(254, Short.MAX_VALUE)));

        jTabbedPane1.addTab("Modbus PLC", jPanel2);

        opcNameLabel.setText("OPC Ad = x");

        visuOpcTextArea.setColumns(20);
        visuOpcTextArea.setRows(5);
        jScrollPane6.setViewportView(visuOpcTextArea);

        visuOpcAllButton.setText("Hepsini Panoya Kopyala");
        visuOpcAllButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuOpcAllButtonActionPerformed(evt);
            }
        });

        visuOpcLineButton.setText("Satr Panoya Kopyala");
        visuOpcLineButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuOpcLineButtonActionPerformed(evt);
            }
        });

        jLabel5.setText("Visu Deikenleri");

        visuVarTextArea.setColumns(20);
        visuVarTextArea.setRows(5);
        jScrollPane7.setViewportView(visuVarTextArea);

        visuVarAllButton.setText("Hepsini Panoya Kopyala");
        visuVarAllButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuVarAllButtonActionPerformed(evt);
            }
        });

        visuVarLineButton.setText("Satr Panoya Kopyala");
        visuVarLineButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuVarLineButtonActionPerformed(evt);
            }
        });

        jLabel6.setText("Visu Alarm TextList");

        visuAlTextArea.setColumns(20);
        visuAlTextArea.setRows(5);
        jScrollPane8.setViewportView(visuAlTextArea);

        jButton11.setText("Hepsini Panoya Kopyala");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane7)
                        .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel5).addGap(58, 58, 58)
                                .addComponent(visuVarAllButton, javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(126, 126, 126)
                                .addComponent(visuVarLineButton, javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel3Layout.createSequentialGroup().addComponent(opcNameLabel)
                                                .addGap(52, 52, 52)
                                                .addComponent(visuOpcAllButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        122, Short.MAX_VALUE)
                                                .addComponent(visuOpcLineButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane6)).addGap(18, 18, 18)
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addGroup(jPanel3Layout.createSequentialGroup()
                                                        .addComponent(jLabel6)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                        .addComponent(jButton11,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        337, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addContainerGap()));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(visuOpcAllButton).addComponent(opcNameLabel)
                                .addComponent(visuOpcLineButton).addComponent(jLabel6).addComponent(jButton11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 222,
                                                Short.MAX_VALUE)
                                        .addComponent(jScrollPane8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel5).addComponent(visuVarAllButton)
                                .addComponent(visuVarLineButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
                        .addContainerGap()));

        jTabbedPane1.addTab("Visu", jPanel3);

        jLabel7.setText("Dijitallerin Manual Kontrol Scriptleri");

        esaScriptTextArea.setColumns(20);
        esaScriptTextArea.setRows(5);
        jScrollPane9.setViewportView(esaScriptTextArea);

        esaScriptCopyButton.setText("Hepsini Kopyala");
        esaScriptCopyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                esaScriptCopyButtonActionPerformed(evt);
            }
        });

        jLabel8.setText("Alarm Scripti");

        esaAlarmScriptTextArea.setColumns(20);
        esaAlarmScriptTextArea.setRows(5);
        jScrollPane10.setViewportView(esaAlarmScriptTextArea);

        esaAlarmScriptCopyButton.setText("Hepsini Kopyala");
        esaAlarmScriptCopyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                esaAlarmScriptCopyButtonActionPerformed(evt);
            }
        });

        jLabel14.setText("Analoglarn Manual Kontrol Scriptleri");

        esaAnalogScriptCopyButton.setText("Hepsini Kopyala");
        esaAnalogScriptCopyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                esaAnalogScriptCopyButtonActionPerformed(evt);
            }
        });

        esaAnalogScriptTextArea.setColumns(20);
        esaAnalogScriptTextArea.setRows(5);
        jScrollPane18.setViewportView(esaAnalogScriptTextArea);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(jPanel4Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jScrollPane18)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                        jPanel4Layout.createSequentialGroup().addComponent(jLabel14)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(esaAnalogScriptCopyButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 195,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jScrollPane9, javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                        jPanel4Layout.createSequentialGroup().addComponent(jLabel7)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        155, Short.MAX_VALUE)
                                                .addComponent(esaScriptCopyButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 195,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(
                                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel4Layout.createSequentialGroup().addComponent(jLabel8)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        202, Short.MAX_VALUE)
                                                .addComponent(esaAlarmScriptCopyButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 195,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane10))
                        .addContainerGap()));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel7).addComponent(esaScriptCopyButton).addComponent(jLabel8)
                                .addComponent(esaAlarmScriptCopyButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 227,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanel4Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel14).addComponent(esaAnalogScriptCopyButton))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane18, javax.swing.GroupLayout.DEFAULT_SIZE, 232,
                                                Short.MAX_VALUE))
                                .addComponent(jScrollPane10))
                        .addContainerGap()));

        jTabbedPane1.addTab("ESA", jPanel4);

        plcAnalogGlobalLabel.setText("Analog Global Deikenler x Adet");

        plcAnalogGlobalButton.setText("Panoya Kopyala");
        plcAnalogGlobalButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcAnalogGlobalButtonActionPerformed(evt);
            }
        });

        plcAnalogGlobalTextArea.setColumns(20);
        plcAnalogGlobalTextArea.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        plcAnalogGlobalTextArea.setRows(5);
        jScrollPane11.setViewportView(plcAnalogGlobalTextArea);

        jLabel9.setText("GIRISLER stl dosyas");

        plcAnalogGirislerButton.setText("Panoya Kopyala");
        plcAnalogGirislerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcAnalogGirislerButtonActionPerformed(evt);
            }
        });

        girislerAnalogTextArea.setColumns(20);
        girislerAnalogTextArea.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        girislerAnalogTextArea.setRows(5);
        jScrollPane12.setViewportView(girislerAnalogTextArea);

        jLabel10.setText("CIKISLAR stl dosyas");

        plcAnalogCikislarButton.setText("Panoya Kopyala");
        plcAnalogCikislarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcAnalogCikislarButtonActionPerformed(evt);
            }
        });

        cikislarAnalogTextArea.setColumns(20);
        cikislarAnalogTextArea.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        cikislarAnalogTextArea.setRows(5);
        jScrollPane13.setViewportView(cikislarAnalogTextArea);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(jPanel5Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addGroup(jPanel5Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane11)
                        .addGroup(jPanel5Layout.createSequentialGroup().addComponent(plcAnalogGlobalLabel)
                                .addGap(96, 96, 96)
                                .addComponent(plcAnalogGlobalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                        .addGroup(jPanel5Layout.createSequentialGroup().addGroup(
                                jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel5Layout.createSequentialGroup().addComponent(jLabel9)
                                                .addGap(186, 186, 186).addComponent(plcAnalogGirislerButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 455,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78,
                                        Short.MAX_VALUE)
                                .addGroup(jPanel5Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel5Layout.createSequentialGroup().addComponent(jLabel10)
                                                .addGap(186, 186, 186).addComponent(plcAnalogCikislarButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 455,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addContainerGap()));
        jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(plcAnalogGlobalButton).addComponent(plcAnalogGlobalLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 193,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel5Layout.createSequentialGroup()
                                        .addGroup(jPanel5Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel9).addComponent(plcAnalogGirislerButton))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 280,
                                                Short.MAX_VALUE)
                                        .addGap(13, 13, 13))
                                .addGroup(jPanel5Layout.createSequentialGroup()
                                        .addGroup(jPanel5Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel10).addComponent(plcAnalogCikislarButton))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 282,
                                                Short.MAX_VALUE)
                                        .addContainerGap()))));

        jTabbedPane1.addTab("Analog PLC", jPanel5);

        jLabel11.setText("Analog giriler iin INITMB dosyasna");

        plcAnalogInitmbInButton.setText("Panoya Kopyala");
        plcAnalogInitmbInButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcAnalogInitmbInButtonActionPerformed(evt);
            }
        });

        initAnalogMbGirislerTextArea.setColumns(20);
        initAnalogMbGirislerTextArea.setRows(5);
        jScrollPane14.setViewportView(initAnalogMbGirislerTextArea);

        jLabel12.setText("Analog klar iin INITMB dosyasna");

        initAnalogMbCikislarTextArea.setColumns(20);
        initAnalogMbCikislarTextArea.setRows(5);
        jScrollPane15.setViewportView(initAnalogMbCikislarTextArea);

        plcAnalogInitmbOutButton.setText("Panoya Kopyala");
        plcAnalogInitmbOutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plcAnalogInitmbOutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(jPanel6Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addGroup(jPanel6Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel11).addGap(153, 153, 153)
                                .addComponent(plcAnalogInitmbInButton, javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jScrollPane14)).addGap(26, 26, 26)
                        .addGroup(
                                jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel12)
                                                .addGap(153, 153, 153).addComponent(plcAnalogInitmbOutButton,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane15))
                        .addContainerGap()));
        jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel11).addComponent(plcAnalogInitmbInButton).addComponent(jLabel12)
                                .addComponent(plcAnalogInitmbOutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jScrollPane14, javax.swing.GroupLayout.DEFAULT_SIZE, 256,
                                                Short.MAX_VALUE)
                                        .addComponent(jScrollPane15))
                        .addContainerGap(254, Short.MAX_VALUE)));

        jTabbedPane1.addTab("MBAnalogPLC", jPanel6);

        opcAnalogNameLabel.setText("OPC Ad = x");

        visuAnalogOpcAllButton.setText("Hepsini Panoya Kopyala");
        visuAnalogOpcAllButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuAnalogOpcAllButtonActionPerformed(evt);
            }
        });

        visuAnalogOpcLineButton.setText("Satr Panoya Kopyala");
        visuAnalogOpcLineButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuAnalogOpcLineButtonActionPerformed(evt);
            }
        });

        visuAnalogOpcTextArea.setColumns(20);
        visuAnalogOpcTextArea.setRows(5);
        jScrollPane16.setViewportView(visuAnalogOpcTextArea);

        jLabel13.setText("Visu Deikenleri");

        visuAnalogVarAllButton.setText("Hepsini Panoya Kopyala");
        visuAnalogVarAllButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuAnalogVarAllButtonActionPerformed(evt);
            }
        });

        visuAnalogVarLineButton.setText("Satr Panoya Kopyala");
        visuAnalogVarLineButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visuAnalogVarLineButtonActionPerformed(evt);
            }
        });

        visuAnalogVarTextArea.setColumns(20);
        visuAnalogVarTextArea.setRows(5);
        jScrollPane17.setViewportView(visuAnalogVarTextArea);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout
                .setHorizontalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGap(0, 1008, Short.MAX_VALUE)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                                        .addGroup(jPanel7Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jScrollPane17)
                                                .addGroup(jPanel7Layout.createSequentialGroup()
                                                        .addComponent(jLabel13).addGap(58, 58, 58)
                                                        .addComponent(visuAnalogVarAllButton,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(126, 126, 126)
                                                        .addComponent(visuAnalogVarLineButton,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(0, 0, Short.MAX_VALUE))
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout
                                                        .createSequentialGroup().addComponent(opcAnalogNameLabel)
                                                        .addGap(52, 52, 52)
                                                        .addComponent(visuAnalogOpcAllButton,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                122, Short.MAX_VALUE)
                                                        .addComponent(visuAnalogOpcLineButton,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(355, 355, 355))
                                                .addComponent(jScrollPane16))
                                        .addContainerGap())));
        jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 550, Short.MAX_VALUE)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                                .addGroup(jPanel7Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(visuAnalogOpcAllButton).addComponent(opcAnalogNameLabel)
                                        .addComponent(visuAnalogOpcLineButton))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane16, javax.swing.GroupLayout.PREFERRED_SIZE, 222,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel7Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel13).addComponent(visuAnalogVarAllButton)
                                        .addComponent(visuAnalogVarLineButton))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane17, javax.swing.GroupLayout.DEFAULT_SIZE, 237,
                                        Short.MAX_VALUE)
                                .addContainerGap())));

        jTabbedPane1.addTab("Analog Visu", jPanel7);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTabbedPane1).addGroup(layout.createSequentialGroup()
                                        .addComponent(dosyaSecButton).addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(dosyaSecButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTabbedPane1).addContainerGap()));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void dosyaSecButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dosyaSecButtonActionPerformed
        opcName = getOpcName();
        modbusMasterName = getModbusName();
        opcNameLabel.setText("OPC Ad = " + opcName);
        visuOpcTextArea.setText("");
        visuVarTextArea.setText("");

        JFileChooser jfc = new JFileChooser();
        jfc.setDialogTitle("Ltfen IO Liste Dosyas Sein");
        jfc.setCurrentDirectory(new java.io.File("."));
        jfc.setFileFilter(new FileNameExtensionFilter("Excel Files", "xls"));
        int returnVal = jfc.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File xlsFile = jfc.getSelectedFile();

            //..
            java.io.FileInputStream file;
            try {
                file = new java.io.FileInputStream(xlsFile);
                HSSFWorkbook workbook = new HSSFWorkbook(file);
                HSSFSheet sheet = workbook.getSheetAt(0);
                int maxRowNr = sheet.getLastRowNum();
                digitalTagCount = 0;
                modbusInNr = 1000;
                modbusOutNr = 0;

                // esa tag dosyas
                esaWb = new HSSFWorkbook();
                fillEsaWb();

                // esa alarm dosyas
                esaAWb = new HSSFWorkbook();
                fillEsaAWb();

                // esa analog tag dosyas
                esaAnalogWb = new HSSFWorkbook();
                fillEsaAnalogWb();

                for (int i = 0; i < maxRowNr; i++) {

                    if (sheet.getRow(i) == null) {
                    } else if (sheet.getRow(i).getCell(3) == null) {
                    } else {
                        HSSFCell cell = sheet.getRow(i).getCell(3);
                        if (cell.toString().startsWith("O")) { //DIGITAL OUTPUT
                            digitalOutput(sheet.getRow(i));
                        }
                        if (cell.toString().startsWith("I")) { //DIGITAL INPUT
                            digitalInput(sheet.getRow(i));
                        }
                        if (cell.toString().startsWith("AI")) { //ANALOG INPUT
                            analogInput(sheet.getRow(i));
                        }
                        if (cell.toString().startsWith("AO")) { //ANALOG OUTPUT
                            analogOutput(sheet.getRow(i));
                        }
                    }
                }

                FileOutputStream fileOut = new FileOutputStream(xlsFile.getParent() + "\\esaTag.xls");
                esaWb.write(fileOut);
                fileOut.close();
                FileOutputStream fileAOut = new FileOutputStream(xlsFile.getParent() + "\\esaAlarms.xls");
                esaAWb.write(fileAOut);
                fileAOut.close();
                FileOutputStream fileAnalogOut = new FileOutputStream(xlsFile.getParent() + "\\esaAnalogTag.xls");
                esaAnalogWb.write(fileAnalogOut);
                fileAnalogOut.close();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(AnaEkran.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(AnaEkran.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_dosyaSecButtonActionPerformed

    private void plcGlobalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcGlobalButtonActionPerformed
        String get = plcGlobalTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcGlobalButtonActionPerformed

    private void plcGirislerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcGirislerButtonActionPerformed
        String get = girislerTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcGirislerButtonActionPerformed

    private void plcCikislarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcCikislarButtonActionPerformed
        String get = cikislarTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcCikislarButtonActionPerformed

    private void plcInitmbInButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcInitmbInButtonActionPerformed
        String get = initMbGirislerTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcInitmbInButtonActionPerformed

    private void plcInitmbOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcInitmbOutButtonActionPerformed
        String get = initMbCikislarTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcInitmbOutButtonActionPerformed

    private void visuOpcAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuOpcAllButtonActionPerformed
        String get = visuOpcTextArea.getText();
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuOpcAllButtonActionPerformed

    private void visuOpcLineButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuOpcLineButtonActionPerformed
        String get = visuOpcTextArea.getText();
        int curPos = visuOpcTextArea.getCaretPosition();
        int endPoint = visuOpcTextArea.getText().indexOf("\n", curPos);
        int strPoint = visuOpcTextArea.getText().substring(0, curPos).lastIndexOf("\n");
        //System.out.println(get.substring(strPoint+1, endPoint));
        get = get.substring(strPoint + 1, endPoint);
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuOpcLineButtonActionPerformed

    private void visuVarAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuVarAllButtonActionPerformed
        String get = visuVarTextArea.getText();
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuVarAllButtonActionPerformed

    private void visuVarLineButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuVarLineButtonActionPerformed
        String get = visuVarTextArea.getText();
        int curPos = visuVarTextArea.getCaretPosition();
        int endPoint = visuVarTextArea.getText().indexOf("\n", curPos);
        int strPoint = visuVarTextArea.getText().substring(0, curPos).lastIndexOf("\n");
        //System.out.println(get.substring(strPoint+1, endPoint));
        get = get.substring(strPoint + 1, endPoint);
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuVarLineButtonActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        String get = visuAlTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_jButton11ActionPerformed

    private void esaScriptCopyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_esaScriptCopyButtonActionPerformed
        String get = esaScriptTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_esaScriptCopyButtonActionPerformed

    private void esaAlarmScriptCopyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_esaAlarmScriptCopyButtonActionPerformed
        String get = esaAlarmScriptTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_esaAlarmScriptCopyButtonActionPerformed

    private void plcAnalogGlobalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcAnalogGlobalButtonActionPerformed
        String get = plcAnalogGlobalTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcAnalogGlobalButtonActionPerformed

    private void plcAnalogGirislerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcAnalogGirislerButtonActionPerformed
        String get = girislerAnalogTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcAnalogGirislerButtonActionPerformed

    private void plcAnalogCikislarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcAnalogCikislarButtonActionPerformed
        String get = cikislarAnalogTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcAnalogCikislarButtonActionPerformed

    private void plcAnalogInitmbInButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcAnalogInitmbInButtonActionPerformed
        String get = initAnalogMbGirislerTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcAnalogInitmbInButtonActionPerformed

    private void plcAnalogInitmbOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plcAnalogInitmbOutButtonActionPerformed
        String get = initAnalogMbCikislarTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_plcAnalogInitmbOutButtonActionPerformed

    private void visuAnalogOpcAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuAnalogOpcAllButtonActionPerformed
        String get = visuAnalogOpcTextArea.getText();
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuAnalogOpcAllButtonActionPerformed

    private void visuAnalogOpcLineButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuAnalogOpcLineButtonActionPerformed
        String get = visuAnalogOpcTextArea.getText();
        int curPos = visuAnalogOpcTextArea.getCaretPosition();
        int endPoint = visuAnalogOpcTextArea.getText().indexOf("\n", curPos);
        int strPoint = visuAnalogOpcTextArea.getText().substring(0, curPos).lastIndexOf("\n");
        get = get.substring(strPoint + 1, endPoint);
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuAnalogOpcLineButtonActionPerformed

    private void visuAnalogVarAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuAnalogVarAllButtonActionPerformed
        String get = visuAnalogVarTextArea.getText();
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuAnalogVarAllButtonActionPerformed

    private void visuAnalogVarLineButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visuAnalogVarLineButtonActionPerformed
        String get = visuAnalogVarTextArea.getText();
        int curPos = visuAnalogVarTextArea.getCaretPosition();
        int endPoint = visuAnalogVarTextArea.getText().indexOf("\n", curPos);
        int strPoint = visuAnalogVarTextArea.getText().substring(0, curPos).lastIndexOf("\n");
        get = get.substring(strPoint + 1, endPoint);
        get = "<MovClipboard>" + get.substring(1, get.length() - 2) + "</MovClipboard>\n";
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_visuAnalogVarLineButtonActionPerformed

    private void esaAnalogScriptCopyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_esaAnalogScriptCopyButtonActionPerformed
        String get = esaAnalogScriptTextArea.getText();
        StringSelection selec = new StringSelection(get);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selec, selec);
    }//GEN-LAST:event_esaAnalogScriptCopyButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AnaEkran.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AnaEkran.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AnaEkran.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AnaEkran.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AnaEkran().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea cikislarAnalogTextArea;
    private javax.swing.JTextArea cikislarTextArea;
    private javax.swing.JButton dosyaSecButton;
    private javax.swing.JButton esaAlarmScriptCopyButton;
    private javax.swing.JTextArea esaAlarmScriptTextArea;
    private javax.swing.JButton esaAnalogScriptCopyButton;
    private javax.swing.JTextArea esaAnalogScriptTextArea;
    private javax.swing.JButton esaScriptCopyButton;
    private javax.swing.JTextArea esaScriptTextArea;
    private javax.swing.JTextArea girislerAnalogTextArea;
    private javax.swing.JTextArea girislerTextArea;
    private javax.swing.JTextArea initAnalogMbCikislarTextArea;
    private javax.swing.JTextArea initAnalogMbGirislerTextArea;
    private javax.swing.JTextArea initMbCikislarTextArea;
    private javax.swing.JTextArea initMbGirislerTextArea;
    private javax.swing.JButton jButton11;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane15;
    private javax.swing.JScrollPane jScrollPane16;
    private javax.swing.JScrollPane jScrollPane17;
    private javax.swing.JScrollPane jScrollPane18;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel opcAnalogNameLabel;
    private javax.swing.JLabel opcNameLabel;
    private javax.swing.JButton plcAnalogCikislarButton;
    private javax.swing.JButton plcAnalogGirislerButton;
    private javax.swing.JButton plcAnalogGlobalButton;
    private javax.swing.JLabel plcAnalogGlobalLabel;
    private javax.swing.JTextArea plcAnalogGlobalTextArea;
    private javax.swing.JButton plcAnalogInitmbInButton;
    private javax.swing.JButton plcAnalogInitmbOutButton;
    private javax.swing.JButton plcCikislarButton;
    private javax.swing.JButton plcGirislerButton;
    private javax.swing.JButton plcGlobalButton;
    private javax.swing.JLabel plcGlobalLabel;
    private javax.swing.JTextArea plcGlobalTextArea;
    private javax.swing.JButton plcInitmbInButton;
    private javax.swing.JButton plcInitmbOutButton;
    private javax.swing.JTextArea visuAlTextArea;
    private javax.swing.JButton visuAnalogOpcAllButton;
    private javax.swing.JButton visuAnalogOpcLineButton;
    private javax.swing.JTextArea visuAnalogOpcTextArea;
    private javax.swing.JButton visuAnalogVarAllButton;
    private javax.swing.JButton visuAnalogVarLineButton;
    private javax.swing.JTextArea visuAnalogVarTextArea;
    private javax.swing.JButton visuOpcAllButton;
    private javax.swing.JButton visuOpcLineButton;
    private javax.swing.JTextArea visuOpcTextArea;
    private javax.swing.JButton visuVarAllButton;
    private javax.swing.JButton visuVarLineButton;
    private javax.swing.JTextArea visuVarTextArea;
    // End of variables declaration//GEN-END:variables

    private void digitalOutput(HSSFRow row) {
        String tagName = row.getCell(1).toString();
        String tagComment = row.getCell(2).toString();
        String tagIO = row.getCell(3).toString();
        digitalTagCount++;
        if (digitalTagCount == 1) {
            String header = "(*  ###    #    #  #  #####    #    #     *)\n"
                    + "(*  #  #        #       #     ###   #     *)\n"
                    + "(*  #   #  #    #  #    #    #   #  #     *)\n"
                    + "(*  #   #  #    #  #    #    #   #  #     *)\n"
                    + "(*  #  #   # #  #  #    #   ####### #     *)\n"
                    + "(*  ###    #  ##   #    #   #     # ##### *)\n\n\n\n";
            girislerTextArea.append(header);
            cikislarTextArea.append(header);
        }
        plcGlobalTextArea.append(tagIO + "\tBOOL\tVAR_GLOBAL\t" + row.getCell(1).toString()
                + "\t\t\t0\t0\t0\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
        if (tagName.equals("YEDEK")) {
        } else {
            digitalTagCount++;
            plcGlobalTextArea.append(tagName + "W\tWORD\tVAR_GLOBAL\t" + tec(tagComment)
                    + "\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
            digitalTagCount++;
            plcGlobalTextArea.append(tagName + "\tBOOL\tVAR_GLOBAL\t" + tec(tagComment)
                    + "\t\t\t0\t0\t0\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");

            //modbus plc ksm
            initMbCikislarTextArea.append("if MODDATA[" + modbusOutNr + "] <> MODDATA2[" + modbusOutNr + "] then "
                    + tagName + "W := MODDATA[" + modbusOutNr + "]; else MODDATA[" + modbusOutNr + "] := " + tagName
                    + "W; end_if;\n");
        }
        plcGlobalLabel.setText("Dijital Global Deikenler " + digitalTagCount + " Adet");

        //CIKISLAR stl dosyas ierii
        if (tagName.equals("YEDEK")) {
        } else {
            int alrType = 0;
            String onFb = "false";
            String offFb = "false";

            int onFbRowNr = findRow(row.getSheet(), tagName + "_ON_FB");
            if (onFbRowNr > 0) {
                onFb = row.getSheet().getRow(onFbRowNr).getCell(3).toString();
            }
            int offFbRowNr = findRow(row.getSheet(), tagName + "_OFF_FB");
            if (offFbRowNr > 0) {
                offFb = row.getSheet().getRow(offFbRowNr).getCell(3).toString();
            }
            alrType = ((onFb.equals("false")) ? 0 : 1) + ((offFb.equals("false")) ? 0 : 2);

            // kn fb alarm var
            if (alrType > 0) {
                visuAlTextArea.append(tagName + "W.2\t" + tagName + " - " + tagComment);
                //esa alarm tag
                HSSFRow trow = esaWb.getSheet("Tags").createRow(esaRowNr);
                trow.createCell(0).setCellValue("");
                trow.createCell(1).setCellValue(tagName);
                trow.createCell(2).setCellValue("Internal");
                trow.createCell(3).setCellValue("");
                trow.createCell(4).setCellValue("");
                trow.createCell(5).setCellValue("");
                trow.createCell(6).setCellValue("");
                trow.createCell(7).setCellValue("");
                trow.createCell(8).setCellValue("Boolean");
                trow.createCell(9).setCellValue("");
                trow.createCell(10).setCellValue(tagComment + " alarm var");
                trow.createCell(11).setCellValue(0);
                trow.createCell(12).setCellValue("");
                esaRowNr++;
                //esa AlarmScript ierii
                esaAlarmScriptTextArea.append("'" + tagName + "\na = ESAHMI.ESATAG.GetCurrentValue(\"" + tagName
                        + "W\") And 4\nf = ESAHMI.ESATAG.WriteValue(\"" + tagName + "\" , a)\n");
                //esa alarm xls
                HSSFRow arow = esaAWb.getSheet("Alarms").createRow(esaARowNr);
                arow.createCell(0).setCellValue("");
                arow.createCell(1).setCellValue(tagName);
                arow.createCell(2).setCellValue("Bit");
                arow.createCell(3).setCellValue(tagName);
                arow.createCell(4).setCellValue("AlarmPriority Error");
                arow.createCell(5).setCellValue(tagComment + " alarm");
                arow.createCell(6).setCellValue(1);
                esaARowNr++;
            }

            cikislarTextArea.append("(* " + tagIO + " - " + tagName + " - " + tagComment + " *)\n");
            cikislarTextArea.append(
                    "DIGOUT_FB_1(LOG_INP := " + tagName + ",OUT_WORD := " + tagName + "W,ALR_TYP := " + alrType
                            + ",ALR_TIME := 5,FBON := " + onFb + ",FBOFF := " + offFb + ",AL_RST := ALRST);\n");
            cikislarTextArea.append(tagName + "W := DIGOUT_FB_1.OUT_WORD;\n");
            cikislarTextArea.append(tagIO + " := DIGOUT_FB_1.FIZ_OUT;\n\n\n");
        }

        //Visu OPC tag listesi
        if (tagName.equals("YEDEK")) {
        } else {
            visuOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "W\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "W</ItemID>\t</OPCItem>\t\t" + "\n");

            //Visu Var deikenleri
            visuVarTextArea.append(
                    "\t\t<Variable(Tag)>   <Name Type=\"4\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagIO + " - " + tagComment + "\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "W</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
        }

        //ESA tag listesi
        if (tagName.equals("YEDEK")) {
        } else {
            HSSFRow trow = esaWb.getSheet("Tags").createRow(esaRowNr);
            trow.createCell(0).setCellValue("");
            trow.createCell(1).setCellValue(tagName + "W");
            trow.createCell(2).setCellValue("Device");
            trow.createCell(3).setCellValue(modbusMasterName);
            trow.createCell(4).setCellValue("FC 03-16: read/write registers");
            trow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusOutNr));
            trow.createCell(6).setCellValue("Word");
            trow.createCell(7).setCellValue("False");
            trow.createCell(8).setCellValue("Integer");
            trow.createCell(9).setCellValue("Class_0_5: 500 msec");
            trow.createCell(10).setCellValue(tagComment);
            trow.createCell(11).setCellValue(0);
            trow.createCell(12).setCellValue("");
            esaRowNr++;
        }

        //ESA Scriptler
        if (tagName.equals("YEDEK")) {
        } else {
            esaScriptTextArea.append("\tCase " + modbusOutNr + "\n\t\tnom = \"" + tagName + "W\"\n\t\tdesc = \""
                    + tec(tagComment) + "\"\n\n");
        }

        modbusOutNr++;
    }

    private void digitalInput(HSSFRow row) {

        // Global deiken tanmlar
        String tagName = row.getCell(1).toString();
        String tagComment = row.getCell(2).toString();
        String tagIO = row.getCell(3).toString();
        digitalTagCount++;
        if (digitalTagCount == 1) {
            String header = "(*  ###    #    #  #  #####    #    #     *)\n"
                    + "(*  #  #        #       #     ###   #     *)\n"
                    + "(*  #   #  #    #  #    #    #   #  #     *)\n"
                    + "(*  #   #  #    #  #    #    #   #  #     *)\n"
                    + "(*  #  #   # #  #  #    #   ####### #     *)\n"
                    + "(*  ###    #  ##   #    #   #     # ##### *)\n\n\n\n";
            girislerTextArea.append(header);
            cikislarTextArea.append(header);
        }
        plcGlobalTextArea
                .append(tagIO + "\tBOOL\tVAR_GLOBAL\t" + tagName + "\t\t\t0\t0\t0\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
        if (tagName.equals("YEDEK") | tagName.contains("ON_FB") | tagName.contains("OFF_FB")) {
        } else {
            digitalTagCount++;
            plcGlobalTextArea.append(tagName + "W\tWORD\tVAR_GLOBAL\t" + tec(tagComment)
                    + "\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
            digitalTagCount++;
            plcGlobalTextArea.append(tagName + "\tBOOL\tVAR_GLOBAL\t" + tec(tagComment)
                    + "\t\t\t0\t0\t0\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");

            //modbus plc ksm
            initMbGirislerTextArea.append("if MODDATA[" + modbusInNr + "] <> MODDATA2[" + modbusInNr + "] then "
                    + tagName + "W := MODDATA[" + modbusInNr + "]; else MODDATA[" + modbusInNr + "] := " + tagName
                    + "W; end_if;\n");
        }
        plcGlobalLabel.setText("Dijital Global Deikenler " + digitalTagCount + " Adet");

        //GIRISLER stl dosyas ierii
        if (tagName.equals("YEDEK") | tagName.contains("ON_FB") | tagName.contains("OFF_FB")) {
        } else {
            girislerTextArea.append("(* " + tagIO + " - " + tagName + " - " + tagComment + " *)\n");
            girislerTextArea.append(
                    "DIGIN_FB_1(FIZ_INP := " + tagIO + ", INP_WORD := " + tagName + "W, AL_RST := ALRST);\n");
            girislerTextArea.append(tagName + "W := DIGIN_FB_1.INP_WORD;\n");
            girislerTextArea.append(tagName + " := DIGIN_FB_1.LOG_OUT;\n\n\n");
        }

        //Visu OPC tag listesi
        if (tagName.equals("YEDEK") | tagName.contains("ON_FB") | tagName.contains("OFF_FB")) {
        } else {
            visuOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "W\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "W</ItemID>\t</OPCItem>\t\t" + "\n");

            //Visu Var deikenleri
            visuVarTextArea.append(
                    "\t\t<Variable(Tag)>   <Name Type=\"4\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagIO + " - " + tagComment + "\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "W</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
        }

        //ESA tag listesi
        if (tagName.equals("YEDEK") | tagName.contains("ON_FB") | tagName.contains("OFF_FB")) {
        } else {
            HSSFRow trow = esaWb.getSheet("Tags").createRow(esaRowNr);
            trow.createCell(0).setCellValue("");
            trow.createCell(1).setCellValue(tagName + "W");
            trow.createCell(2).setCellValue("Device");
            trow.createCell(3).setCellValue(modbusMasterName);
            trow.createCell(4).setCellValue("FC 03-16: read/write registers");
            trow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusInNr));
            trow.createCell(6).setCellValue("Word");
            trow.createCell(7).setCellValue("False");
            trow.createCell(8).setCellValue("Integer");
            trow.createCell(9).setCellValue("Class_0_5: 500 msec");
            trow.createCell(10).setCellValue(tagComment);
            trow.createCell(11).setCellValue(0);
            trow.createCell(12).setCellValue("");
            esaRowNr++;
        }

        //ESA Scriptler
        if (tagName.equals("YEDEK") | tagName.contains("ON_FB") | tagName.contains("OFF_FB")) {
        } else {
            esaScriptTextArea.append("\tCase " + modbusInNr + "\n\t\tnom = \"" + tagName + "W\"\n\t\tdesc = \""
                    + tec(tagComment) + "\"\n\n");
        }

        modbusInNr++;
    }

    //feedback bulmak iin
    private static int findRow(HSSFSheet sheet, String cellContent) {
        /*
         *  This is the method to find the row number
         */

        int rowNum = 0;

        for (Row row : sheet) {
            for (Cell cell : row) {
                if (cell.toString().equals(cellContent)) {
                    rowNum = row.getRowNum();
                    return rowNum;
                }
            }
        }
        return rowNum;
    }

    //Kaytl OPC adlarndan liste seimi
    private String getOpcName() {
        List opcNames = new ArrayList();
        File dir = new File("C:\\Users\\Public\\Documents\\OPC-Server\\OpcProject");
        File[] filesList = dir.listFiles();
        for (File file : filesList) {
            if (file.isFile()) {
                opcNames.add(file.getName().replace(".opc", ""));
            }
        }
        JComboBox jcb = new JComboBox(opcNames.toArray());
        jcb.setEditable(true);
        JOptionPane.showMessageDialog(null, jcb, "Hangi OPC Kullanlacak?", JOptionPane.QUESTION_MESSAGE);
        return (jcb.getSelectedItem().toString());
    }

    //ESA tag import dosyasnn balklar ksm
    private void fillEsaWb() {
        esaWb.createSheet("Tags");
        esaWb.getSheet("Tags").createRow(0).createCell(0).setCellValue("ESAPOLYMATH");
        esaWb.getSheet("Tags").createRow(2).createCell(0).setCellValue(0);
        for (int i = 9; i < 11; i++) {
            HSSFRow row = esaWb.getSheet("Tags").createRow(i);
            row.createCell(0).setCellValue("Folder Name");
            row.createCell(1).setCellValue("Name");
            row.createCell(2).setCellValue("TypeOfAddress");
            row.createCell(3).setCellValue("Device");
            row.createCell(4).setCellValue("Memory address");
            row.createCell(5).setCellValue("Address");
            row.createCell(6).setCellValue("Data area type");
            row.createCell(7).setCellValue("Signed");
            row.createCell(8).setCellValue("Type");
            row.createCell(9).setCellValue("Group");
            row.createCell(10).setCellValue("Comment");
            row.createCell(11).setCellValue("Value");
            row.createCell(12).setCellValue("Source");
        }
        esaRowNr = 11;
    }

    private String getModbusName() {
        List modbusNames = new ArrayList();
        modbusNames.add("ModbusMaster_40");
        modbusNames.add("ModbusMaster_41");
        modbusNames.add("ModbusMaster_42");
        modbusNames.add("ModbusMaster_43");
        JComboBox jcb = new JComboBox(modbusNames.toArray());
        jcb.setEditable(true);
        JOptionPane.showMessageDialog(null, jcb, "Modbus Master Seiniz", JOptionPane.QUESTION_MESSAGE);
        return (jcb.getSelectedItem().toString());
    }

    private void fillEsaAWb() {
        esaAWb.createSheet("Alarms");
        esaAWb.getSheet("Alarms").createRow(0).createCell(0).setCellValue("ESAPOLYMATH");
        esaAWb.getSheet("Alarms").createRow(2).createCell(0).setCellValue(0);
        for (int i = 9; i < 11; i++) {
            HSSFRow row = esaAWb.getSheet("Alarms").createRow(i);
            row.createCell(0).setCellValue("Folder Name");
            row.createCell(1).setCellValue("Name");
            row.createCell(2).setCellValue("Activation Type");
            row.createCell(3).setCellValue("Tag");
            row.createCell(4).setCellValue("Priority");
            row.createCell(5).setCellValue("Description:Turkish (Turkey)");
            row.createCell(6).setCellValue("Automatic bit reset");
        }
        esaARowNr = 11;
    }

    private void analogInput(HSSFRow row) {

        // Global deiken tanmlar
        String tagName = row.getCell(1).toString();
        String tagComment = row.getCell(2).toString();
        String tagIO = row.getCell(3).toString();
        analogTagCount++;
        if (analogTagCount == 1) {
            String header = "(*     #     #    #     #     #        ###      ###    *)\n"
                    + "(*    ###    ##   #    ###    #       #   #    #   #   *)\n"
                    + "(*   #   #   # #  #   #   #   #      #     #  #        *)\n"
                    + "(*   #   #   #  # #   #   #   #      #     #  #  ###   *)\n"
                    + "(*  #######  #   ##  #######  #       #   #    #   #   *)\n"
                    + "(*  #     #  #    #  #     #  #####    ###      ###    *)\n\n\n\n";
            girislerAnalogTextArea.append(header);
            cikislarAnalogTextArea.append(header);
        }
        //IO noktas iin
        plcAnalogGlobalTextArea
                .append(tagIO + "\tWORD\tVAR_GLOBAL\t" + tagName + "\t\t\t0\t0\t0\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
        //dier plc globaller
        if (tagName.equals("YEDEK")) {
        } else {
            analogTagCount++;
            plcAnalogGlobalTextArea.append(tagName + "_YVAL\tREAL\tVAR_GLOBAL\t" + tec(tagComment)
                    + " manual degeri\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
            analogTagCount++;
            plcAnalogGlobalTextArea.append(tagName + "\tREAL\tVAR_GLOBAL\t" + tec(tagComment)
                    + "\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
            analogTagCount++;
            plcAnalogGlobalTextArea.append(tagName + "_MAN\tBOOL\tVAR_GLOBAL\t" + tec(tagComment)
                    + " manual mod\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");

            //modbus plc ksm
            initAnalogMbGirislerTextArea.append("if MODDATA[" + (modbusAnalogInNr + 1000) + "] <> MODDATA2["
                    + (modbusAnalogInNr + 1000) + "] then " + tagName + "_MAN := MODDATA["
                    + (modbusAnalogInNr + 1000) + "].X0 ; else MODDATA[" + (modbusAnalogInNr + 1000) + "].X0 := "
                    + tagName + "_MAN; end_if;\n");
            initAnalogMbGirislerTextArea.append("if (MODDATA[" + (modbusAnalogInNr + 500) + "] <> MODDATA2["
                    + (modbusAnalogInNr + 500) + "]) or (MODDATA[" + (modbusAnalogInNr + 501) + "] <> MODDATA2["
                    + (modbusAnalogInNr + 501) + "]) then\n");
            initAnalogMbGirislerTextArea.append(
                    "\t" + tagName + "_YVAL := DWORD_TO_REAL(WORD_TO_DWORD(MODDATA[" + (modbusAnalogInNr + 501)
                            + "]) + SHL(WORD_TO_DWORD(MODDATA[" + (modbusAnalogInNr + 500) + "]),16)) / 10.0;\n");
            initAnalogMbGirislerTextArea.append("else\n\tTEMPDW := REAL_TO_DWORD(" + tagName
                    + "_YVAL * 10.0);\n\tMODDATA[" + (modbusAnalogInNr + 501) + "] := DWORD_TO_WORD(TEMPDW);\n"
                    + "\tMODDATA[" + (modbusAnalogInNr + 500) + "] := DWORD_TO_WORD(SHR(TEMPDW,16));\nend_if;\n\n");
        }
        plcAnalogGlobalLabel.setText("Analog Global Deikenler " + analogTagCount + " Adet");

        //GIRISLER stl dosyas ierii
        if (tagName.equals("YEDEK")) {
        } else {
            girislerAnalogTextArea.append("(* " + tagIO + " - " + tagName + " - " + tec(tagComment) + " *)\n");
            girislerAnalogTextArea.append("ANIN_FB_1(ANALOG_INP := " + tagIO
                    + ",ANL_MIN:=word#0,ANL_MAX:=word#30000,SCL_MIN:=0.0,\n" + "          SCL_MAX:=100.0,MANUAL:="
                    + tagName + "_MAN,YVAL:=" + tagName + "_YVAL);\n");
            girislerAnalogTextArea.append(tagName + " :=ANIN_FB_1.SCL_VAL;\n\n");
            girislerAnalogTextArea.append("TEMPDW := REAL_TO_DWORD(" + tagName + " * 10.0);\n");
            girislerAnalogTextArea.append("MODDATA[" + (modbusAnalogInNr + 1) + "] := DWORD_TO_WORD(TEMPDW);\n");
            girislerAnalogTextArea
                    .append("MODDATA[" + modbusAnalogInNr + "] := DWORD_TO_WORD(SHR(TEMPDW,16));\n\n\n\n");
        }

        //Visu OPC tag listesi
        if (tagName.equals("YEDEK")) {
        } else {
            visuAnalogOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "</ItemID>\t</OPCItem>\t\t" + "\n");
            visuAnalogOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "_MAN\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "_MAN</ItemID>\t</OPCItem>\t\t" + "\n");
            visuAnalogOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "_YVAL\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "_YVAL</ItemID>\t</OPCItem>\t\t" + "\n");

            //Visu Var deikenleri
            visuAnalogVarTextArea.append(
                    "\t\t<Variable(Tag)>\t<Name Type=\"7\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagIO + " - " + tagComment + "\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
            visuAnalogVarTextArea.append(
                    "\t\t<Variable(Tag)>\t<Name Type=\"0\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagComment + " manual biti\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "_MAN</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
            visuAnalogVarTextArea.append(
                    "\t\t<Variable(Tag)>\t<Name Type=\"7\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagComment + " manual deer\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "_YVAL</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
        }

        //ESA tag listesi
        if (tagName.equals("YEDEK")) {
        } else {
            HSSFRow tagRow = esaAnalogWb.getSheet("Tags").createRow(esaAnalogRowNr);
            tagRow.createCell(0).setCellValue("");
            tagRow.createCell(1).setCellValue(tagName);
            tagRow.createCell(2).setCellValue("Device");
            tagRow.createCell(3).setCellValue(modbusMasterName);
            tagRow.createCell(4).setCellValue("FC 03-16: read/write registers");
            tagRow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusAnalogInNr));
            tagRow.createCell(6).setCellValue("Dword");
            tagRow.createCell(7).setCellValue("Real");
            tagRow.createCell(8).setCellValue("Class_0_5: 500 msec");
            tagRow.createCell(9).setCellValue(tagComment);
            tagRow.createCell(10).setCellValue("Linear");
            tagRow.createCell(11).setCellValue("0");
            tagRow.createCell(12).setCellValue("10000");
            tagRow.createCell(13).setCellValue("0");
            tagRow.createCell(14).setCellValue("1000");
            esaAnalogRowNr++;
            // YVAL tag
            tagRow = esaAnalogWb.getSheet("Tags").createRow(esaAnalogRowNr);
            tagRow.createCell(0).setCellValue("");
            tagRow.createCell(1).setCellValue(tagName + "_YVAL");
            tagRow.createCell(2).setCellValue("Device");
            tagRow.createCell(3).setCellValue(modbusMasterName);
            tagRow.createCell(4).setCellValue("FC 03-16: read/write registers");
            tagRow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusAnalogInNr + 500));
            tagRow.createCell(6).setCellValue("Dword");
            tagRow.createCell(7).setCellValue("Real");
            tagRow.createCell(8).setCellValue("Class_0_5: 500 msec");
            tagRow.createCell(9).setCellValue(tagComment + " manual deer");
            tagRow.createCell(10).setCellValue("Linear");
            tagRow.createCell(11).setCellValue("0");
            tagRow.createCell(12).setCellValue("10000");
            tagRow.createCell(13).setCellValue("0");
            tagRow.createCell(14).setCellValue("1000");
            esaAnalogRowNr++;
            // MAN tag
            tagRow = esaAnalogWb.getSheet("Tags").createRow(esaAnalogRowNr);
            tagRow.createCell(0).setCellValue("");
            tagRow.createCell(1).setCellValue(tagName + "_MAN");
            tagRow.createCell(2).setCellValue("Device");
            tagRow.createCell(3).setCellValue(modbusMasterName);
            tagRow.createCell(4).setCellValue("FC 03-16: read/write registers");
            tagRow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusAnalogInNr + 1000));
            tagRow.createCell(6).setCellValue("Word");
            tagRow.createCell(7).setCellValue("Integer");
            tagRow.createCell(8).setCellValue("Class_0_5: 500 msec");
            tagRow.createCell(9).setCellValue(tagComment + " manual biti");
            tagRow.createCell(10).setCellValue("None");
            tagRow.createCell(11).setCellValue("");
            tagRow.createCell(12).setCellValue("");
            tagRow.createCell(13).setCellValue("");
            tagRow.createCell(14).setCellValue("");
            esaAnalogRowNr++;
        }

        //ESA Scriptler
        if (tagName.equals("YEDEK")) {
        } else {
            esaAnalogScriptTextArea.append("\tCase " + modbusAnalogInNr + "\n\t\tnom = \"" + tagName
                    + "\"\n\t\tdesc = \"" + tec(tagComment) + "\"\n");
        }

        modbusAnalogInNr += 2;
    }

    private void analogOutput(HSSFRow row) {

        // Global deiken tanmlar
        String tagName = row.getCell(1).toString();
        String tagComment = row.getCell(2).toString();
        String tagIO = row.getCell(3).toString();
        analogTagCount++;
        if (analogTagCount == 1) {
            String header = "(*     #     #    #     #     #        ###      ###    *)\n"
                    + "(*    ###    ##   #    ###    #       #   #    #   #   *)\n"
                    + "(*   #   #   # #  #   #   #   #      #     #  #        *)\n"
                    + "(*   #   #   #  # #   #   #   #      #     #  #  ###   *)\n"
                    + "(*  #######  #   ##  #######  #       #   #    #   #   *)\n"
                    + "(*  #     #  #    #  #     #  #####    ###      ###    *)\n\n\n\n";
            girislerAnalogTextArea.append(header);
            cikislarAnalogTextArea.append(header);
        }
        //IO noktas iin
        plcAnalogGlobalTextArea
                .append(tagIO + "\tWORD\tVAR_GLOBAL\t" + tagName + "\t\t\t0\t0\t0\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
        //dier plc globaller
        if (tagName.equals("YEDEK")) {
        } else {
            analogTagCount++;
            plcAnalogGlobalTextArea.append(tagName + "_YVAL\tREAL\tVAR_GLOBAL\t" + tec(tagComment)
                    + " manual degeri\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
            analogTagCount++;
            plcAnalogGlobalTextArea.append(tagName + "\tREAL\tVAR_GLOBAL\t" + tec(tagComment)
                    + "\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");
            analogTagCount++;
            plcAnalogGlobalTextArea.append(tagName + "_MAN\tBOOL\tVAR_GLOBAL\t" + tec(tagComment)
                    + " manual mod\t\t\t0\t0\t1\t0\t0\t0\t\t0\t0\t\t\t\t\t0\t\n");

            //modbus plc ksm
            initAnalogMbCikislarTextArea.append("if MODDATA[" + (modbusAnalogOutNr + 1000) + "] <> MODDATA2["
                    + (modbusAnalogOutNr + 1000) + "] then " + tagName + "_MAN := MODDATA["
                    + (modbusAnalogOutNr + 1000) + "].X0 ; else MODDATA[" + (modbusAnalogOutNr + 1000) + "].X0 := "
                    + tagName + "_MAN; end_if;\n");
            initAnalogMbCikislarTextArea.append("if (MODDATA[" + (modbusAnalogOutNr + 500) + "] <> MODDATA2["
                    + (modbusAnalogOutNr + 500) + "]) or (MODDATA[" + (modbusAnalogOutNr + 501) + "] <> MODDATA2["
                    + (modbusAnalogOutNr + 501) + "]) then\n");
            initAnalogMbCikislarTextArea.append(
                    "\t" + tagName + "_YVAL := DWORD_TO_REAL(WORD_TO_DWORD(MODDATA[" + (modbusAnalogOutNr + 501)
                            + "]) + SHL(WORD_TO_DWORD(MODDATA[" + (modbusAnalogOutNr + 500) + "]),16)) / 10.0;\n");
            initAnalogMbCikislarTextArea
                    .append("else\n\tTEMPDW := REAL_TO_DWORD(" + tagName + "_YVAL * 10.0);\n\tMODDATA["
                            + (modbusAnalogOutNr + 501) + "] := DWORD_TO_WORD(TEMPDW);\n" + "\tMODDATA["
                            + (modbusAnalogOutNr + 500) + "] := DWORD_TO_WORD(SHR(TEMPDW,16));\nend_if;\n\n");
        }
        plcAnalogGlobalLabel.setText("Analog Global Deikenler " + analogTagCount + " Adet");

        //CIKISLAR stl dosyas ierii
        if (tagName.equals("YEDEK")) {
        } else {
            cikislarAnalogTextArea.append("(* " + tagIO + " - " + tagName + " - " + tec(tagComment) + " *)\n");
            cikislarAnalogTextArea.append(
                    "ANOUT_FB_1(ANL_MIN:=word#0,ANL_MAX:=word#30000,SCL_MIN:=0.0,\n" + "   SCL_MAX:=100.0,MANUAL:="
                            + tagName + "_MAN,YVAL:=" + tagName + "_YVAL,SCL_INP:=" + tagName + ");\n");
            cikislarAnalogTextArea.append(tagIO + " := ANOUT_FB_1.ANL_OUT;\n\n");
            cikislarAnalogTextArea.append("TEMPDW := REAL_TO_DWORD(" + tagName + " * 10.0);\n");
            cikislarAnalogTextArea.append("MODDATA[" + (modbusAnalogOutNr + 1) + "] := DWORD_TO_WORD(TEMPDW);\n");
            cikislarAnalogTextArea
                    .append("MODDATA[" + modbusAnalogOutNr + "] := DWORD_TO_WORD(SHR(TEMPDW,16));\n\n\n\n");
        }

        //Visu OPC tag listesi
        if (tagName.equals("YEDEK")) {
        } else {
            visuAnalogOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "</ItemID>\t</OPCItem>\t\t" + "\n");
            visuAnalogOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "_MAN\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "_MAN</ItemID>\t</OPCItem>\t\t" + "\n");
            visuAnalogOpcTextArea.append("\t\t<OPCItem>\t<ItemID AccessPath=\"\" VTType=\"0\" Variable=\"" + tagName
                    + "_YVAL\" EnableWrite=\"1\" EnableRead=\"1\" SyncDataStartup=\"0\" SyncWrite=\"1\" ReRead=\"0\">"
                    + opcName + "." + tagName + "_YVAL</ItemID>\t</OPCItem>\t\t" + "\n");

            //Visu Var deikenleri
            visuAnalogVarTextArea.append(
                    "\t\t<Variable(Tag)>\t<Name Type=\"7\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagIO + " - " + tagComment + "\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
            visuAnalogVarTextArea.append(
                    "\t\t<Variable(Tag)>\t<Name Type=\"0\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagComment + " manual biti\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "_MAN</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
            visuAnalogVarTextArea.append(
                    "\t\t<Variable(Tag)>\t<Name Type=\"7\" AreaType=\"1\" Address=\"0\" Bit=\"0\" Description=\""
                            + tagComment + " manual deer\" Shared=\"0\" Retentive=\"0\" InitQuality=\"192\">"
                            + tagName + "_YVAL</Name>\t<EnableTrace DurationDays=\"730\">0</EnableTrace>\t"
                            + "<EnableOPCServer>0</EnableOPCServer>\t<EnableNetworkClient EnableTCPIPServer=\"1\">0</EnableNetworkClient>\t"
                            + "<EnableMapRealTimeToDB>0</EnableMapRealTimeToDB>\t" + "</Variable(Tag)>\t\t" + "\n");
        }

        //ESA tag listesi
        if (tagName.equals("YEDEK")) {
        } else {
            HSSFRow tagRow = esaAnalogWb.getSheet("Tags").createRow(esaAnalogRowNr);
            tagRow.createCell(0).setCellValue("");
            tagRow.createCell(1).setCellValue(tagName);
            tagRow.createCell(2).setCellValue("Device");
            tagRow.createCell(3).setCellValue(modbusMasterName);
            tagRow.createCell(4).setCellValue("FC 03-16: read/write registers");
            tagRow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusAnalogOutNr));
            tagRow.createCell(6).setCellValue("Dword");
            tagRow.createCell(7).setCellValue("Real");
            tagRow.createCell(8).setCellValue("Class_0_5: 500 msec");
            tagRow.createCell(9).setCellValue(tagComment);
            tagRow.createCell(10).setCellValue("Linear");
            tagRow.createCell(11).setCellValue("0");
            tagRow.createCell(12).setCellValue("10000");
            tagRow.createCell(13).setCellValue("0");
            tagRow.createCell(14).setCellValue("1000");
            esaAnalogRowNr++;
            // YVAL tag
            tagRow = esaAnalogWb.getSheet("Tags").createRow(esaAnalogRowNr);
            tagRow.createCell(0).setCellValue("");
            tagRow.createCell(1).setCellValue(tagName + "_YVAL");
            tagRow.createCell(2).setCellValue("Device");
            tagRow.createCell(3).setCellValue(modbusMasterName);
            tagRow.createCell(4).setCellValue("FC 03-16: read/write registers");
            tagRow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusAnalogOutNr + 500));
            tagRow.createCell(6).setCellValue("Dword");
            tagRow.createCell(7).setCellValue("Real");
            tagRow.createCell(8).setCellValue("Class_0_5: 500 msec");
            tagRow.createCell(9).setCellValue(tagComment + " manual deer");
            tagRow.createCell(10).setCellValue("Linear");
            tagRow.createCell(11).setCellValue("0");
            tagRow.createCell(12).setCellValue("10000");
            tagRow.createCell(13).setCellValue("0");
            tagRow.createCell(14).setCellValue("1000");
            esaAnalogRowNr++;
            // MAN tag
            tagRow = esaAnalogWb.getSheet("Tags").createRow(esaAnalogRowNr);
            tagRow.createCell(0).setCellValue("");
            tagRow.createCell(1).setCellValue(tagName + "_MAN");
            tagRow.createCell(2).setCellValue("Device");
            tagRow.createCell(3).setCellValue(modbusMasterName);
            tagRow.createCell(4).setCellValue("FC 03-16: read/write registers");
            tagRow.createCell(5).setCellValue("Address," + Integer.toHexString(modbusAnalogOutNr + 1000));
            tagRow.createCell(6).setCellValue("Word");
            tagRow.createCell(7).setCellValue("Integer");
            tagRow.createCell(8).setCellValue("Class_0_5: 500 msec");
            tagRow.createCell(9).setCellValue(tagComment + " manual biti");
            tagRow.createCell(10).setCellValue("None");
            tagRow.createCell(11).setCellValue("");
            tagRow.createCell(12).setCellValue("");
            tagRow.createCell(13).setCellValue("");
            tagRow.createCell(14).setCellValue("");
            esaAnalogRowNr++;
        }

        //ESA Scriptler
        if (tagName.equals("YEDEK")) {
        } else {
            esaAnalogScriptTextArea.append("\tCase " + modbusAnalogOutNr + "\n\t\tnom = \"" + tagName
                    + "\"\n\t\tdesc = \"" + tec(tagComment) + "\"\n");
        }

        modbusAnalogOutNr += 2;
    }

    //translate english chars - trke olanlar plc iin ingilizceye evir
    private String tec(String tagComment) {
        return (tagComment.replace("", "c").replace("", "C").replace("", "g").replace("", "G")
                .replace("", "i").replace("", "I").replace("", "o").replace("", "O").replace("", "s")
                .replace("", "S").replace("", "u").replace("", "U"));
    }

    private void fillEsaAnalogWb() {
        esaAnalogWb.createSheet("Tags");
        esaAnalogWb.getSheet("Tags").createRow(0).createCell(0).setCellValue("ESAPOLYMATH");
        esaAnalogWb.getSheet("Tags").createRow(2).createCell(0).setCellValue(0);
        for (int i = 9; i < 11; i++) {
            HSSFRow row = esaAnalogWb.getSheet("Tags").createRow(i);
            row.createCell(0).setCellValue("Folder Name");
            row.createCell(1).setCellValue("Name");
            row.createCell(2).setCellValue("TypeOfAddress");
            row.createCell(3).setCellValue("Device");
            row.createCell(4).setCellValue("Memory address");
            row.createCell(5).setCellValue("Address");
            row.createCell(6).setCellValue("Data area type");
            row.createCell(7).setCellValue("Type");
            row.createCell(8).setCellValue("Group");
            row.createCell(9).setCellValue("Comment");
            row.createCell(10).setCellValue("Conversion");
            row.createCell(11).setCellValue("X1ConversionValue");
            row.createCell(12).setCellValue("X2ConversionValue");
            row.createCell(13).setCellValue("Y1ConversionValue");
            row.createCell(14).setCellValue("Y2ConversionValue");
        }
        esaAnalogRowNr = 11;
    }

}