Silicon Junction Logo dcc @ silicon junction

PC Front End

The PC Front End provides a user interface on a laptop/desktop and communicates with the DCC command station through the USB port. The front end is written in java. The previous version was written in swing. I did not like this development environment and in this version the program acts as a mini web server and provides the user interface on a standard browser. This moves all the user interface design into the web world of HTML and javascript.

Software Deign

All communication with the program is as a series of URL requests. These requests are usually made as ajax calls in response to some user action. The program responds to the request and at the same time sends commands to the command station on the USB port. A windows driver simulates a serial port on the USB port.

Layout Configuration

The program holds the layout configuration in an XML file and serves the information to the browser. The javascript in the browser then constructs the user interface based on this configuration. This makes the user interface dynamic and configurable easily using a config file.A sample layout configuration XML file is shown below.

<?xml version="1.0"?>

<!DOCTYPE Layout SYSTEM "layout.dtd">

<Layout>
  <Port port="COM5" baud="9600"/>
  <Devices>
    <Loco address="3" name="Just another one" number="1123"/>
    <Loco address="4" name="Still another one" number="1145"/>
    <Loco address="5" name="One more" number="1166"/>
    <Turnout address="130" slot="0" number="M1"/>
    <Turnout address="130" slot="1" number="M2"/>
    <Turnout address="130" slot="2" number="S1"/>
    <Turnout address="130" slot="3" number="S2"/>
    <Turnout address="131" slot="0" number="S3"/>
  </Devices>
  <LayoutPic icon="layout.gif">
    <LocoPic number="1123" icon="blkwidw.gif"/>
    <LocoPic number="1145" icon="daylit.gif"/>
    <LocoPic number="1166" icon="daylit.gif"/>
    <TurnoutPic number="M1" x="388" y="100"
      offsetx="-0" offsety="-40" align="_LD_D"/>
    <TurnoutPic number="M2" x="607" y="325"
      offsetx="-0" offsety="-265" align="_RU_U"/>
    <TurnoutPic number="S1" x="448" y="163"
      offsetx="-0" offsety="-103" align="i_UR_R"/>
    <TurnoutPic number="S2" x="510" y="225"
      offsetx="-0" offsety="-165" align="i_UR_R"/>
    <TurnoutPic number="S3" x="548" y="263"
      offsetx="-0" offsety="-203" align="i_DL_L"/>
  </LayoutPic>
</Layout>
		

User Interface Design


User Interface

The user interface has the following elements.

  • Loco Control - Allows the speed to be increased, descreased or the loco to be halted. The change in speed is in 10% steps. The current speed is displayed. To help identify the loco, an icon, a number and a description is also displayed.
  • Layout Schematic - A schematic of the layout is displayed.
  • Turnout Control - The image of the turnout is superimposed on the layout schematic. Controls allow the position of the turnout to be changed. The change is indicated on the schematic.
  • Command Buttons - These buttons are arranged on top. So far they haven't been fully implemented yet. The first is an emergency stop button. This brings the entire layout ot a halt, possibly by shutting off all power. The second is the Program Button used for programnming decoders using the DCC Service Mode. The third is the Layout Config button that allows the layout to be configured using the user interface rather than a config file.

Request URLs

There are two sets of URL requests. One set is used to get information about the layout configuration that help paint the user interface. The other set is to control the devices on the layout like locos and turnouts. A future version will have support for programming decoders using the DCC service mode. URLs for all three types are listed below.

cmd.cgi?f=lc
Get no. of locos
Response:
  count
cmd.cgi?f=tc
Get no. of turnouts
Response;
  count
cmd.cgi?f=ld&i=<n>
Get details of loco n
Response:
  L|index|code|desc|decoder addr|icon|speed
cmd.cgi?f=td&i=<n>
Get details of turnout n
Response:
  T|index|code|desc|dec addr|icon|status|scrX|scrY|offX|offY
    Status - Y is straight thru or left for wye
    scrX, scrY - position of turnout icon on layout
    offX, offY - relative position of controls
cmd.cgi?f=ls&i=<n>&v=<U/D/0/s>
Set speed of loco n
  U - increase speed by 10% approx
  D - Decrease speed by 10% approx
  0 - Stop
  s - Speed as a percent
Response:
  L|index|new speed
cmd.cgi?f=ts&i=<n>&v=<status>
Set position of turnout n to status
Response:
  T|index|new status
prog.cgi?f=cr&i=<n>
Read CV i in hex
Response:
  C|CV No.|value
prog.cgi?f=cw&i=<n>&v=<val>
Write CV i with value val
Response:
  Status
    Status is Y if ack received and N otherwise
feedback to feedback email