</table>
</x-boxleft>
+<x-boxleft id="job" class="cont">
+ <table style="width:100%;">
+ <tr><td class="tiny">Vehicle </td><td><span class="tiny" id="vehicle">-</span></td></tr>
+ <tr><td class="tiny">Trailers </td><td><span class="tiny" id="trailer">-</span></td></tr>
+ <tr><td class="tiny">Cargo </td><td><span class="tiny" id="cargo">-</span></td></tr>
+ <tr><td class="tiny">Mass </td><td><span class="tiny" id="cargomass">-</span></td></tr>
+ <tr><td class="tiny">From </td><td><span class="tiny" id="source">-</span></td></tr>
+ <tr><td class="tiny">To </td><td><span class="tiny" id="destination">-</span></td></tr>
+ <tr><td class="tiny">Reward </td><td><span class="tiny" id="reward">-</span></td></tr>
+ </table>
+</x-boxleft>
+
<x-boxleft id="range" class="bar clear">
<x-bar class="pause" id="pausebar">Paused</x-bar>
<x-bar class="error" id="errbar"></x-bar>
var next_rest = document.getElementById("next_rest");
var job_ttd = document.getElementById("job_ttd");
//
+var vehicle = document.getElementById("vehicle");
+var trailer = document.getElementById("trailer");
+var cargo = document.getElementById("cargo");
+var cargomass = document.getElementById("cargomass");
+var source = document.getElementById("source");
+var destination = document.getElementById("destination");
+var reward = document.getElementById("reward");
+//
var errbar = document.getElementById("errbar");
var pausebar = document.getElementById("pausebar");
: '<span class="special">[external]</span>'
: '<span class="special">[none]</span>'
+ //// "job" box
+
+ // make and model of truck and number of trailers
+ vehicle.innerHTML = tele.truck_brand + ' ' + tele.truck_name;
+ trailer.innerHTML = tele.trailer_cnt;
+ cargo.innerHTML = tele.job_isvalid ? tele.job_cargo : '-';
+ cargomass.innerHTML = tele.job_isvalid ? (tele.job_cargo_mass / 1000).toFixed(0) + 't' : '-';
+ source.innerHTML = tele.job_isvalid ? tele.job_source_city : '-';
+ destination.innerHTML = tele.job_isvalid ? tele.job_destination_city : '-';
+ reward.innerHTML = tele.job_isvalid ? tele.job_income + '.-' : '-';
+
//// pause and error bar status:
pausebar.style.display = tele.paused ? "block" : "none";
write(fd, buf, sprintf( buf, " \"rpm\": %f,\n", telemetry->rpm ) );
write(fd, buf, sprintf( buf, " \"gear\": %d,\n", telemetry->gear ) );
write(fd, buf, sprintf( buf, " \"gear_disp\": %d,\n", telemetry->gear_disp ) );
- write(fd, buf, sprintf( buf, " \"gear_fwdcnt\": %u,\n", telemetry->gear_fwdcnt ) );
+ write(fd, buf, sprintf( buf, " \"gear_fwdcnt\": %u,\n", telemetry->truck_fwd_gear_cnt ) );
write(fd, buf, sprintf( buf, " \"clutch_eff\": %f,\n", telemetry->clutch_eff ) );
write(fd, buf, sprintf( buf, " \"shifter\": %d,\n", telemetry->shifter ) );
write(fd, buf, sprintf( buf, " \"nav_slimit\": %f,\n", telemetry->nav_slimit ) );
write(fd, buf, sprintf( buf, " \"next_rest\": %d,\n", telemetry->next_rest ) );
+ write(fd, buf, sprintf( buf, " \"truck_brand\": \"%s\",\n", telemetry->truck_brand ) );
+ write(fd, buf, sprintf( buf, " \"truck_name\": \"%s\",\n", telemetry->truck_name ) );
+
+ write(fd, buf, sprintf( buf, " \"trailer_cnt\": %u,\n", telemetry->trailer_cnt ) );
+
write(fd, buf, sprintf( buf, " \"job_isvalid\": %d,\n", (int)telemetry->job_isvalid ) );
write(fd, buf, sprintf( buf, " \"job_deltime\": %u,\n", telemetry->job_deltime ) );
+ write(fd, buf, sprintf( buf, " \"job_income\": %"PRIu64",\n", telemetry->job_income ) );
+ write(fd, buf, sprintf( buf, " \"job_cargo_mass\": %f,\n", telemetry->job_cargo_mass ) );
+ write(fd, buf, sprintf( buf, " \"job_cargo\": \"%s\",\n", telemetry->job_cargo ) );
+ write(fd, buf, sprintf( buf, " \"job_source_city\": \"%s\",\n", telemetry->job_source_city ) );
+ write(fd, buf, sprintf( buf, " \"job_destination_city\": \"%s\",\n", telemetry->job_destination_city ) );
// add more here
printf( "rpm: %.0f /min\n", telemetry->rpm );
printf( "gear: %d\n", telemetry->gear );
printf( "gear d: %d\n", telemetry->gear_disp );
- printf( "gear fwd cnt: %u\n", telemetry->gear_fwdcnt );
+ printf( "fwd gear cnt: %u\n", telemetry->truck_fwd_gear_cnt );
printf( "clutch eff: %.1f\n", telemetry->clutch_eff );
printf( "shifter: %s\n", telemetry->shifter ? "manual" : "automatic" );
printf( "nav limit: %.1f km/h\n", telemetry->nav_slimit * 3.6 );
printf( "next rest: %s\n", m2hm( telemetry->next_rest ) );
- printf( "time till delivery: %s\n",
- telemetry->job_isvalid ? m2hm( telemetry->job_deltime - telemetry->game_time ) : "--:--" );
+ printf( "truck brand: %s\n", telemetry->truck_brand );
+ printf( "truck model: %s\n", telemetry->truck_name );
+
+ printf( "trailer count: %u\n", telemetry->trailer_cnt );
+
+ if ( telemetry->job_isvalid ) {
+ printf( "job delivery time: %s\n", m2hm( telemetry->job_deltime - telemetry->game_time ) );
+ printf( "job income: %"PRIu64"\n", telemetry->job_income / 10 );
+ printf( "job cargo mass: %.1f t\n", telemetry->job_cargo_mass / 1000 );
+ printf( "job cargo: %s\n", telemetry->job_cargo );
+ printf( "job source city: %s\n", telemetry->job_source_city );
+ printf( "job destination city: %s\n", telemetry->job_destination_city );
+ }
puts("");
#define TELE_SHM_KEY 0xecc11
+#define TELE_STRLEN 30
+
struct telemetry_state_t {
char game_id[10];
unsigned game_major_ver;
float rpm; // engine rpm
int gear; // engine gear
int gear_disp; // displayed gear
- unsigned gear_fwdcnt; // gearbox number of forward gears
float clutch_eff; // effective clutch
int shifter; // 0 = automatic, 1 = manual
float nav_slimit; // navigation speed limit in m/s
int next_rest; // time to next rest stop in minutes
+ char truck_brand[TELE_STRLEN]; // truck brand name
+ char truck_name[TELE_STRLEN]; // truck model name
+ unsigned truck_fwd_gear_cnt; // truck number of forward gears
+
bool job_isvalid; // job info is current, i.e. job is in progress
unsigned job_deltime; // job deadline in minutes (see game_time)
+ uint64_t job_income; // job reward without penalties in in-game currency
+ float job_cargo_mass; // cargo mass in kg
+ char job_cargo[TELE_STRLEN]; // job cargo name
+ char job_source_city[TELE_STRLEN]; // job source city name
+ char job_destination_city[TELE_STRLEN]; // job destination city name
+
+ unsigned trailer_cnt; // number of active trailers
};
#endif /* TELEMETRY_H_ */
}
}
+
+#define TELEMETRY_CONFIG_trailerX "trailer."
+
SCSAPI_VOID telemetry_configuration(const scs_event_t event, const void *const event_info, const scs_context_t UNUSED(context))
{
const struct scs_telemetry_configuration_t *const info = static_cast<const scs_telemetry_configuration_t *>(event_info);
if ( 0 == strcmp( info->id, SCS_TELEMETRY_CONFIG_truck ) ) {
+ /*
+ * @li brand_id
+ * @li brand
+ * @li id
+ * @li name
+ * @li fuel_capacity
+ * @li fuel_warning_factor
+ * @li adblue_capacity
+ * @li ablue_warning_factor
+ * @li air_pressure_warning
+ * @li air_pressure_emergency
+ * @li oil_pressure_warning
+ * @li water_temperature_warning
+ * @li battery_voltage_warning
+ * @li rpm_limit
+ * @li foward_gear_count
+ * @li reverse_gear_count
+ * @li retarder_step_count
+ * @li cabin_position
+ * @li head_position
+ * @li hook_position
+ * @li license_plate
+ * @li license_plate_country
+ * @li license_plate_country_id
+ * @li wheel_count
+ * @li wheel positions for wheel_count wheels
+ */
for (const scs_named_value_t *current = info->attributes; current->name; ++current) {
- if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_forward_gear_count ) ) {
- telemetry->gear_fwdcnt = current->value.value_u32.value;
+ if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_brand ) ) {
+ snprintf( telemetry->truck_brand, sizeof telemetry->truck_brand, "%s", current->value.value_string.value );
+ }
+ else if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_name ) ) {
+ snprintf( telemetry->truck_name, sizeof telemetry->truck_name, "%s", current->value.value_string.value );
+ }
+ else if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_forward_gear_count ) ) {
+ telemetry->truck_fwd_gear_cnt = current->value.value_u32.value;
}
}
}
}
}
else if ( 0 == strcmp( info->id, SCS_TELEMETRY_CONFIG_job ) ) {
+ /*
+ * @li cargo_id
+ * @li cargo
+ * @li cargo_mass
+ * @li destination_city_id
+ * @li destination_city
+ * @li source_city_id
+ * @li source_city
+ * @li destination_company_id (only available for non special transport jobs)
+ * @li destination_company (only available for non special transport jobs)
+ * @li source_company_id (only available for non special transport jobs)
+ * @li source_company (only available for non special transport jobs)
+ * @li income - represents expected income for the job without any penalties
+ * @li delivery_time
+ * @li is_cargo_loaded
+ * @li job_market
+ * @li special_job
+ */
for (const scs_named_value_t *current = info->attributes; current->name; ++current) {
if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_delivery_time ) ) {
telemetry->job_deltime = current->value.value_u32.value;
telemetry->job_isvalid = true;
}
+ else if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_income ) ) {
+ telemetry->job_income = current->value.value_u64.value;
+ }
+ else if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_cargo_mass ) ) {
+ telemetry->job_cargo_mass = current->value.value_float.value;
+ }
+ else if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_cargo ) ) {
+ snprintf( telemetry->job_cargo, sizeof telemetry->job_cargo, "%s", current->value.value_string.value );
+ }
+ else if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_source_city ) ) {
+ snprintf( telemetry->job_source_city, sizeof telemetry->job_source_city, "%s", current->value.value_string.value );
+ }
+ else if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_destination_city ) ) {
+ snprintf( telemetry->job_destination_city, sizeof telemetry->job_destination_city, "%s", current->value.value_string.value );
+ }
+ }
+ }
+ else if ( 0 == strcmp( info->id, SCS_TELEMETRY_CONFIG_trailer ) )
+ { // (Ab)use the compatibility single trailer configuration to reset the trailer counter.
+ telemetry->trailer_cnt = 0;
+ }
+ else if ( 0 == strncmp( info->id, TELEMETRY_CONFIG_trailerX, strlen(TELEMETRY_CONFIG_trailerX) ) ) {
+ // sample the last valid trailer's index plus one
+ for (const scs_named_value_t *current = info->attributes; current->name; ++current) {
+ if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_id ) ) {
+ telemetry->trailer_cnt = strtoul(info->id + strlen(TELEMETRY_CONFIG_trailerX), NULL, 0) + 1;
+ break;
+ }
}
}