// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java
// public class ConnectException extends java.net.ConnectException {
//     public ConnectException(String localizedMessage) {
//         super(localizedMessage);
//     }
// }
// 
// Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java
// public interface Modbus {
// }


import com.ghgande.j2mod.modbus.util.SerialParameters;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.assemblits.eru.exception.ConnectException;
import org.assemblits.eru.fieldbus.protocols.modbus.Modbus;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Transient;
/******************************************************************************
 * Copyright (c) 2017 Assemblits contributors                                 *
 *                                                                            *
 * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. *
 *                                                                            *
 * Eru The open JavaFX SCADA is free software: you can redistribute it        *
 * and/or modify it under the terms of the GNU General Public License         *
 *  as published by the Free Software Foundation, either version 3            *
 *  of the License, or (at your option) any later version.                    *
 *                                                                            *
 * Eru is distributed in the hope that it will be useful,                     *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License          *
 * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.            *
 ******************************************************************************/
package org.assemblits.eru.entities;



@Entity
@DiscriminatorValue(value = "SERIAL")
public class SerialConnection extends Connection implements Modbus{

    private StringProperty port;
    private IntegerProperty bitsPerSeconds;
    private IntegerProperty dataBits;
    private StringProperty parity;
    private IntegerProperty stopsBits;
    private StringProperty frameEncoding;
    private com.ghgande.j2mod.modbus.net.SerialConnection coreConnection;

    public SerialConnection() {
        this.port = new SimpleStringProperty("COM1");
        this.bitsPerSeconds = new SimpleIntegerProperty(19200);
        this.dataBits = new SimpleIntegerProperty(8);
        this.parity = new SimpleStringProperty("NONE");
        this.stopsBits = new SimpleIntegerProperty(1);
        this.frameEncoding = new SimpleStringProperty("RTU");
    }

    @Override
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java
// public class ConnectException extends java.net.ConnectException {
//     public ConnectException(String localizedMessage) {
//         super(localizedMessage);
//     }
// }
// 
// Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java
// public interface Modbus {
// }


// Path: Eru/src/main/java/org/assemblits/eru/entities/SerialConnection.java
import com.ghgande.j2mod.modbus.util.SerialParameters;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.assemblits.eru.exception.ConnectException;
import org.assemblits.eru.fieldbus.protocols.modbus.Modbus;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Transient;

/******************************************************************************
 * Copyright (c) 2017 Assemblits contributors                                 *
 *                                                                            *
 * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. *
 *                                                                            *
 * Eru The open JavaFX SCADA is free software: you can redistribute it        *
 * and/or modify it under the terms of the GNU General Public License         *
 *  as published by the Free Software Foundation, either version 3            *
 *  of the License, or (at your option) any later version.                    *
 *                                                                            *
 * Eru is distributed in the hope that it will be useful,                     *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License          *
 * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.            *
 ******************************************************************************/
package org.assemblits.eru.entities;



@Entity
@DiscriminatorValue(value = "SERIAL")
public class SerialConnection extends Connection implements Modbus{

    private StringProperty port;
    private IntegerProperty bitsPerSeconds;
    private IntegerProperty dataBits;
    private StringProperty parity;
    private IntegerProperty stopsBits;
    private StringProperty frameEncoding;
    private com.ghgande.j2mod.modbus.net.SerialConnection coreConnection;

    public SerialConnection() {
        this.port = new SimpleStringProperty("COM1");
        this.bitsPerSeconds = new SimpleIntegerProperty(19200);
        this.dataBits = new SimpleIntegerProperty(8);
        this.parity = new SimpleStringProperty("NONE");
        this.stopsBits = new SimpleIntegerProperty(1);
        this.frameEncoding = new SimpleStringProperty("RTU");
    }

    @Override
    public void connect() throws ConnectException {