/*                                                                      *\
**                    SICU Stress Measurement System                    **
**                      Project P04  |  C380 Team A                     **
**          EBME 380: Biomedical Engineering Design Experience          **
**                    Case Western Reserve University                   **
**                          2016 Fall Semester                          **
\*                                                                      */

package edu.cwru.sicu_sms.util;

import jssc.SerialPort;
import jssc.SerialPortEventListener;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * This class is an abstraction of a serial port comprising all the necessary parameters and core functionality needed for the client application.
 *
 * @since December 12, 2016
 * @author Ted Frohlich <ttf10@case.edu>
 * @author Abby Walker <amw138@case.edu>
 */
abstract class AbstractSerialPort implements SerialPortEventListener {
    
    final SerialPort serialPort;
    final Properties properties;
    
    /**
     * Constructs the underlying serial port with properties from the specified file.
     *
     * @param filename the relative path to the <code>.properties</code> file
     */
    AbstractSerialPort(String filename) {
        properties = new Properties();
        try {
            FileInputStream inStream = new FileInputStream(filename);
            properties.load(inStream);
            inStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        serialPort = new SerialPort(getPortName());
    }
    
    private String propertyValue(String key) {
        return properties.getProperty(key);
    }
    
    private int propertyValueAsInt(String key) {
        return Integer.parseInt(propertyValue(key));
    }
    
    public String getPortName() {
        return propertyValue("portName");
    }
    
    public String getNickname() {
        return propertyValue("nickname");
    }
    
    public int getBaudRate() {
        return propertyValueAsInt("baudRate");
    }
    
    public int getDataBits() {
        return propertyValueAsInt("dataBits");
    }
    
    public int getStopBits() {
        return propertyValueAsInt("stopBits");
    }
    
    public int getParity() {
        return propertyValueAsInt("parity");
    }
    
    public int getMask() {
        return propertyValueAsInt("mask");
    }
    
}

@@ -1699,29 +1699,27 @@
  String 
-p
+getP
 roperty
-Value
 (String 
@@ -1796,29 +1796,27 @@
 ate int 
-p
+getP
 roperty
-Value
 AsInt(St
@@ -1859,29 +1859,27 @@
 arseInt(
-p
+getP
 roperty
-Value
 (key));%0A
@@ -1938,29 +1938,27 @@
  return 
-p
+getP
 roperty
-Value
 (%22portNa
@@ -2023,29 +2023,27 @@
  return 
-p
+getP
 roperty
-Value
 (%22nickna
@@ -2101,37 +2101,35 @@
      return 
-p
+getP
 roperty
-Value
 AsInt(%22baudR
@@ -2188,37 +2188,35 @@
      return 
-p
+getP
 roperty
-Value
 AsInt(%22dataB
@@ -2275,37 +2275,35 @@
      return 
-p
+getP
 roperty
-Value
 AsInt(%22stopB
@@ -2360,37 +2360,35 @@
      return 
-p
+getP
 roperty
-Value
 AsInt(%22parit
@@ -2449,21 +2449,19 @@
 urn 
-p
+getP
 roperty
-Value
 AsIn

Rename private getters with 'get' prefix for clarity when later adding setters