001package jmri.jmris.srcp; 002 003import java.io.IOException; 004import java.io.OutputStream; 005 006import jmri.ProgListener; 007import jmri.jmris.AbstractProgrammerServer; 008import org.slf4j.Logger; 009import org.slf4j.LoggerFactory; 010 011/** 012 * SRCP interface between the JMRI service mode programmer and a network 013 * connection 014 * 015 * @author Paul Bender Copyright (C) 2012 016 */ 017public class JmriSRCPProgrammerServer extends AbstractProgrammerServer { 018 019 private OutputStream output; 020 021 public JmriSRCPProgrammerServer(OutputStream outStream) { 022 output = outStream; 023 } 024 025 026 /* 027 * Protocol Specific Abstract Functions 028 */ 029 @Override 030 public void sendStatus(int CV, int value, int status) throws IOException { 031 if (log.isDebugEnabled()) { 032 log.debug("sendStatus called for CV {} with value {} and status {}",CV,value,status); 033 } 034 if (status == ProgListener.OK) { 035 output.write(("100 INFO 1 SM " + CV + " CV " + value + "\n\r").getBytes()); 036 } else { 037 output.write(Bundle.getMessage("Error416").getBytes()); 038 } 039 } 040 041 @Override 042 public void sendNotAvailableStatus() throws IOException { 043 output.write(Bundle.getMessage("Error499").getBytes()); 044 } 045 046 @Override 047 public void parseRequest(String statusString) throws jmri.JmriException, java.io.IOException { 048 // SRCP requests are parsed through the common parser. 049 } 050 051 private static final Logger log = LoggerFactory.getLogger(JmriSRCPProgrammerServer.class); 052 053}