package Asf;
|
|
import art.library.model.devices.DeviceGraphicsRuntime;
|
import com.kitfox.svg.SVGDiagram;
|
import com.kitfox.svg.SVGElement;
|
|
|
public class AsfCommandsAspect extends DeviceGraphicsRuntime
|
{
|
|
public AsfCommandsAspect(art.library.model.devices.Device device, SVGDiagram diagram)
|
{
|
super(device, diagram);
|
}
|
|
public AsfCommandsAspect(art.library.model.devices.Device device, art.library.model.devices.DeviceCommands deviceCommands, SVGDiagram diagram)
|
{
|
super(device, deviceCommands, diagram);
|
}
|
|
private boolean flashOn = false;
|
public void timer()
|
{
|
flashOn = !flashOn;
|
commands();
|
}
|
public void commands()
|
{
|
art.library.model.devices.vms.asf.AsfCommands deviceCommands = (art.library.model.devices.vms.asf.AsfCommands) getDeviceCommands();
|
SVGElement arrow = getElement("arrow");
|
SVGElement cross = getElement("cross");
|
SVGElement arrowRight = getElement("arrow-right");
|
SVGElement arrowLeft = getElement("arrow-left");
|
SVGElement s52_left = getElement("s52_left");
|
SVGElement textBUS = getElement("BUS");
|
SVGElement dynamicElements = getElement("elements");
|
setAttribute("lock", "display", "inline", 999);
|
setAttribute("restart", "display", "inline", 999);
|
setAttribute("unlock", "display", "inline", 999);
|
setAttribute("lock-off", "display", "inline", 999);
|
setAttribute(dynamicElements, "display", "none", 999);
|
setAttribute(textBUS, "display", "none", 999);
|
|
SVGElement showElement = null;
|
switch (deviceCommands.state)
|
{
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_ARROW:
|
showElement = arrow;
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_CROSS:
|
showElement = cross;
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_OFF:
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_LEFT:
|
showElement = arrowLeft;
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_RIGHT:
|
showElement = arrowRight;
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_S52_LEFT:
|
showElement = s52_left;
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_BUS:
|
showElement = textBUS;
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_FLASHING_LEFT:
|
showElement = (flashOn) ? arrowLeft : null;
|
break;
|
case art.library.model.devices.vms.asf.AsfCommands.STATE_FLASHING_RIGHT:
|
showElement = (flashOn) ? arrowRight : null;
|
break;
|
}
|
if (showElement != null)
|
{
|
setAttribute(showElement, "display", "inline", 999);
|
}
|
if (deviceCommands.reset != art.library.model.devices.vms.asf.AsfCommands.CONDITION_YES)
|
{
|
setAttribute("restart", "display", "none", 999);
|
}
|
if (deviceCommands.liberate != art.library.model.devices.vms.asf.AsfCommands.CONDITION_YES)
|
{
|
setAttribute("unlock", "display", "none", 999);
|
} else
|
{
|
setAttribute("lock-off", "display", "none", 999);
|
}
|
if (deviceCommands.priority < 256)
|
{
|
setAttribute("lock", "display", "none", 999);
|
}
|
}
|
// java.io.StringWriter sw = new java.io.StringWriter();
|
// art.library.gui.flat.FlatDialog.showDialog(null, "Error", e.getMessage() + "\n\n" + sw.toString(), true, art.library.gui.flat.FlatDialog.DIALOG_ERROR);
|
//
|
}
|