package art.servers.etdserver;
|
|
import art.library.model.devices.etd.Etd;
|
import art.library.model.devices.etd.information.EtdInformationSection;
|
import art.library.model.devices.etd.status.EtdStatusLane;
|
import art.servers.etdserver.controller.ControllerDPS;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
|
public class Shared extends art.servers.Shared
|
{
|
public static List<ControllerDPS> lcontrollerDPS = new ArrayList<ControllerDPS>();
|
public static boolean logDPS = false;
|
public static String deviceLog = null;
|
public static String etdLog = null;
|
public static boolean testVigicat = false;
|
|
|
public static Model getModel()
|
{
|
return (art.servers.etdserver.Model)model;
|
}
|
|
|
public static ControllerDPS getControllerDPS (String identifier)
|
{
|
for (ControllerDPS controller : lcontrollerDPS)
|
{
|
if (controller.getConfigurationDPS().identifier.equalsIgnoreCase(identifier) == true)
|
return(controller);
|
}
|
|
return(null);
|
}
|
|
|
public static void setSectionsData (Etd etdData)
|
{
|
try
|
{
|
List<EtdStatusLane> lstatusSection = etdData.getDeviceStatus().lsection;
|
for (EtdStatusLane sectionStatus : lstatusSection)
|
{
|
EtdInformationSection sectionInformation = etdData.getDeviceInformation().getSection(sectionStatus.number);
|
int I = 0;
|
int V = 0;
|
int O = 0;
|
int NC = 0;
|
for (Integer lane : sectionInformation.llane)
|
{
|
EtdStatusLane laneStatus = etdData.getDeviceStatus().getLane(lane.intValue());
|
I = I + laneStatus.counting;
|
V = V + (laneStatus.counting*(int)laneStatus.speed);
|
O = O + (laneStatus.counting*(int)laneStatus.occupancy);
|
NC = NC + laneStatus.unclassified;
|
|
for (int l=0; l<sectionStatus.lengths.length; l++)
|
{
|
try
|
{
|
sectionStatus.lengths[l] = sectionStatus.lengths[l] + laneStatus.lengths[l];
|
}
|
catch (Exception e)
|
{
|
|
}
|
}
|
|
for (int l=0; l<sectionStatus.speeds.length; l++)
|
{
|
try
|
{
|
sectionStatus.speeds[l] = sectionStatus.speeds[l] + laneStatus.speeds[l];
|
}
|
catch (Exception e)
|
{
|
|
}
|
}
|
|
for (int l=0; l<sectionStatus.speedxlength.length; l++)
|
{
|
for (int s=0; s<sectionStatus.speedxlength[l].length; s++)
|
{
|
try
|
{
|
sectionStatus.speedxlength[l][s] = sectionStatus.speedxlength[l][s] + laneStatus.speedxlength[l][s];
|
}
|
catch (Exception e)
|
{
|
|
}
|
}
|
}
|
}
|
|
sectionStatus.counting = I;
|
sectionStatus.unclassified = NC;
|
sectionStatus.totalMeasurements = sectionInformation.llane.size();
|
sectionStatus.correctMeasurements = sectionInformation.llane.size();
|
sectionStatus.speed = 0;
|
sectionStatus.occupancy = 0;
|
if (I > 0)
|
{
|
sectionStatus.speed = (int)(V/I);
|
sectionStatus.occupancy = (int)(O/I);
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
|
public static void setTotalData (Etd etdData)
|
{
|
try
|
{
|
EtdStatusLane total = etdData.getDeviceStatus().total;
|
int I = 0;
|
int V = 0;
|
int O = 0;
|
int NC = 0;
|
|
List<EtdStatusLane> lstatusLane = etdData.getDeviceStatus().llane;
|
for (EtdStatusLane laneStatus : lstatusLane)
|
{
|
I = I + laneStatus.counting;
|
V = V + (laneStatus.counting*(int)laneStatus.speed);
|
O = O + (laneStatus.counting*(int)laneStatus.occupancy);
|
NC = NC + laneStatus.unclassified;
|
|
for (int l=0; l<laneStatus.lengths.length; l++)
|
{
|
try
|
{
|
total.lengths[l] = total.lengths[l] + laneStatus.lengths[l];
|
}
|
catch (Exception e)
|
{
|
|
}
|
}
|
|
for (int l=0; l<laneStatus.speeds.length; l++)
|
{
|
try
|
{
|
total.speeds[l] = total.speeds[l] + laneStatus.speeds[l];
|
}
|
catch (Exception e)
|
{
|
|
}
|
}
|
|
for (int l=0; l<laneStatus.speedxlength.length; l++)
|
{
|
for (int s=0; s<laneStatus.speedxlength[l].length; s++)
|
{
|
try
|
{
|
total.speedxlength[l][s] = total.speedxlength[l][s] + laneStatus.speedxlength[l][s];
|
}
|
catch (Exception e)
|
{
|
|
}
|
}
|
}
|
}
|
|
total.counting = I;
|
total.unclassified = NC;
|
total.totalMeasurements = etdData.getDeviceInformation().lLane.size();
|
total.correctMeasurements = etdData.getDeviceInformation().lLane.size();
|
total.speed = 0;
|
total.occupancy = 0;
|
if (I > 0)
|
{
|
total.speed = (int)(V/I);
|
total.occupancy = (int)(O/I);
|
}
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
}
|