Ticket #171 (closed defect: done)

Opened 7 years ago

Last modified 7 years ago

script fails on Unit tag

Reported by: jdalbey Owned by: sdanthin
Priority: High Milestone: Sep 2019 Training
Component: ScriptBuilder Model Version:
Severity: Minor Keywords:
Cc:

Description

Using ScriptBuilder I created this simple script with one Unit tag.

<TMC_SCRIPT title=""><SCRIPT_EVENT><TIME_INDEX>00:00:00</TIME_INDEX>
<INCIDENT LogNum="201">Incident201</INCIDENT>
<COLOR r="0" g="0" b="0"/>
<CAD_DATA><HEADER_INFO><Type>DEFAULT</Type>
<Beat></Beat>
<TruncLoc>Default Location (short)</TruncLoc>
<FullLoc>Default Location (long)</FullLoc>
</HEADER_INFO>
<CAD_INCIDENT_EVENT><DETAIL>Sample CAD Log entry</DETAIL>
<UNIT UnitNum="5-5" Status="1098" Primary="True" Active="True"/>
</CAD_INCIDENT_EVENT>
</CAD_DATA>
</SCRIPT_EVENT>
</TMC_SCRIPT>

When running this Script in Simulation Manager it causes the CAD server to throw an exception:

Exception in thread "Thread-12" java.lang.NullPointerException
	at tmcsim.client.cadclientgui.data.CADData.unitAvailable(CADData.java:402)
	at tmcsim.cadsimulator.Coordinator.updateUnitsInGUI(Coordinator.java:2540)
	at tmcsim.cadsimulator.Coordinator.updateIncidentInGUI(Coordinator.java:2483)
	at tmcsim.cadsimulator.managers.IncidentManager.tick(IncidentManager.java:251)
	at tmcsim.cadsimulator.Coordinator$5.run(Coordinator.java:721)
	at java.lang.Thread.run(Thread.java:748)

Examining the source code, I see the exception is caused when the unit name is looked up and returns null. I assume this is because the script doesn't contain any unit definitions. When I add the following unit definition to the script it no longer fails.

	<SCRIPT_DATA>
		<NEW_UNIT UnitNum = "5-5">
			<STATUS>10-8</STATUS>
			<TIMER>9999</TIMER>
			<AGY>CHP</AGY>
			<ALIAS></ALIAS>
			<UNIT_STATUS>Assignable</UNIT_STATUS>
		</NEW_UNIT>
	</SCRIPT_DATA>

So I think Unit Definitions need to be added to the scripts that are created. Probably the simplest solution is to create a static file containing a big list of unit definitions and automatically insert them when the script is written to a file. (However the user might create a UNIT tag with a unit number that doesn't exist in the file of unit definitions -- but for now let's assume that won't happen).

  1. A better solution would be to restrict the user's choice of unit numbers via a combo box that contains only units from the definition file.
  2. Another strategy is have the Script Builder automatically insert a "dummy" Unit definition whenever a unit tag is created for a non-existing unit number.
  3. Another approach would be a kind of "wizard" that appears as the script is saved which finds all unit numbers from tags in the script and guides the user through creating unit definitions.
  4. Another approach would be to build a new form in the GUI that allows the user to create Unit Definitions.

Change History

comment:1 Changed 7 years ago by sdanthin

Unit is now only selected from a file that is pre-loaded with UNIT definitions, ensuring for all of the units to be already accounted for when added to the file. Strategy 1 is used.

comment:2 Changed 7 years ago by jdalbey

  • Status changed from new to closed
  • Resolution set to done

fixed in development version.

Note: See TracTickets for help on using tickets.