package cn.pda.serialport;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import cn.pda.rfid.hf.HfConmmand;
import cn.pda.rfid.hf.HfReader;

/**
 * Created by zrl on 2017/2/9.
 */

public class Main {
    private static SerialPort serialPort;
    private static HfConmmand hf;
    private static InputStream is;
    private static OutputStream os;

    public static SerialPort getSerialPort() {
        return serialPort;
    }

    public static void setSerialPort(SerialPort serialPort) {
        Main.serialPort = serialPort;
    }

    public static HfConmmand getHf() {
        return hf;
    }

    public static void setHf(HfConmmand hf) {
        Main.hf = hf;
    }

    public static InputStream getIs() {
        return is;
    }

    public static void setIs(InputStream is) {
        Main.is = is;
    }

    public static OutputStream getOs() {
        return os;
    }

    public static void setOs(OutputStream os) {
        Main.os = os;
    }

    public static void initSerialPort(){
        try {
            serialPort = new SerialPort(13,115200,0);
            is = serialPort.getInputStream();
            os = serialPort.getOutputStream();
            serialPort.rfid_poweron();
            hf = new HfReader(is,os);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void destroy(){
        serialPort.close(13);
        serialPort.rfid_poweroff();
    }
}
