| 1 |
/* |
| 2 |
RailControl - Model Railway Control Software |
| 3 |
|
| 4 |
Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org |
| 5 |
|
| 6 |
RailControl is free software; you can redistribute it and/or modify it |
| 7 |
under the terms of the GNU General Public License as published by the |
| 8 |
Free Software Foundation; either version 3, or (at your option) any |
| 9 |
later version. |
| 10 |
|
| 11 |
RailControl is distributed in the hope that it will be useful, but |
| 12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 |
See the GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with RailControl; see the file LICENCE. If not see |
| 18 |
<http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include <map> |
| 22 |
#include <string> |
| 23 |
#include <utility> |
| 24 |
#include <vector> |
| 25 |
|
| 26 |
#include "DataModel/DataModel.h" |
| 27 |
#include "DataModel/ObjectIdentifier.h" |
| 28 |
#include "Server/Web/HtmlTagButton.h" |
| 29 |
#include "Server/Web/HtmlTagButtonCancel.h" |
| 30 |
#include "Server/Web/HtmlTagButtonCommandWide.h" |
| 31 |
#include "Server/Web/HtmlTagButtonOK.h" |
| 32 |
#include "Server/Web/HtmlTagButtonPopupWide.h" |
| 33 |
#include "Server/Web/HtmlTagButtonSwapRelation.h" |
| 34 |
#include "Server/Web/HtmlTagInputCheckboxWithLabel.h" |
| 35 |
#include "Server/Web/HtmlTagInputHidden.h" |
| 36 |
#include "Server/Web/HtmlTagInputIntegerWithLabel.h" |
| 37 |
#include "Server/Web/HtmlTagInputTextWithLabel.h" |
| 38 |
#include "Server/Web/HtmlTagRoute.h" |
| 39 |
#include "Server/Web/HtmlTagSelect.h" |
| 40 |
#include "Server/Web/HtmlTagSelectMultipleWithLabel.h" |
| 41 |
#include "Server/Web/HtmlTagSelectOrientation.h" |
| 42 |
#include "Server/Web/HtmlTagSelectWithLabel.h" |
| 43 |
#include "Server/Web/HtmlTagSpace.h" |
| 44 |
#include "Server/Web/WebClient.h" |
| 45 |
#include "Server/Web/WebClientRoute.h" |
| 46 |
#include "Server/Web/WebClientStatic.h" |
| 47 |
#include "Utils/Integer.h" |
| 48 |
|
| 49 |
using namespace DataModel; |
| 50 |
using LayoutPosition = DataModel::LayoutItem::LayoutPosition; |
| 51 |
using LayoutItemSize = DataModel::LayoutItem::LayoutItemSize; |
| 52 |
using LayoutRotation = DataModel::LayoutItem::LayoutRotation; |
| 53 |
using Visible = DataModel::LayoutItem::Visible; |
| 54 |
using std::map; |
| 55 |
using std::pair; |
| 56 |
using std::string; |
| 57 |
using std::to_string; |
| 58 |
using std::vector; |
| 59 |
|
| 60 |
namespace Server { namespace Web |
| 61 |
{ |
| 62 |
void WebClientRoute::HandleRouteGet(const map<string, string>& arguments) |
| 63 |
{ |
| 64 |
RouteID routeID = Utils::Utils::GetIntegerMapEntry(arguments, "route"); |
| 65 |
const DataModel::Route* route = manager.GetRoute(routeID); |
| 66 |
if (route == nullptr || route->GetVisible() == DataModel::LayoutItem::VisibleNo) |
| 67 |
{ |
| 68 |
client.ReplyHtmlWithHeader(HtmlTag()); |
| 69 |
return; |
| 70 |
} |
| 71 |
client.ReplyHtmlWithHeader(HtmlTagRoute(route)); |
| 72 |
} |
| 73 |
|
| 74 |
void WebClientRoute::HandleRouteEdit(const map<string, string>& arguments) |
| 75 |
{ |
| 76 |
HtmlTag content; |
| 77 |
const RouteID routeID = Utils::Utils::GetIntegerMapEntry(arguments, "route", RouteNone); |
| 78 |
string name = Languages::GetText(Languages::TextNew); |
| 79 |
Delay delay = Route::DefaultDelay; |
| 80 |
Route::PushpullType pushpull = Route::PushpullTypeBoth; |
| 81 |
Propulsion propulsion = PropulsionAll; |
| 82 |
TrainType trainType = TrainTypeAll; |
| 83 |
Length minTrainLength = 0; |
| 84 |
Length maxTrainLength = 0; |
| 85 |
vector<Relation*> relationsAtLock; |
| 86 |
vector<Relation*> relationsAtUnlock; |
| 87 |
LayoutPosition posx = Utils::Utils::GetIntegerMapEntry(arguments, "posx", 0); |
| 88 |
LayoutPosition posy = Utils::Utils::GetIntegerMapEntry(arguments, "posy", 0); |
| 89 |
LayoutPosition posz = Utils::Utils::GetIntegerMapEntry(arguments, "posz", LayerUndeletable); |
| 90 |
DataModel::LayoutItem::Visible visible = static_cast<Visible>(Utils::Utils::GetBoolMapEntry(arguments, "visible", routeID == RouteNone && ((posx || posy) && posz >= LayerUndeletable) ? DataModel::LayoutItem::VisibleYes : DataModel::LayoutItem::VisibleNo)); |
| 91 |
Automode automode = static_cast<Automode>(Utils::Utils::GetBoolMapEntry(arguments, "automode", AutomodeNo)); |
| 92 |
TrackID fromTrack = static_cast<TrackID>(Utils::Utils::GetIntegerMapEntry(arguments, "fromtrack", TrackNone)); |
| 93 |
Orientation fromOrientation = static_cast<Orientation>(Utils::Utils::GetBoolMapEntry(arguments, "fromorientation", OrientationRight)); |
| 94 |
TrackID toTrack = static_cast<TrackID>(Utils::Utils::GetIntegerMapEntry(arguments, "totrack", TrackNone)); |
| 95 |
Orientation toOrientation = static_cast<Orientation>(Utils::Utils::GetBoolMapEntry(arguments, "toorientation", OrientationRight)); |
| 96 |
Route::Speed speed = static_cast<Route::Speed>(Utils::Utils::GetIntegerMapEntry(arguments, "speed", Route::SpeedTravel)); |
| 97 |
FeedbackID feedbackIdReduced = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackreduced", FeedbackNone); |
| 98 |
Delay reducedDelay = Utils::Utils::GetIntegerMapEntry(arguments, "reduceddelay", 0); |
| 99 |
FeedbackID feedbackIdCreep = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackcreep", FeedbackNone); |
| 100 |
Delay creepDelay = Utils::Utils::GetIntegerMapEntry(arguments, "creepdelay", 0); |
| 101 |
FeedbackID feedbackIdStop = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackstop", FeedbackNone); |
| 102 |
Delay stopDelay = Utils::Utils::GetIntegerMapEntry(arguments, "stopdelay", 0); |
| 103 |
FeedbackID feedbackIdOver = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackover", FeedbackNone); |
| 104 |
Pause waitAfterRelease = Utils::Utils::GetIntegerMapEntry(arguments, "waitafterrelease", 0); |
| 105 |
RouteID followUpRoute = Utils::Utils::GetIntegerMapEntry(arguments, "followuproute", RouteNone); |
| 106 |
if (routeID > RouteNone) |
| 107 |
{ |
| 108 |
const DataModel::Route* route = manager.GetRoute(routeID); |
| 109 |
if (route != nullptr) |
| 110 |
{ |
| 111 |
name = route->GetName(); |
| 112 |
delay = route->GetDelay(); |
| 113 |
pushpull = route->GetPushpull(); |
| 114 |
propulsion = route->GetPropulsion(); |
| 115 |
trainType = route->GetTrainType(); |
| 116 |
minTrainLength = route->GetMinTrainLength(); |
| 117 |
maxTrainLength = route->GetMaxTrainLength(); |
| 118 |
relationsAtLock = route->GetRelationsAtLock(); |
| 119 |
relationsAtUnlock = route->GetRelationsAtUnlock(); |
| 120 |
visible = route->GetVisible(); |
| 121 |
posx = route->GetPosX(); |
| 122 |
posy = route->GetPosY(); |
| 123 |
posz = route->GetPosZ(); |
| 124 |
automode = route->GetAutomode(); |
| 125 |
fromTrack = route->GetFromTrack(); |
| 126 |
fromOrientation = route->GetFromOrientation(); |
| 127 |
toTrack = route->GetToTrack(); |
| 128 |
toOrientation = route->GetToOrientation(); |
| 129 |
speed = route->GetSpeed(); |
| 130 |
feedbackIdReduced = route->GetFeedbackIdReduced(); |
| 131 |
reducedDelay = route->GetReducedDelay(); |
| 132 |
feedbackIdCreep = route->GetFeedbackIdCreep(); |
| 133 |
creepDelay = route->GetCreepDelay(); |
| 134 |
feedbackIdStop = route->GetFeedbackIdStop(); |
| 135 |
stopDelay = route->GetStopDelay(); |
| 136 |
feedbackIdOver = route->GetFeedbackIdOver(); |
| 137 |
waitAfterRelease = route->GetWaitAfterRelease(); |
| 138 |
followUpRoute = route->GetFollowUpRoute(); |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
content.AddChildTag(HtmlTag("h1").AddContent(name).AddId("popup_title")); |
| 143 |
HtmlTag tabMenu("div"); |
| 144 |
tabMenu.AddChildTag(WebClientStatic::HtmlTagTabMenuItem("basic", Languages::TextBasic, true)); |
| 145 |
tabMenu.AddChildTag(WebClientStatic::HtmlTagTabMenuItem("relationatlock", Languages::TextAtLock)); |
| 146 |
tabMenu.AddChildTag(WebClientStatic::HtmlTagTabMenuItem("relationatunlock", Languages::TextAtUnlock, false, !automode)); |
| 147 |
tabMenu.AddChildTag(WebClientStatic::HtmlTagTabMenuItem("position", Languages::TextPosition)); |
| 148 |
tabMenu.AddChildTag(WebClientStatic::HtmlTagTabMenuItem("automode", Languages::TextAutomode)); |
| 149 |
content.AddChildTag(tabMenu); |
| 150 |
|
| 151 |
HtmlTag formContent("form"); |
| 152 |
formContent.AddId("editform"); |
| 153 |
formContent.AddChildTag(HtmlTagInputHidden("cmd", "routesave")); |
| 154 |
formContent.AddChildTag(HtmlTagInputHidden("route", to_string(routeID))); |
| 155 |
|
| 156 |
HtmlTag basicContent("div"); |
| 157 |
basicContent.AddId("tab_basic"); |
| 158 |
basicContent.AddClass("tab_content"); |
| 159 |
basicContent.AddChildTag(HtmlTagInputTextWithLabel("name", Languages::TextName, name).AddAttribute("onkeyup", "updateName();")); |
| 160 |
basicContent.AddChildTag(HtmlTagInputIntegerWithLabel("delay", Languages::TextWaitingTimeBetweenMembers, delay, 1, USHRT_MAX)); |
| 161 |
formContent.AddChildTag(basicContent); |
| 162 |
|
| 163 |
HtmlTag relationDivAtLock("div"); |
| 164 |
relationDivAtLock.AddId("relationatlock"); |
| 165 |
Priority priorityAtLock = 1; |
| 166 |
for (auto relation : relationsAtLock) |
| 167 |
{ |
| 168 |
relationDivAtLock.AddChildTag(HtmlTagRelation("atlock", relation->GetPriority(), relation->ObjectType2(), relation->ObjectID2(), relation->GetData())); |
| 169 |
priorityAtLock = relation->GetPriority() + 1; |
| 170 |
} |
| 171 |
relationDivAtLock.AddChildTag(HtmlTagInputHidden("relationcounteratlock", to_string(priorityAtLock))); |
| 172 |
relationDivAtLock.AddChildTag(HtmlTag("div").AddId("new_atlock_priority_" + to_string(priorityAtLock))); |
| 173 |
|
| 174 |
HtmlTag relationContentAtLock("div"); |
| 175 |
relationContentAtLock.AddId("tab_relationatlock"); |
| 176 |
relationContentAtLock.AddClass("tab_content"); |
| 177 |
relationContentAtLock.AddClass("hidden"); |
| 178 |
relationContentAtLock.AddChildTag(relationDivAtLock); |
| 179 |
HtmlTagButton newButtonAtLock(Languages::TextNew, "newrelationatlock"); |
| 180 |
newButtonAtLock.AddAttribute("onclick", "addRelation('atlock');return false;"); |
| 181 |
newButtonAtLock.AddClass("wide_button"); |
| 182 |
relationContentAtLock.AddChildTag(newButtonAtLock); |
| 183 |
relationContentAtLock.AddChildTag(HtmlTag("br")); |
| 184 |
formContent.AddChildTag(relationContentAtLock); |
| 185 |
|
| 186 |
HtmlTag relationDivAtUnlock("div"); |
| 187 |
relationDivAtUnlock.AddId("relationatunlock"); |
| 188 |
Priority priorityAtUnlock = 1; |
| 189 |
for (auto relation : relationsAtUnlock) |
| 190 |
{ |
| 191 |
relationDivAtUnlock.AddChildTag(HtmlTagRelation("atunlock", relation->GetPriority(), relation->ObjectType2(), relation->ObjectID2(), relation->GetData())); |
| 192 |
priorityAtUnlock = relation->GetPriority() + 1; |
| 193 |
} |
| 194 |
relationDivAtUnlock.AddChildTag(HtmlTagInputHidden("relationcounteratunlock", to_string(priorityAtUnlock))); |
| 195 |
relationDivAtUnlock.AddChildTag(HtmlTag("div").AddId("new_atunlock_priority_" + to_string(priorityAtUnlock))); |
| 196 |
|
| 197 |
HtmlTag relationContentAtUnlock("div"); |
| 198 |
relationContentAtUnlock.AddId("tab_relationatunlock"); |
| 199 |
relationContentAtUnlock.AddClass("tab_content"); |
| 200 |
relationContentAtUnlock.AddClass("hidden"); |
| 201 |
relationContentAtUnlock.AddChildTag(relationDivAtUnlock); |
| 202 |
HtmlTagButton newButtonAtUnlock(Languages::TextNew, "newrelationatunlock"); |
| 203 |
newButtonAtUnlock.AddAttribute("onclick", "addRelation('atunlock');return false;"); |
| 204 |
newButtonAtUnlock.AddClass("wide_button"); |
| 205 |
relationContentAtUnlock.AddChildTag(newButtonAtUnlock); |
| 206 |
relationContentAtUnlock.AddChildTag(HtmlTag("br")); |
| 207 |
formContent.AddChildTag(relationContentAtUnlock); |
| 208 |
|
| 209 |
formContent.AddChildTag(client.HtmlTagTabPosition(posx, posy, posz, visible)); |
| 210 |
|
| 211 |
HtmlTag automodeContent("div"); |
| 212 |
automodeContent.AddId("tab_automode"); |
| 213 |
automodeContent.AddClass("tab_content"); |
| 214 |
automodeContent.AddClass("hidden"); |
| 215 |
|
| 216 |
HtmlTagInputCheckboxWithLabel checkboxAutomode("automode", Languages::TextAutomode, "automode", static_cast<bool>(automode)); |
| 217 |
checkboxAutomode.AddId("automode"); |
| 218 |
checkboxAutomode.AddAttribute("onchange", "onChangeCheckboxShowHide('automode', 'tracks', 'tab_button_relationatunlock');"); |
| 219 |
automodeContent.AddChildTag(checkboxAutomode); |
| 220 |
|
| 221 |
HtmlTag tracksDiv("div"); |
| 222 |
tracksDiv.AddId("tracks"); |
| 223 |
if (automode == AutomodeNo) |
| 224 |
{ |
| 225 |
tracksDiv.AddAttribute("hidden"); |
| 226 |
} |
| 227 |
tracksDiv.AddChildTag(HtmlTagSelectTrack("from", Languages::TextStartTrack, fromTrack, fromOrientation)); |
| 228 |
tracksDiv.AddChildTag(HtmlTagSelectTrack("to", Languages::TextDestinationTrack, toTrack, toOrientation, "updateFeedbacksOfTrack(); return false;")); |
| 229 |
|
| 230 |
map<Route::Speed,Languages::TextSelector> speedOptions; |
| 231 |
speedOptions[Route::SpeedTravel] = Languages::TextTravelSpeed; |
| 232 |
speedOptions[Route::SpeedReduced] = Languages::TextReducedSpeed; |
| 233 |
speedOptions[Route::SpeedCreeping] = Languages::TextCreepingSpeed; |
| 234 |
tracksDiv.AddChildTag(HtmlTagSelectWithLabel("speed", Languages::TextSpeed, speedOptions, speed)); |
| 235 |
HtmlTag feedbackDiv("div"); |
| 236 |
feedbackDiv.AddId("feedbacks"); |
| 237 |
feedbackDiv.AddChildTag(HtmlTagSelectFeedbacksOfTrack(toTrack, followUpRoute, feedbackIdReduced, reducedDelay, feedbackIdCreep, creepDelay, feedbackIdStop, stopDelay, feedbackIdOver)); |
| 238 |
tracksDiv.AddChildTag(feedbackDiv); |
| 239 |
|
| 240 |
map<Route::PushpullType,Languages::TextSelector> pushpullOptions; |
| 241 |
pushpullOptions[Route::PushpullTypeNo] = Languages::TextNoPushPull; |
| 242 |
pushpullOptions[Route::PushpullTypeBoth] = Languages::TextAllTrains; |
| 243 |
pushpullOptions[Route::PushpullTypeOnly] = Languages::TextPushPullOnly; |
| 244 |
tracksDiv.AddChildTag(HtmlTagSelectWithLabel("pushpull", Languages::TextAllowedPushPull, pushpullOptions, pushpull)); |
| 245 |
|
| 246 |
vector<pair<Propulsion,Languages::TextSelector>> propulsionOptions; |
| 247 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionAll,Languages::TextPropulsionAll)); |
| 248 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionSteam,Languages::TextPropulsionSteam)); |
| 249 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionDiesel,Languages::TextPropulsionDiesel)); |
| 250 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionGas,Languages::TextPropulsionGas)); |
| 251 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionElectric,Languages::TextPropulsionElectric)); |
| 252 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionHydrogen,Languages::TextPropulsionHydrogen)); |
| 253 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionAccu,Languages::TextPropulsionAccu)); |
| 254 |
propulsionOptions.push_back(pair<Propulsion,Languages::TextSelector>(PropulsionOther,Languages::TextPropulsionOther)); |
| 255 |
tracksDiv.AddChildTag(HtmlTagSelectMultipleWithLabel("propulsion", Languages::TextAllowedPropulsions, propulsionOptions, propulsion)); |
| 256 |
|
| 257 |
vector<pair<TrainType,Languages::TextSelector>> trainTypeOptions; |
| 258 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeAll,Languages::TextTrainTypeAll)); |
| 259 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypePassenger,Languages::TextTrainTypePassenger)); |
| 260 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeInternationalHighSpeed,Languages::TextTrainTypeInternationalHighSpeed)); |
| 261 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeNationalHighSpeed,Languages::TextTrainTypeNationalHighSpeed)); |
| 262 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeInternationalLongDistance,Languages::TextTrainTypeInternationalLongDistance)); |
| 263 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeNationalLongDistance,Languages::TextTrainTypeNationalLongDistance)); |
| 264 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeInternationalNight,Languages::TextTrainTypeInternationalNight)); |
| 265 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeNationalNight,Languages::TextTrainTypeNationalNight)); |
| 266 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeLongDistanceFastLocal,Languages::TextTrainTypeLongDistanceFastLocal)); |
| 267 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeFastLocal,Languages::TextTrainTypeFastLocal)); |
| 268 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeLocal,Languages::TextTrainTypeLocal)); |
| 269 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeSuburban,Languages::TextTrainTypeSuburban)); |
| 270 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeUnderground,Languages::TextTrainTypeUnderground)); |
| 271 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeHistoric,Languages::TextTrainTypeHistoric)); |
| 272 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeExtra,Languages::TextTrainTypeExtra)); |
| 273 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypePassengerWithCargo,Languages::TextTrainTypePassengerWithCargo)); |
| 274 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCargo,Languages::TextTrainTypeCargo)); |
| 275 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCargoLongDistance,Languages::TextTrainTypeCargoLongDistance)); |
| 276 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCargoLocal,Languages::TextTrainTypeCargoLocal)); |
| 277 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCargoBlock,Languages::TextTrainTypeCargoBlock)); |
| 278 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCargoTractor,Languages::TextTrainTypeCargoTractor)); |
| 279 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCargoExpress,Languages::TextTrainTypeCargoExpress)); |
| 280 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCargoWithPassenger,Languages::TextTrainTypeCargoWithPassenger)); |
| 281 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeRescue,Languages::TextTrainTypeRescue)); |
| 282 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeConstruction,Languages::TextTrainTypeConstruction)); |
| 283 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeEmpty,Languages::TextTrainTypeEmpty)); |
| 284 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeLoco,Languages::TextTrainTypeLoco)); |
| 285 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeCleaning,Languages::TextTrainTypeCleaning)); |
| 286 |
trainTypeOptions.push_back(pair<TrainType,Languages::TextSelector>(TrainTypeOther,Languages::TextTrainTypeOther)); |
| 287 |
tracksDiv.AddChildTag(HtmlTagSelectMultipleWithLabel("traintype", Languages::TextAllowedTrainTypes, trainTypeOptions, trainType)); |
| 288 |
|
| 289 |
tracksDiv.AddChildTag(HtmlTagInputIntegerWithLabel("mintrainlength", Languages::TextMinTrainLength, minTrainLength, 0, 99999)); |
| 290 |
tracksDiv.AddChildTag(HtmlTagInputIntegerWithLabel("maxtrainlength", Languages::TextMaxTrainLength, maxTrainLength, 0, 99999)); |
| 291 |
tracksDiv.AddChildTag(HtmlTagInputIntegerWithLabel("waitafterrelease", Languages::TextWaitAfterRelease, waitAfterRelease, 0, 300)); |
| 292 |
|
| 293 |
automodeContent.AddChildTag(tracksDiv); |
| 294 |
formContent.AddChildTag(automodeContent); |
| 295 |
|
| 296 |
content.AddChildTag(HtmlTag("div").AddClass("popup_content").AddChildTag(formContent)); |
| 297 |
content.AddChildTag(HtmlTagButtonCancel()); |
| 298 |
content.AddChildTag(HtmlTagButtonOK()); |
| 299 |
client.ReplyHtmlWithHeader(content); |
| 300 |
} |
| 301 |
|
| 302 |
void WebClientRoute::HandleRouteSave(const map<string, string>& arguments) |
| 303 |
{ |
| 304 |
const RouteID routeID = Utils::Utils::GetIntegerMapEntry(arguments, "route", RouteNone); |
| 305 |
const string name = Utils::Utils::GetStringMapEntry(arguments, "name"); |
| 306 |
const Delay delay = static_cast<Delay>(Utils::Utils::GetIntegerMapEntry(arguments, "delay")); |
| 307 |
const Route::PushpullType pushpull = static_cast<Route::PushpullType>(Utils::Utils::GetIntegerMapEntry(arguments, "pushpull", Route::PushpullTypeBoth)); |
| 308 |
Propulsion propulsion = static_cast<Propulsion>(Utils::Utils::GetIntegerMapEntry(arguments, "propulsion", PropulsionAll)); |
| 309 |
if (propulsion == PropulsionUnknown) |
| 310 |
{ |
| 311 |
propulsion = PropulsionAll; |
| 312 |
} |
| 313 |
TrainType trainType = static_cast<TrainType>(Utils::Utils::GetIntegerMapEntry(arguments, "traintype", TrainTypeAll)); |
| 314 |
if (trainType == TrainTypeUnknown) |
| 315 |
{ |
| 316 |
trainType = TrainTypeAll; |
| 317 |
} |
| 318 |
const Length mintrainlength = static_cast<Length>(Utils::Utils::GetIntegerMapEntry(arguments, "mintrainlength", 0)); |
| 319 |
const Length maxtrainlength = static_cast<Length>(Utils::Utils::GetIntegerMapEntry(arguments, "maxtrainlength", 0)); |
| 320 |
const Visible visible = static_cast<Visible>(Utils::Utils::GetBoolMapEntry(arguments, "visible")); |
| 321 |
const LayoutPosition posx = Utils::Utils::GetIntegerMapEntry(arguments, "posx", 0); |
| 322 |
const LayoutPosition posy = Utils::Utils::GetIntegerMapEntry(arguments, "posy", 0); |
| 323 |
const LayoutPosition posz = Utils::Utils::GetIntegerMapEntry(arguments, "posz", 0); |
| 324 |
const Automode automode = static_cast<Automode>(Utils::Utils::GetBoolMapEntry(arguments, "automode")); |
| 325 |
const TrackID fromTrack = static_cast<TrackID>(Utils::Utils::GetIntegerMapEntry(arguments, "fromtrack", TrackNone)); |
| 326 |
const Orientation fromOrientation = static_cast<Orientation>(Utils::Utils::GetBoolMapEntry(arguments, "fromorientation", OrientationRight)); |
| 327 |
const TrackID toTrack = static_cast<TrackID>(Utils::Utils::GetIntegerMapEntry(arguments, "totrack", TrackNone)); |
| 328 |
const Orientation toOrientation = static_cast<Orientation>(Utils::Utils::GetBoolMapEntry(arguments, "toorientation", OrientationRight)); |
| 329 |
const Route::Speed speed = static_cast<Route::Speed>(Utils::Utils::GetIntegerMapEntry(arguments, "speed", Route::SpeedTravel)); |
| 330 |
const FeedbackID feedbackIdReduced = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackreduced", FeedbackNone); |
| 331 |
const Delay reducedDelay = Utils::Utils::GetIntegerMapEntry(arguments, "reduceddelay", 0); |
| 332 |
const FeedbackID feedbackIdCreep = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackcreep", FeedbackNone); |
| 333 |
const Delay creepDelay = Utils::Utils::GetIntegerMapEntry(arguments, "creepdelay", 0); |
| 334 |
const FeedbackID feedbackIdStop = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackstop", FeedbackNone); |
| 335 |
const Delay stopDelay = Utils::Utils::GetIntegerMapEntry(arguments, "stopdelay", 0); |
| 336 |
const FeedbackID feedbackIdOver = Utils::Utils::GetIntegerMapEntry(arguments, "feedbackover", FeedbackNone); |
| 337 |
const Pause waitAfterRelease = Utils::Utils::GetIntegerMapEntry(arguments, "waitafterrelease", 0); |
| 338 |
const RouteID followUpRoute = Utils::Utils::GetIntegerMapEntry(arguments, "followuproute", RouteNone); |
| 339 |
|
| 340 |
Priority relationCountAtLock = Utils::Utils::GetIntegerMapEntry(arguments, "relationcounteratlock", 0); |
| 341 |
Priority relationCountAtUnlock = Utils::Utils::GetIntegerMapEntry(arguments, "relationcounteratunlock", 0); |
| 342 |
|
| 343 |
vector<Relation*> relationsAtLock; |
| 344 |
Priority priorityAtLock = 1; |
| 345 |
for (Priority relationId = 1; relationId <= relationCountAtLock; ++relationId) |
| 346 |
{ |
| 347 |
string priorityString = to_string(relationId); |
| 348 |
ObjectType objectType = static_cast<ObjectType>(Utils::Utils::GetIntegerMapEntry(arguments, "relation_atlock_" + priorityString + "_type")); |
| 349 |
ObjectID objectId = Utils::Utils::GetIntegerMapEntry(arguments, "relation_atlock_" + priorityString + "_id", ObjectNone); |
| 350 |
if (objectId == 0 |
| 351 |
&& objectType != ObjectTypeLoco |
| 352 |
&& objectType != ObjectTypePause |
| 353 |
&& objectType != ObjectTypeMultipleUnit |
| 354 |
&& objectType != ObjectTypeBooster) |
| 355 |
{ |
| 356 |
continue; |
| 357 |
} |
| 358 |
if (objectId == fromTrack && objectType == ObjectTypeTrack) |
| 359 |
{ |
| 360 |
continue; |
| 361 |
} |
| 362 |
if (objectId == toTrack && objectType == ObjectTypeTrack) |
| 363 |
{ |
| 364 |
continue; |
| 365 |
} |
| 366 |
unsigned short state = Utils::Utils::GetIntegerMapEntry(arguments, "relation_atlock_" + priorityString + "_state"); |
| 367 |
relationsAtLock.push_back(new Relation(&manager, |
| 368 |
ObjectIdentifier(ObjectTypeRoute, routeID), |
| 369 |
ObjectIdentifier(objectType, objectId), |
| 370 |
Relation::RelationTypeRouteAtLock, |
| 371 |
priorityAtLock, |
| 372 |
state)); |
| 373 |
++priorityAtLock; |
| 374 |
} |
| 375 |
|
| 376 |
vector<Relation*> relationsAtUnlock; |
| 377 |
Priority priorityAtUnlock = 1; |
| 378 |
for (Priority relationId = 1; relationId <= relationCountAtUnlock; ++relationId) |
| 379 |
{ |
| 380 |
string priorityString = to_string(relationId); |
| 381 |
ObjectType objectType = static_cast<ObjectType>(Utils::Utils::GetIntegerMapEntry(arguments, "relation_atunlock_" + priorityString + "_type")); |
| 382 |
ObjectID objectId = Utils::Utils::GetIntegerMapEntry(arguments, "relation_atunlock_" + priorityString + "_id", ObjectNone); |
| 383 |
if (objectId == 0 |
| 384 |
&& objectType != ObjectTypeLoco |
| 385 |
&& objectType != ObjectTypePause |
| 386 |
&& objectType != ObjectTypeMultipleUnit |
| 387 |
&& objectType != ObjectTypeBooster) |
| 388 |
{ |
| 389 |
continue; |
| 390 |
} |
| 391 |
if (objectId == fromTrack && objectType == ObjectTypeTrack) |
| 392 |
{ |
| 393 |
continue; |
| 394 |
} |
| 395 |
if (objectId == toTrack && objectType == ObjectTypeTrack) |
| 396 |
{ |
| 397 |
continue; |
| 398 |
} |
| 399 |
unsigned char state = Utils::Utils::GetIntegerMapEntry(arguments, "relation_atunlock_" + priorityString + "_state"); |
| 400 |
relationsAtUnlock.push_back(new Relation(&manager, |
| 401 |
ObjectIdentifier(ObjectTypeRoute, routeID), |
| 402 |
ObjectIdentifier(objectType, objectId), |
| 403 |
Relation::RelationTypeRouteAtUnlock, |
| 404 |
priorityAtUnlock, |
| 405 |
state)); |
| 406 |
++priorityAtUnlock; |
| 407 |
} |
| 408 |
|
| 409 |
string result; |
| 410 |
if (!manager.RouteSave(routeID, |
| 411 |
name, |
| 412 |
delay, |
| 413 |
pushpull, |
| 414 |
propulsion, |
| 415 |
trainType, |
| 416 |
mintrainlength, |
| 417 |
maxtrainlength, |
| 418 |
relationsAtLock, |
| 419 |
relationsAtUnlock, |
| 420 |
visible, |
| 421 |
posx, |
| 422 |
posy, |
| 423 |
posz, |
| 424 |
automode, |
| 425 |
fromTrack, |
| 426 |
fromOrientation, |
| 427 |
toTrack, |
| 428 |
toOrientation, |
| 429 |
speed, |
| 430 |
feedbackIdReduced, |
| 431 |
reducedDelay, |
| 432 |
feedbackIdCreep, |
| 433 |
creepDelay, |
| 434 |
feedbackIdStop, |
| 435 |
stopDelay, |
| 436 |
feedbackIdOver, |
| 437 |
waitAfterRelease, |
| 438 |
followUpRoute, |
| 439 |
result)) |
| 440 |
{ |
| 441 |
client.ReplyResponse(client.ResponseError, result); |
| 442 |
return; |
| 443 |
} |
| 444 |
client.ReplyResponse(client.ResponseInfo, Languages::TextRouteSaved, name); |
| 445 |
} |
| 446 |
|
| 447 |
void WebClientRoute::HandleRouteAskDelete(const map<string, string>& arguments) |
| 448 |
{ |
| 449 |
RouteID routeID = Utils::Utils::GetIntegerMapEntry(arguments, "route", RouteNone); |
| 450 |
|
| 451 |
if (routeID == RouteNone) |
| 452 |
{ |
| 453 |
client.ReplyHtmlWithHeaderAndParagraph(Languages::TextRouteDoesNotExist); |
| 454 |
return; |
| 455 |
} |
| 456 |
|
| 457 |
const DataModel::Route* route = manager.GetRoute(routeID); |
| 458 |
if (route == nullptr) |
| 459 |
{ |
| 460 |
client.ReplyHtmlWithHeaderAndParagraph(Languages::TextRouteDoesNotExist); |
| 461 |
return; |
| 462 |
} |
| 463 |
|
| 464 |
HtmlTag content; |
| 465 |
const string& routeName = route->GetName(); |
| 466 |
content.AddContent(HtmlTag("h1").AddContent(Languages::TextDeleteRoute)); |
| 467 |
content.AddContent(HtmlTag("p").AddContent(Languages::TextAreYouSureToDelete, routeName)); |
| 468 |
content.AddContent(HtmlTag("form").AddId("editform") |
| 469 |
.AddContent(HtmlTagInputHidden("cmd", "routedelete")) |
| 470 |
.AddContent(HtmlTagInputHidden("route", to_string(routeID)) |
| 471 |
)); |
| 472 |
content.AddContent(HtmlTagButtonCancel()); |
| 473 |
content.AddContent(HtmlTagButtonOK()); |
| 474 |
client.ReplyHtmlWithHeader(content); |
| 475 |
} |
| 476 |
|
| 477 |
void WebClientRoute::HandleRouteDelete(const map<string, string>& arguments) |
| 478 |
{ |
| 479 |
RouteID routeID = Utils::Utils::GetIntegerMapEntry(arguments, "route", RouteNone); |
| 480 |
const DataModel::Route* route = manager.GetRoute(routeID); |
| 481 |
if (route == nullptr) |
| 482 |
{ |
| 483 |
client.ReplyResponse(client.ResponseError, Languages::TextRouteDoesNotExist); |
| 484 |
return; |
| 485 |
} |
| 486 |
|
| 487 |
string name = route->GetName(); |
| 488 |
string result; |
| 489 |
if (!manager.RouteDelete(routeID, result)) |
| 490 |
{ |
| 491 |
client.ReplyResponse(client.ResponseError, result); |
| 492 |
return; |
| 493 |
} |
| 494 |
|
| 495 |
client.ReplyResponse(client.ResponseInfo, Languages::TextRouteDeleted, name); |
| 496 |
} |
| 497 |
|
| 498 |
void WebClientRoute::HandleRouteList() |
| 499 |
{ |
| 500 |
HtmlTag content; |
| 501 |
content.AddChildTag(HtmlTag("h1").AddContent(Languages::TextRoutes)); |
| 502 |
HtmlTag table("table"); |
| 503 |
const map<string,DataModel::Route*> routeList = manager.RouteListByName(); |
| 504 |
map<string,string> routeArgument; |
| 505 |
for (auto& route : routeList) |
| 506 |
{ |
| 507 |
HtmlTag row("tr"); |
| 508 |
row.AddChildTag(HtmlTag("td").AddContent(route.first)); |
| 509 |
const string& routeIdString = to_string(route.second->GetID()); |
| 510 |
routeArgument["route"] = routeIdString; |
| 511 |
row.AddChildTag(HtmlTag("td").AddChildTag(HtmlTagButtonPopupWide(Languages::TextEdit, "routeedit_list_" + routeIdString, routeArgument))); |
| 512 |
row.AddChildTag(HtmlTag("td").AddChildTag(HtmlTagButtonPopupWide(Languages::TextDelete, "routeaskdelete_" + routeIdString, routeArgument))); |
| 513 |
if (route.second->IsInUse()) |
| 514 |
{ |
| 515 |
row.AddChildTag(HtmlTag("td").AddChildTag(HtmlTagButtonCommandWide(Languages::TextRelease, "routerelease_" + routeIdString, routeArgument, "hideElement('b_routerelease_" + routeIdString + "');"))); |
| 516 |
} |
| 517 |
table.AddChildTag(row); |
| 518 |
} |
| 519 |
content.AddChildTag(HtmlTag("div").AddClass("popup_content").AddChildTag(table)); |
| 520 |
content.AddChildTag(HtmlTagButtonCancel()); |
| 521 |
content.AddChildTag(HtmlTagButtonPopupWide(Languages::TextNew, "routeedit_0")); |
| 522 |
client.ReplyHtmlWithHeader(content); |
| 523 |
} |
| 524 |
|
| 525 |
void WebClientRoute::HandleRouteExecute(const map<string, string>& arguments) |
| 526 |
{ |
| 527 |
RouteID routeID = Utils::Utils::GetIntegerMapEntry(arguments, "route", RouteNone); |
| 528 |
manager.RouteExecuteAsync(logger, routeID); |
| 529 |
client.ReplyHtmlWithHeaderAndParagraph("Route executed"); |
| 530 |
} |
| 531 |
|
| 532 |
void WebClientRoute::HandleRouteRelease(const map<string, string>& arguments) |
| 533 |
{ |
| 534 |
RouteID routeID = Utils::Utils::GetIntegerMapEntry(arguments, "route"); |
| 535 |
bool ret = manager.RouteRelease(routeID); |
| 536 |
client.ReplyHtmlWithHeaderAndParagraph(ret ? "Route released" : "Route not released"); |
| 537 |
} |
| 538 |
|
| 539 |
void WebClientRoute::HandleRelationAdd(const map<string, string>& arguments) |
| 540 |
{ |
| 541 |
string priorityString = Utils::Utils::GetStringMapEntry(arguments, "priority", "1"); |
| 542 |
string type = Utils::Utils::GetStringMapEntry(arguments, "type", "atunlock"); |
| 543 |
if (type.compare("atunlock") != 0) |
| 544 |
{ |
| 545 |
type = "atlock"; |
| 546 |
} |
| 547 |
Priority priority = Utils::Integer::StringToInteger(priorityString, 1); |
| 548 |
HtmlTag container; |
| 549 |
container.AddChildTag(HtmlTagRelation(type, priority)); |
| 550 |
container.AddChildTag(HtmlTag("div").AddId("new_" + type + "_priority_" + to_string(priority + 1))); |
| 551 |
client.ReplyHtmlWithHeader(container); |
| 552 |
} |
| 553 |
|
| 554 |
void WebClientRoute::HandleRelationObject(const map<string, string>& arguments) |
| 555 |
{ |
| 556 |
const string priority = Utils::Utils::GetStringMapEntry(arguments, "priority"); |
| 557 |
const string atlock = Utils::Utils::GetStringMapEntry(arguments, "atlock"); |
| 558 |
const ObjectType objectType = static_cast<ObjectType>(Utils::Utils::GetIntegerMapEntry(arguments, "objecttype")); |
| 559 |
const ObjectID id = static_cast<ObjectID>(Utils::Utils::GetIntegerMapEntry(arguments, "id")); |
| 560 |
const DataModel::Relation::Data state = static_cast<DataModel::Relation::Data>(Utils::Utils::GetIntegerMapEntry(arguments, "state")); |
| 561 |
client.ReplyHtmlWithHeader(HtmlTagRelationObject(atlock, priority, objectType, id, state)); |
| 562 |
} |
| 563 |
|
| 564 |
void WebClientRoute::HandleRelationSwitchStates(const map<string, string>& arguments) |
| 565 |
{ |
| 566 |
const string name = Utils::Utils::GetStringMapEntry(arguments, "name"); |
| 567 |
const SwitchID switchId = static_cast<SwitchID>(Utils::Utils::GetIntegerMapEntry(arguments, "switch")); |
| 568 |
client.ReplyHtmlWithHeader(HtmlTagRelationSwitchState(name, switchId)); |
| 569 |
} |
| 570 |
|
| 571 |
HtmlTag WebClientRoute::HtmlTagRelation(const string& atlock, |
| 572 |
const Priority priority, |
| 573 |
const ObjectType objectType, |
| 574 |
const ObjectID objectId, |
| 575 |
const DataModel::Relation::Data state) |
| 576 |
{ |
| 577 |
HtmlTag content("div"); |
| 578 |
string priorityString = to_string(priority); |
| 579 |
string name = "relation_" + atlock + "_" + priorityString; |
| 580 |
content.AddId(name); |
| 581 |
HtmlTagButton deleteButton(Languages::TextDelete, "delete_" + name); |
| 582 |
deleteButton.AddAttribute("onclick", "deleteElement('" + name + "');return false;"); |
| 583 |
deleteButton.AddClass("wide_button"); |
| 584 |
content.AddChildTag(deleteButton); |
| 585 |
|
| 586 |
if (priority > 1) |
| 587 |
{ |
| 588 |
content.AddChildTag(HtmlTagButtonSwapRelation(atlock, priorityString, true)); |
| 589 |
} |
| 590 |
else |
| 591 |
{ |
| 592 |
content.AddChildTag(HtmlTagSpace().AddClass("small_button").AddClass("button_replacement")); |
| 593 |
} |
| 594 |
content.AddChildTag(HtmlTagButtonSwapRelation(atlock, priorityString, false)); |
| 595 |
|
| 596 |
HtmlTag contentObject("div"); |
| 597 |
contentObject.AddId(name + "_object"); |
| 598 |
contentObject.AddClass("inline-block"); |
| 599 |
contentObject.AddChildTag(HtmlTagRelationObject(atlock, priorityString, objectType, objectId, state)); |
| 600 |
content.AddChildTag(contentObject); |
| 601 |
return content; |
| 602 |
} |
| 603 |
|
| 604 |
HtmlTag WebClientRoute::HtmlTagRelationSwitchState(const string& name, |
| 605 |
const SwitchID switchId, |
| 606 |
const DataModel::Relation::Data data) |
| 607 |
{ |
| 608 |
map<DataModel::AccessoryState,Languages::TextSelector> stateOptions; |
| 609 |
Switch* mySwitch = manager.GetSwitch(switchId); |
| 610 |
if (mySwitch != nullptr) |
| 611 |
{ |
| 612 |
stateOptions = mySwitch->GetStateOptions(); |
| 613 |
} |
| 614 |
|
| 615 |
return HtmlTagSelect(name + "_state", stateOptions, static_cast<DataModel::AccessoryState>(data)).AddClass("select_relation_state"); |
| 616 |
} |
| 617 |
|
| 618 |
HtmlTag WebClientRoute::HtmlTagRelationObject(const string& atlock, |
| 619 |
const string& priorityString, |
| 620 |
const ObjectType objectType, |
| 621 |
const ObjectID objectId, |
| 622 |
const DataModel::Relation::Data state) |
| 623 |
{ |
| 624 |
const string name = "relation_" + atlock + "_" + priorityString; |
| 625 |
HtmlTag content; |
| 626 |
map<ObjectType, Languages::TextSelector> objectTypeOptions; |
| 627 |
objectTypeOptions[ObjectTypeAccessory] = Languages::TextAccessory; |
| 628 |
objectTypeOptions[ObjectTypeSignal] = Languages::TextSignal; |
| 629 |
objectTypeOptions[ObjectTypeSwitch] = Languages::TextSwitch; |
| 630 |
objectTypeOptions[ObjectTypeTrack] = Languages::TextTrack; |
| 631 |
objectTypeOptions[ObjectTypeRoute] = Languages::TextRoute; |
| 632 |
objectTypeOptions[ObjectTypeLoco] = Languages::TextLoco; |
| 633 |
objectTypeOptions[ObjectTypeMultipleUnit] = Languages::TextOrientation; |
| 634 |
objectTypeOptions[ObjectTypePause] = Languages::TextPause; |
| 635 |
objectTypeOptions[ObjectTypeBooster] = Languages::TextBooster; |
| 636 |
HtmlTagSelect select(name + "_type", objectTypeOptions, objectType); |
| 637 |
select.AddClass("select_relation_objecttype"); |
| 638 |
select.AddAttribute("onchange", "loadRelationObject('" + atlock + "', '" + priorityString + "');return false;"); |
| 639 |
content.AddChildTag(select); |
| 640 |
|
| 641 |
switch (objectType) |
| 642 |
{ |
| 643 |
case ObjectTypeSwitch: |
| 644 |
{ |
| 645 |
std::map<string, AccessoryConfig> switches = manager.SwitchConfigByName(); |
| 646 |
map<string, SwitchID> switchOptions; |
| 647 |
for (auto& mySwitch : switches) |
| 648 |
{ |
| 649 |
switchOptions[mySwitch.first] = mySwitch.second.GetObjectIdentifier().GetObjectID(); |
| 650 |
} |
| 651 |
SwitchID switchId = objectId; |
| 652 |
if (switchId == SwitchNone && switchOptions.size() > 0) |
| 653 |
{ |
| 654 |
switchId = switchOptions.begin()->second; |
| 655 |
} |
| 656 |
HtmlTagSelect selectSwitch(name + "_id", switchOptions, switchId); |
| 657 |
selectSwitch.AddClass("select_relation_id"); |
| 658 |
selectSwitch.AddAttribute("onchange", "loadRelationObjectStates('switch', '" + name + "', '" + to_string(switchId) + "');return false;"); |
| 659 |
content.AddChildTag(selectSwitch); |
| 660 |
|
| 661 |
HtmlTag contentState("div"); |
| 662 |
contentState.AddId(name + "_state"); |
| 663 |
contentState.AddClass("inline-block"); |
| 664 |
contentState.AddChildTag(HtmlTagRelationSwitchState(name, switchId, state)); |
| 665 |
content.AddChildTag(contentState); |
| 666 |
return content; |
| 667 |
} |
| 668 |
|
| 669 |
case ObjectTypeSignal: |
| 670 |
{ |
| 671 |
std::map<string, AccessoryConfig> signals = manager.SignalConfigByName(); |
| 672 |
map<string, SignalID> signalOptions; |
| 673 |
for (auto& signal : signals) |
| 674 |
{ |
| 675 |
signalOptions[signal.first] = signal.second.GetObjectIdentifier().GetObjectID(); |
| 676 |
} |
| 677 |
SignalID signalId = objectId; |
| 678 |
if (signalId == SignalNone && signalOptions.size() > 0) |
| 679 |
{ |
| 680 |
signalId = signalOptions.begin()->second; |
| 681 |
} |
| 682 |
HtmlTagSelect selectSignal(name + "_id", signalOptions, signalId); |
| 683 |
selectSignal.AddClass("select_relation_id"); |
| 684 |
selectSignal.AddAttribute("onchange", "loadRelationObjectStates('signal', '" + name + "', '" + to_string(signalId) + "');return false;"); |
| 685 |
content.AddChildTag(selectSignal); |
| 686 |
|
| 687 |
HtmlTag contentState("div"); |
| 688 |
contentState.AddId(name + "_state"); |
| 689 |
contentState.AddClass("inline-block"); |
| 690 |
contentState.AddChildTag(client.HtmlTagRelationSignalState(name, signalId, state)); |
| 691 |
content.AddChildTag(contentState); |
| 692 |
return content; |
| 693 |
} |
| 694 |
|
| 695 |
case ObjectTypeAccessory: |
| 696 |
{ |
| 697 |
std::map<string, AccessoryConfig> accessories = manager.AccessoryConfigByName(); |
| 698 |
map<string, AccessoryID> accessoryOptions; |
| 699 |
for (auto& accessory : accessories) |
| 700 |
{ |
| 701 |
accessoryOptions[accessory.first] = accessory.second.GetObjectIdentifier().GetObjectID(); |
| 702 |
} |
| 703 |
content.AddChildTag(HtmlTagSelect(name + "_id", accessoryOptions, objectId).AddClass("select_relation_id")); |
| 704 |
|
| 705 |
map<DataModel::AccessoryState,Languages::TextSelector> stateOptions; |
| 706 |
stateOptions[DataModel::AccessoryStateOn] = Languages::TextOn; |
| 707 |
stateOptions[DataModel::AccessoryStateOff] = Languages::TextOff; |
| 708 |
content.AddChildTag(HtmlTagSelect(name + "_state", stateOptions, static_cast<DataModel::AccessoryState>(state)).AddClass("select_relation_state")); |
| 709 |
return content; |
| 710 |
} |
| 711 |
|
| 712 |
case ObjectTypeTrack: |
| 713 |
{ |
| 714 |
std::map<string, Track*> tracks = manager.TrackListMasterByName(); |
| 715 |
map<string, TrackID> trackOptions; |
| 716 |
for (auto& track : tracks) |
| 717 |
{ |
| 718 |
trackOptions[track.first] = track.second->GetID(); |
| 719 |
} |
| 720 |
content.AddChildTag(HtmlTagSelect(name + "_id", trackOptions, objectId).AddClass("select_relation_id")); |
| 721 |
|
| 722 |
content.AddChildTag(HtmlTagSelectOrientation(name + "_state", static_cast<Orientation>(state)).AddClass("select_relation_state")); |
| 723 |
return content; |
| 724 |
} |
| 725 |
|
| 726 |
case ObjectTypeRoute: |
| 727 |
{ |
| 728 |
std::map<string, Route*> routes = manager.RouteListByName(); |
| 729 |
map<string, RouteID> routeOptions; |
| 730 |
for (auto& route : routes) |
| 731 |
{ |
| 732 |
routeOptions[route.first] = route.second->GetID(); |
| 733 |
} |
| 734 |
content.AddChildTag(HtmlTagSelect(name + "_id", routeOptions, objectId).AddClass("select_relation_id")); |
| 735 |
return content; |
| 736 |
} |
| 737 |
|
| 738 |
case ObjectTypeLoco: |
| 739 |
{ |
| 740 |
map<string,string> functionOptions; |
| 741 |
for (DataModel::LocoFunctionNr function = 0; function < NumberOfLocoFunctions; ++function) |
| 742 |
{ |
| 743 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(function, 3)] = "F" + to_string(function); |
| 744 |
} |
| 745 |
|
| 746 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconShuntingMode, 3)] = Languages::GetText(Languages::TextLocoFunctionIconShuntingMode); |
| 747 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconInertia, 3)] = Languages::GetText(Languages::TextLocoFunctionIconInertia); |
| 748 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconLight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconLight); |
| 749 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconHeadlightLowBeamForward, 3)] = Languages::GetText(Languages::TextLocoFunctionIconHeadlightLowBeamForward); |
| 750 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconHeadlightLowBeamReverse, 3)] = Languages::GetText(Languages::TextLocoFunctionIconHeadlightLowBeamReverse); |
| 751 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconHeadlightHighBeamForward, 3)] = Languages::GetText(Languages::TextLocoFunctionIconHeadlightHighBeamForward); |
| 752 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconHeadlightHighBeamReverse, 3)] = Languages::GetText(Languages::TextLocoFunctionIconHeadlightHighBeamReverse); |
| 753 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBacklightForward, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBacklightForward); |
| 754 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBacklightReverse, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBacklightReverse); |
| 755 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconShuntingLight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconShuntingLight); |
| 756 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBlinkingLight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBlinkingLight); |
| 757 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconInteriorLight1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconInteriorLight1); |
| 758 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconInteriorLight2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconInteriorLight2); |
| 759 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTableLight1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTableLight1); |
| 760 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTableLight2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTableLight2); |
| 761 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTableLight3, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTableLight3); |
| 762 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCabLight1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCabLight1); |
| 763 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCabLight2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCabLight2); |
| 764 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCabLight12, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCabLight12); |
| 765 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconDriversDeskLight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconDriversDeskLight); |
| 766 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTrainDestinationIndicator, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTrainDestinationIndicator); |
| 767 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconLocomotiveNumberIndicator, 3)] = Languages::GetText(Languages::TextLocoFunctionIconLocomotiveNumberIndicator); |
| 768 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconEngineLight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconEngineLight); |
| 769 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFireBox, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFireBox); |
| 770 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconStairsLight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconStairsLight); |
| 771 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSmokeGenerator, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSmokeGenerator); |
| 772 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTelex1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTelex1); |
| 773 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTelex2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTelex2); |
| 774 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTelex12, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTelex12); |
| 775 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconPanto1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconPanto1); |
| 776 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconPanto2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconPanto2); |
| 777 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconPanto12, 3)] = Languages::GetText(Languages::TextLocoFunctionIconPanto12); |
| 778 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconUp, 3)] = Languages::GetText(Languages::TextLocoFunctionIconUp); |
| 779 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconDown, 3)] = Languages::GetText(Languages::TextLocoFunctionIconDown); |
| 780 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconUpDown1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconUpDown1); |
| 781 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconUpDown2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconUpDown2); |
| 782 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconLeft, 3)] = Languages::GetText(Languages::TextLocoFunctionIconLeft); |
| 783 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconRight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconRight); |
| 784 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconLeftRight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconLeftRight); |
| 785 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTurnLeft, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTurnLeft); |
| 786 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTurnRight, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTurnRight); |
| 787 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconTurn, 3)] = Languages::GetText(Languages::TextLocoFunctionIconTurn); |
| 788 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCrane, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCrane); |
| 789 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconMagnet, 3)] = Languages::GetText(Languages::TextLocoFunctionIconMagnet); |
| 790 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCraneHook, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCraneHook); |
| 791 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFan, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFan); |
| 792 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBreak, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBreak); |
| 793 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconNoSound, 3)] = Languages::GetText(Languages::TextLocoFunctionIconNoSound); |
| 794 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSoundGeneral, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSoundGeneral); |
| 795 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconRunning1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconRunning1); |
| 796 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconRunning2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconRunning2); |
| 797 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconEngine1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconEngine1); |
| 798 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconEngine2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconEngine2); |
| 799 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBreak1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBreak1); |
| 800 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBreak2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBreak2); |
| 801 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCurve, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCurve); |
| 802 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconHorn1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconHorn1); |
| 803 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconHorn2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconHorn2); |
| 804 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconWhistle1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconWhistle1); |
| 805 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconWhistle2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconWhistle2); |
| 806 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBell, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBell); |
| 807 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconStationAnnouncement1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconStationAnnouncement1); |
| 808 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconStationAnnouncement2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconStationAnnouncement2); |
| 809 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconStationAnnouncement3, 3)] = Languages::GetText(Languages::TextLocoFunctionIconStationAnnouncement3); |
| 810 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSpeak, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSpeak); |
| 811 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconRadio, 3)] = Languages::GetText(Languages::TextLocoFunctionIconRadio); |
| 812 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconMusic1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconMusic1); |
| 813 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconMusic2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconMusic2); |
| 814 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconOpenDoor, 3)] = Languages::GetText(Languages::TextLocoFunctionIconOpenDoor); |
| 815 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCloseDoor, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCloseDoor); |
| 816 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFan1, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFan1); |
| 817 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFan2, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFan2); |
| 818 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFan3, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFan3); |
| 819 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconShovelCoal, 3)] = Languages::GetText(Languages::TextLocoFunctionIconShovelCoal); |
| 820 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCompressedAir, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCompressedAir); |
| 821 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconReliefValve, 3)] = Languages::GetText(Languages::TextLocoFunctionIconReliefValve); |
| 822 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSteamBlowOut, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSteamBlowOut); |
| 823 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSteamBlow, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSteamBlow); |
| 824 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconDrainValve, 3)] = Languages::GetText(Languages::TextLocoFunctionIconDrainValve); |
| 825 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconShakingRust, 3)] = Languages::GetText(Languages::TextLocoFunctionIconShakingRust); |
| 826 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconAirPump, 3)] = Languages::GetText(Languages::TextLocoFunctionIconAirPump); |
| 827 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconWaterPump, 3)] = Languages::GetText(Languages::TextLocoFunctionIconWaterPump); |
| 828 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconBufferPush, 3)] = Languages::GetText(Languages::TextLocoFunctionIconBufferPush); |
| 829 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconGenerator, 3)] = Languages::GetText(Languages::TextLocoFunctionIconGenerator); |
| 830 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconGearBox, 3)] = Languages::GetText(Languages::TextLocoFunctionIconGearBox); |
| 831 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconGearUp, 3)] = Languages::GetText(Languages::TextLocoFunctionIconGearUp); |
| 832 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconGearDown, 3)] = Languages::GetText(Languages::TextLocoFunctionIconGearDown); |
| 833 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFillWater, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFillWater); |
| 834 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFillDiesel, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFillDiesel); |
| 835 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconFillGas, 3)] = Languages::GetText(Languages::TextLocoFunctionIconFillGas); |
| 836 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSand, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSand); |
| 837 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconRailJoint, 3)] = Languages::GetText(Languages::TextLocoFunctionIconRailJoint); |
| 838 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconCoupler, 3)] = Languages::GetText(Languages::TextLocoFunctionIconCoupler); |
| 839 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconPanto, 3)] = Languages::GetText(Languages::TextLocoFunctionIconPanto); |
| 840 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconMainSwitch, 3)] = Languages::GetText(Languages::TextLocoFunctionIconMainSwitch); |
| 841 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSoundLouder, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSoundLouder); |
| 842 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconSoundLower, 3)] = Languages::GetText(Languages::TextLocoFunctionIconSoundLower); |
| 843 |
functionOptions[Utils::Utils::ToStringWithLeadingZeros(256 + LocoFunctionIconNoBreak, 3)] = Languages::GetText(Languages::TextLocoFunctionIconNoBreak); |
| 844 |
|
| 845 |
content.AddChildTag(HtmlTagSelect(name + "_id", functionOptions, Utils::Utils::ToStringWithLeadingZeros(objectId, 3)).AddClass("select_relation_id")); |
| 846 |
|
| 847 |
// FIXME: load available functions of loco |
| 848 |
map<DataModel::LocoFunctionState,string> stateOptions; |
| 849 |
stateOptions[DataModel::LocoFunctionStateOff] = Languages::GetText(Languages::TextOff); |
| 850 |
stateOptions[DataModel::LocoFunctionStateOn] = Languages::GetText(Languages::TextOn); |
| 851 |
stateOptions[DataModel::LocoFunctionState0s5] = "0.5s"; |
| 852 |
stateOptions[DataModel::LocoFunctionState1s0] = "1s"; |
| 853 |
stateOptions[DataModel::LocoFunctionState1s5] = "1.5s"; |
| 854 |
stateOptions[DataModel::LocoFunctionState2s0] = "2s"; |
| 855 |
content.AddChildTag(HtmlTagSelect(name + "_state", stateOptions, static_cast<DataModel::LocoFunctionState>(state)).AddClass("select_relation_state")); |
| 856 |
return content; |
| 857 |
} |
| 858 |
|
| 859 |
case ObjectTypePause: |
| 860 |
{ |
| 861 |
map<unsigned int,string> time; |
| 862 |
time[1u] = "0.1s"; |
| 863 |
time[2u] = "0.2s"; |
| 864 |
time[3u] = "0.3s"; |
| 865 |
time[4u] = "0.4s"; |
| 866 |
time[5u] = "0.5s"; |
| 867 |
time[6u] = "0.6s"; |
| 868 |
time[7u] = "0.7s"; |
| 869 |
time[8u] = "0.8s"; |
| 870 |
time[9u] = "0.9s"; |
| 871 |
time[10u] = "1s"; |
| 872 |
time[15u] = "1.5s"; |
| 873 |
time[20u] = "2s"; |
| 874 |
time[25u] = "2.5s"; |
| 875 |
time[30u] = "3s"; |
| 876 |
time[40u] = "4s"; |
| 877 |
time[50u] = "5s"; |
| 878 |
time[60u] = "6s"; |
| 879 |
time[70u] = "7s"; |
| 880 |
time[80u] = "8s"; |
| 881 |
time[90u] = "9s"; |
| 882 |
time[100u] = "10s"; |
| 883 |
content.AddChildTag(HtmlTagSelect(name + "_state", time, static_cast<unsigned int>(state)).AddClass("select_relation_state")); |
| 884 |
return content; |
| 885 |
} |
| 886 |
|
| 887 |
case ObjectTypeMultipleUnit: // abused for loco orientation |
| 888 |
{ |
| 889 |
map<unsigned int,string> orientation; |
| 890 |
orientation[0] = Languages::Languages::GetText(Languages::Languages::TextLeft); |
| 891 |
orientation[1u] = Languages::Languages::GetText(Languages::Languages::TextRight); |
| 892 |
orientation[2u] = Languages::Languages::GetText(Languages::Languages::TextChange);; |
| 893 |
content.AddChildTag(HtmlTagSelect(name + "_state", orientation, static_cast<unsigned int>(state)).AddClass("select_relation_state")); |
| 894 |
return content; |
| 895 |
} |
| 896 |
|
| 897 |
case ObjectTypeBooster: |
| 898 |
{ |
| 899 |
map<unsigned int,string> booster; |
| 900 |
booster[0] = Languages::Languages::GetText(Languages::Languages::TextOff); |
| 901 |
booster[1u] = Languages::Languages::GetText(Languages::Languages::TextOn); |
| 902 |
content.AddChildTag(HtmlTagSelect(name + "_state", booster, static_cast<unsigned int>(state)).AddClass("select_relation_state")); |
| 903 |
return content; |
| 904 |
} |
| 905 |
|
| 906 |
default: |
| 907 |
{ |
| 908 |
content.AddContent(Languages::TextUnknownObjectType); |
| 909 |
return content; |
| 910 |
} |
| 911 |
} |
| 912 |
} |
| 913 |
|
| 914 |
HtmlTag WebClientRoute::HtmlTagSelectTrack(const std::string& name, |
| 915 |
const Languages::TextSelector label, |
| 916 |
const TrackID trackID, |
| 917 |
const Orientation orientation, |
| 918 |
const string& onchange) const |
| 919 |
{ |
| 920 |
HtmlTag tag; |
| 921 |
map<string,TrackID> tracks = manager.TrackListIdByName(); |
| 922 |
HtmlTagSelectWithLabel selectTrack(name + "track", label, tracks, trackID); |
| 923 |
selectTrack.AddClass("select_track"); |
| 924 |
if (onchange.size() > 0) |
| 925 |
{ |
| 926 |
selectTrack.AddAttribute("onchange", onchange); |
| 927 |
} |
| 928 |
tag.AddChildTag(selectTrack); |
| 929 |
tag.AddChildTag(HtmlTagSelectOrientation(name + "orientation", orientation).AddClass("select_orientation")); |
| 930 |
return tag; |
| 931 |
} |
| 932 |
|
| 933 |
HtmlTag WebClientRoute::HtmlTagSelectFeedbacksOfTrack(const TrackID trackID, |
| 934 |
const RouteID followUpRoute, |
| 935 |
const FeedbackID feedbackIdReduced, |
| 936 |
const Delay reducedDelay, |
| 937 |
const FeedbackID feedbackIdCreep, |
| 938 |
const Delay creepDelay, |
| 939 |
const FeedbackID feedbackIdStop, |
| 940 |
const Delay stopDelay, |
| 941 |
const FeedbackID feedbackIdOver) const |
| 942 |
{ |
| 943 |
HtmlTag tag; |
| 944 |
map<RouteID,string> followUpRouteOptions = manager.RoutesOfTrack(trackID); |
| 945 |
followUpRouteOptions[RouteStop] = Languages::Languages::GetText(Languages::TextNone); |
| 946 |
followUpRouteOptions[RouteAuto] = Languages::Languages::GetText(Languages::TextSelectAutomatically); |
| 947 |
tag.AddChildTag(HtmlTagSelectWithLabel("followuproute", Languages::TextFollowUpRoute, followUpRouteOptions, followUpRoute)); |
| 948 |
|
| 949 |
map<string,FeedbackID> feedbacks = manager.FeedbacksOfTrack(trackID); |
| 950 |
map<string,FeedbackID> feedbacksWithNone = feedbacks; |
| 951 |
feedbacksWithNone["-"] = FeedbackNone; |
| 952 |
map<string,Delay> delayOptions; |
| 953 |
delayOptions["0.0s"] = 0; |
| 954 |
delayOptions["0.1s"] = 1; |
| 955 |
delayOptions["0.2s"] = 2; |
| 956 |
delayOptions["0.3s"] = 3; |
| 957 |
delayOptions["0.4s"] = 4; |
| 958 |
delayOptions["0.5s"] = 5; |
| 959 |
delayOptions["0.6s"] = 6; |
| 960 |
delayOptions["0.7s"] = 7; |
| 961 |
delayOptions["0.8s"] = 8; |
| 962 |
delayOptions["0.9s"] = 9; |
| 963 |
delayOptions["1.0s"] = 10; |
| 964 |
delayOptions["1.5s"] = 15; |
| 965 |
delayOptions["2.0s"] = 20; |
| 966 |
delayOptions["2.5s"] = 25; |
| 967 |
delayOptions["3.0s"] = 30; |
| 968 |
delayOptions["3.5s"] = 35; |
| 969 |
delayOptions["4.0s"] = 40; |
| 970 |
delayOptions["4.5s"] = 45; |
| 971 |
delayOptions["5.0s"] = 50; |
| 972 |
delayOptions["6.0s"] = 60; |
| 973 |
delayOptions["7.0s"] = 70; |
| 974 |
delayOptions["8.0s"] = 80; |
| 975 |
delayOptions["9.0s"] = 90; |
| 976 |
|
| 977 |
tag.AddChildTag(HtmlTagSelectWithLabel("feedbackreduced", Languages::TextReducedSpeedAt, feedbacksWithNone, feedbackIdReduced).AddClass("select_feedback")); |
| 978 |
tag.AddChildTag(HtmlTagSelect("reduceddelay", delayOptions, reducedDelay).AddClass("select_delay")); |
| 979 |
tag.AddChildTag(HtmlTagSelectWithLabel("feedbackcreep", Languages::TextCreepAt, feedbacksWithNone, feedbackIdCreep).AddClass("select_feedback")); |
| 980 |
tag.AddChildTag(HtmlTagSelect("creepdelay", delayOptions, creepDelay).AddClass("select_delay")); |
| 981 |
tag.AddChildTag(HtmlTagSelectWithLabel("feedbackstop", Languages::TextStopAt, feedbacks, feedbackIdStop).AddClass("select_feedback")); |
| 982 |
tag.AddChildTag(HtmlTagSelect("stopdelay", delayOptions, stopDelay).AddClass("select_delay")); |
| 983 |
tag.AddChildTag(HtmlTagSelectWithLabel("feedbackover", Languages::TextOverrunAt, feedbacksWithNone, feedbackIdOver).AddClass("select_feedback")); |
| 984 |
return tag; |
| 985 |
} |
| 986 |
|
| 987 |
void WebClientRoute::HandleFeedbacksOfTrack(const map<string, string>& arguments) |
| 988 |
{ |
| 989 |
const TrackID trackID = static_cast<TrackID>(Utils::Utils::GetIntegerMapEntry(arguments, "track", TrackNone)); |
| 990 |
client.ReplyHtmlWithHeader(HtmlTagSelectFeedbacksOfTrack(trackID)); |
| 991 |
} |
| 992 |
}} // namespace Server::Web |