public static void main(String... args) throws Exception
{
boolean understood = false;
if (args.length > 0)
{
StatusSender sender = StatusSender.getInstance();
sender.startConnection();
if ("startSession".equals(args[0]))
{
understood = true;
sender.startSession();
}
else if ("sendHeartbeat".equals(args[0]))
{
for (int a=1; a < args.length; a++)
{
for (Spoke spoke : spokes.values())
{
if (spoke.getLocation().equalsIgnoreCase(args[a]))
{
understood = true;
spoke.heartbeat();
}
}
}
}
else if ("populateInventory".equals(args[0]))
{
understood = true;
for (Spoke spoke : spokes.values())
{
for (Part part : spoke.getParts())
{
part.adjust(random(10));
}
}
}
else if ("incrementPart".equals(args[0]))
{
understood = adjustPart(args, true);
}
else if ("decrementPart".equals(args[0]))
{
understood = adjustPart(args, false);
}
else if ("stopSession".equals(args[0]))
{
understood = true;
sender.stopSession();
}
sender.stopConnection();
}
if (!understood)
{
throw new Exception("could not understand command [" + args + "]");
}