use of course_generator.TrackData.CalcClimbResult in project Course_Generator by patrovite.
the class JPanelResume method refresh.
/**
* Refresh the resume grid
*
* @param force
*/
public void refresh() {
// Exit if the tab is not displayed
// if (TabbedPaneMain.getSelectedIndex() != 4) // Resume
// return;
// StatusBar.Items["Message"].Visible = true;
// StatusBar.Items["Message"].Text = "Mise à jour resumé en cours...";
// StatusBar.Refresh();
int i = 0;
int k = 0;
int old = 0;
CgData OldData;
if (Track == null)
return;
if (Track.data.isEmpty())
return;
CalcClimbResult ccr = new CalcClimbResult();
CalcAvrSlopeResult casr = new CalcAvrSlopeResult();
CalcAvrSpeedResult speedResult = new CalcAvrSpeedResult();
Resume.data.clear();
OldData = Track.data.get(0);
for (CgData src : Track.data) {
if ((src.getTag() & 32) != 0) {
k++;
CgResume dst = new CgResume();
// ResGrid.Rows.Add();
dst.setNum(k);
dst.setName(src.getName());
dst.setLine(src.getNum());
dst.setElevation(src.getElevation(CgConst.UNIT_METER));
ccr = Track.CalcClimb(0, i, ccr);
dst.setClimbP(ccr.cp);
dst.setClimbM(ccr.cm);
dst.setDist(src.getTotal(CgConst.UNIT_METER) / 1000.0);
dst.setTime(src.getTime());
dst.setHour(src.getHour());
dst.setTimeLimit(src.getTimeLimit());
dst.setStationTime(src.getStation());
dst.setdTime_f(src.getTime() - OldData.getTime());
dst.setdDist((src.getTotal(CgConst.UNIT_METER) - OldData.getTotal(CgConst.UNIT_METER)) / 1000.0);
ccr = Track.CalcClimb(old, i, ccr);
casr = Track.CalcAvrSlope(old, i, casr);
speedResult = Track.CalcAvrSpeed(old, i, speedResult);
dst.setdClimbP(ccr.cp);
dst.setdClimbM(ccr.cm);
dst.setSpeedP(ccr.cp * 3600 / Math.abs(ccr.tp));
dst.setSpeedM(ccr.cm * 3600 / Math.abs(ccr.tm));
// if ((AvrSlopeP == 0) || (Double.IsNaN(AvrSlopeP) ))
dst.setAvgSlopeP(casr.AvrSlopeP);
dst.setAvgSlopeM(casr.AvrSlopeM);
dst.setAvgSpeed(speedResult.getAvrspeed(CgConst.UNIT_METER));
dst.setComment(src.getComment());
Resume.data.add(dst);
OldData = src;
old = i;
}
i++;
}
// -- Refresh the grid
TableResume.invalidate();
}
use of course_generator.TrackData.CalcClimbResult in project Course_Generator by patrovite.
the class Utils method GenLabel.
public static String GenLabel(String s, CgData r, TrackData cd, CgSettings settings) {
/*
* %N:Name
* %A:Elevation
* %D:Distance from the start
* %T:Time (hh:mm)
* %Ts:Time (hh:mm)
* %Tl:Time (hh:mm:ss)
* %H: Hour (ddd hh:mm)
* %h: Hour (hh:mm)
* %hs:Hour (hh:mm)
* %hl:Hour (hh:mm:s)
* %B :Time limit (hh:mm) -> Time from the start
* %b :Time limit (hh:mm) -> Limit hour
* %C :Comment
* %c :Comment from the main data
* %L :Carriage return
* %R :Station time (hh:mm)
* %Rs:Station time (hh:mm)
* %Rl:Station time (Duration) (hh:mm:ss)
* %+ :Sum ascend
* %- :Sum descend
*/
int i = 0;
int step = 0;
String sr = "";
DateTime dt;
if (cd != null) {
CalcClimbResult res = new CalcClimbResult();
res = cd.CalcClimb(0, (int) (r.getNum() - 1), res);
for (i = 0; i < s.length(); i++) {
switch(step) {
case 0:
{
if (s.charAt(i) == '%') {
step = 1;
} else {
sr = sr + s.charAt(i);
}
break;
}
case 1:
{
switch(s.charAt(i)) {
// %N:Name
case 'N':
sr = sr + r.getName();
step = 0;
break;
// A:Elevation
case 'A':
sr = sr + String.format("%.0f", r.getElevation(settings.Unit));
step = 0;
break;
// %D:Distance from the start
case 'D':
sr = sr + String.format("%.1f", r.getTotal(settings.Unit) / 1000.0);
step = 0;
break;
// %T:Time (hh:mm)
case 'T':
step = 3;
break;
// %H:Hour (ddd hh:mm)
case 'H':
sr = sr + r.getHour().toString("E HH:mm");
step = 0;
break;
// %h:Time (hh:mm)
case 'h':
step = 2;
break;
// %R:Station time (hh:mm:ss)
case 'R':
step = 4;
break;
// %B:Time limit (hh:mm) -> Time from the start
case 'B':
sr = sr + Utils.Second2DateString_HM(r.getTimeLimit());
step = 0;
break;
// %b:Time limit (hh:mm) -> Limit hour
case 'b':
if (cd != null) {
dt = cd.StartTime.plusSeconds(r.getTimeLimit());
sr = sr + dt.toString("HH:mm");
} else {
sr = sr + "00:00";
}
step = 0;
break;
// %C:Comment from the MRB data
case 'C':
sr = sr + r.CommentMiniRoadbook;
step = 0;
break;
// %c:Comment from the main data
case 'c':
sr = sr + r.getComment();
step = 0;
break;
// %+: Sum ascend
case '+':
sr = sr + String.format("%.0f", res.cp);
step = 0;
break;
// %-: Sum descend
case '-':
sr = sr + String.format("%.0f", res.cm);
step = 0;
break;
// %L: Carriage return
case 'L':
sr = sr + "\n";
step = 0;
break;
default:
sr = sr + s.charAt(i);
break;
}
break;
}
case // %h
2:
{
switch(s.charAt(i)) {
case 's':
sr = sr + r.getHour().toString("HH:mm");
step = 0;
break;
case 'l':
sr = sr + r.getHour().toString("HH:mm:ss");
step = 0;
break;
default:
sr = sr + r.getHour().toString("HH:mm");
sr = sr + s.charAt(i);
step = 0;
break;
}
break;
}
case // %T
3:
{
switch(s.charAt(i)) {
case 's':
sr = sr + Utils.Second2DateString_HM(r.getTime());
step = 0;
break;
case 'l':
sr = sr + Utils.Second2DateString(r.getTime());
step = 0;
break;
default:
sr = sr + Utils.Second2DateString_HM(r.getTime());
sr = sr + s.charAt(i);
step = 0;
break;
}
break;
}
case // %R
4:
{
switch(s.charAt(i)) {
case 's':
sr = sr + Utils.Second2DateString_HM(r.getStation());
step = 0;
break;
case 'l':
sr = sr + Utils.Second2DateString(r.getStation());
step = 0;
break;
default:
sr = sr + Utils.Second2DateString(r.getStation());
sr = sr + s.charAt(i);
step = 0;
break;
}
break;
}
}
}
// If a command with 1 or 2 characters => Default value
if (step == 2) {
sr = sr + r.getHour().toString("HH:mm");
} else if (step == 3) {
sr = sr + Utils.Second2DateString_HM(r.getTime());
} else if (step == 4) {
sr = sr + Utils.Second2DateString(r.getStation());
}
if (cd != null) {
return Utils.WordWrap(sr, cd.WordWrapLength, true);
}
// else {
// return sr;
// }
}
return sr;
}
use of course_generator.TrackData.CalcClimbResult in project Course_Generator by patrovite.
the class frmMain method CalcTrackTime.
/**
* Launch the calculation on the track
*/
private void CalcTrackTime() {
if (Track.data.isEmpty())
return;
Track.Calculate();
RefreshStatusbar(Track);
CalcClimbResult ccr = new CalcClimbResult();
ccr = Track.CalcClimb(0, Track.data.size() - 1, ccr);
Track.setClimbP(ccr.cp);
Track.setClimbM(ccr.cm);
Track.AscTime = ccr.tp;
Track.DescTime = ccr.tm;
Track.CheckTimeLimit();
Track.isCalculated = true;
Track.isModified = true;
// -- Refresh statusbar
RefreshStatusbar(Track);
panelTrackData.refresh();
PanelResume.refresh();
panelStatistics.refresh();
jPanelSpeed.Refresh(Track, Settings);
jPanelSpeedSlope.Refresh(Track, Settings);
}
Aggregations