/*                                                                      *\
**                    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;
    
    /**
     * Instantiates the underlying serial port with the port name associated with the given property key.
     *
     * @param key the string key used to load the port name from the 'port' properties file
     */
    AbstractSerialPort(String key) {
        properties = new Properties();
        try {
            FileInputStream inStream = new FileInputStream("port.properties");
            properties.load(inStream);
            inStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        serialPort = new SerialPort(properties.getProperty(key));
    }
    
}

@@ -1138,19 +1138,17 @@
   * 
-Instantiate
+Construct
 s th
@@ -1181,145 +1181,106 @@
 ith 
-the port name associated with the given property key.%0A     *%0A     * @param key the string key used to load the port name from the 'port' 
+properties from the specified file.%0A     *%0A     * @param filename the relative path to the %3Ccode%3E.
 prop
@@ -1285,16 +1285,23 @@
 operties
+%3C/code%3E
  file%0A  
@@ -1336,19 +1336,24 @@
 (String 
-key
+filename
 ) %7B%0A    
@@ -1464,25 +1464,16 @@
 eam(
-%22port.properties%22
+filename
 );%0A 
@@ -1657,35 +1657,843 @@
 ort(
-properties.getProperty(key)
+getPortName());%0A    %7D%0A    %0A    private String propertyValue(String key) %7B%0A        return properties.getProperty(key);%0A    %7D%0A    %0A    private int propertyValueAsInt(String key) %7B%0A        return Integer.parseInt(propertyValue(key));%0A    %7D%0A    %0A    public String getPortName() %7B%0A        return propertyValue(%22portName%22);%0A    %7D%0A    %0A    public String getNickname() %7B%0A        return propertyValue(%22nickname%22);%0A    %7D%0A    %0A    public int getBaudRate() %7B%0A        return propertyValueAsInt(%22baudRate%22);%0A    %7D%0A    %0A    public int getDataBits() %7B%0A        return propertyValueAsInt(%22dataBits%22);%0A    %7D%0A    %0A    public int getStopBits() %7B%0A        return propertyValueAsInt(%22stopBits%22);%0A    %7D%0A    %0A    public int getParity() %7B%0A        return propertyValueAsInt(%22parity%22);%0A    %7D%0A    %0A    public int getMask() %7B%0A        return propertyValueAsInt(%22mask%22
 );%0A 

Revise constructor, and add property getters