bleh
This commit is contained in:
parent
ea2e747805
commit
1ae94ca7ad
134
init.lua
134
init.lua
@ -2,66 +2,96 @@
|
|||||||
-- Ich weiss jetzt noch nicht, wie viele verschiedene Versionen von dem Script spaeter herumfliegen werden.
|
-- Ich weiss jetzt noch nicht, wie viele verschiedene Versionen von dem Script spaeter herumfliegen werden.
|
||||||
KsKitVer=0
|
KsKitVer=0
|
||||||
|
|
||||||
Kennzahl=34
|
-- Grundsätzliche Typen von Signalbildern
|
||||||
|
FAHRT=1
|
||||||
|
HALT=2
|
||||||
|
RANGIERFAHRT=3
|
||||||
|
ERSATZFAHRT=4
|
||||||
|
AUS=5
|
||||||
|
|
||||||
local Callbacks = {}
|
-- Signalbilder des Hv-Signalsystems
|
||||||
|
Hp0={HALT}
|
||||||
|
Hp1={FAHRT}
|
||||||
|
Hp2={FAHRT, V_max=40}
|
||||||
|
Vr0={FAHRT, H_erwarten=true}
|
||||||
|
Vr1={FAHRT}
|
||||||
|
Vr2={FAHRT, V_erwarten=40}
|
||||||
|
|
||||||
function On(Name, Funktion)
|
-- Signalbilder OSJD/EZMG/Hl-Signale des Ostblocks
|
||||||
-- Erlaube es, Signal und Weichen via Nummer zu referenzieren
|
-- V_erwarten=60 wird durch V_erwarten=40 signalisiert
|
||||||
if type(Name) == "number" then
|
Hl1={FAHRT}
|
||||||
if EEPGetSwitch(Name) > 0 then
|
Hl2={FAHRT, V_max=100}
|
||||||
Name = "EEPOnSwitch_"..tostring(Name)
|
Hl3a={FAHRT, V_max=40}
|
||||||
elseif EEPGetSignal(Name) > 0 then
|
Hl3b={FAHRT, V_max=60}
|
||||||
Name = "EEPOnSignal_"..tostring(Name)
|
Hl4={FAHRT, V_erwarten=100}
|
||||||
|
Hl5={FAHRT, V_max=100, V_erwarten=100}
|
||||||
|
Hl6a={FAHRT, V_max=40, V_erwarten=100}
|
||||||
|
Hl6b={FAHRT, V_max=60, V_erwarten=100}
|
||||||
|
Hl7={FAHRT, V_erwarten=40}
|
||||||
|
Hl8={FAHRT, V_max=100, V_erwarten=40}
|
||||||
|
Hl9a={FAHRT, V_max=40, V_erwarten=40}
|
||||||
|
Hl9b={FAHRT, V_max=60, V_erwarten=40}
|
||||||
|
Hl10={FAHRT, H_erwarten=true}
|
||||||
|
Hl11={FAHRT, V_max=100, H_erwarten=true}
|
||||||
|
Hl12a={FAHRT, V_max=40, H_erwarten=true}
|
||||||
|
Hl12b={FAHRT, V_max=60, H_erwarten=true}
|
||||||
|
Hl13={HALT}
|
||||||
|
|
||||||
|
-- Zusatzsignale (DS 301 Namen)
|
||||||
|
Zs1={ERSATZFAHRT}
|
||||||
|
Sh1={RANGIERFAHRT} -- war Ra12 bei DR
|
||||||
|
|
||||||
|
-- Signalebilder der jeweiligen Signalmodelle
|
||||||
|
Signalmodelle={
|
||||||
|
-- V11NHK10024 HL-Signale der DR *V40* - Grundset
|
||||||
|
["Hl_Signal_Ausfahrt_V40_HK1"]={ Hl13,Hl1,Hl3a,Zs1,Sh1,Hl13 },
|
||||||
|
["Hl_Signal_Ausfahrt_Vmax_HK1"]={ Hl13,Hl1,Zs1,Sh1,Hl13 },
|
||||||
|
["Hl_Signal_Block_HK1"]={ Hl13,Hl1,Zs1,Hl13 },
|
||||||
|
["Hl_Signal_Einfahrt_V40_HK1"]={ Hl13,Hl1,Hl7,Hl10,Hl3a,Hl9a,Hl12a,Zs1,Hl13 },
|
||||||
|
["Hl_Signal_Selbstblock_HK1"]={ Hl13,Hl1,Hl10,Hl13 },
|
||||||
|
["Hl_Signal_Vorsignal_V40_HK1"]={ Hl10,Hl7,Hl1 },
|
||||||
|
["Hl_Signal_Vorsignalwiederholer_V40_HK1"]={ Hl10,Hl7,Hl1 },
|
||||||
|
-- V11NHK10025 HL-Signale der DR *V60* - Erweiterungsset
|
||||||
|
["Hl_Signal_Ausfahrt_V60_HK1"]={ Hl13,Hl1,Hl3b,Hl3a,Zs1,Sh1,Hl13 },
|
||||||
|
["Hl_Signal_Einfahrt_V60_HK1"]={ Hl13,Hl1,Hl4,Hl7,Hl10,Hl3b,Hl6b,Hl9b,Hl12b,Hl3a,Hl6a,Hl9a,Hl12a,Zs1,Hl13 },
|
||||||
|
["Hl_Signal_Vorsignalwiederholer_V60_HK1"]={ Hl10,Hl7,Hl1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
Signalmeta = {}
|
||||||
|
|
||||||
|
Signalmeta.__call= function(table, data)
|
||||||
|
local sigobj = {}
|
||||||
|
local mt = {}
|
||||||
|
mt.__index = table
|
||||||
|
setmetatable(sigobj, mt)
|
||||||
|
for k, v in pairs(data) do
|
||||||
|
local setter = "set_"..tostring(k)
|
||||||
|
if type(sigobj[setter]) == "function" then
|
||||||
|
sigobj[setter](sigobj, v)
|
||||||
|
else
|
||||||
|
error("Invalid signal property "..tostring(k))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if type(Name) == "table" then
|
return sigobj
|
||||||
for _, Newname in pairs(Name) do
|
|
||||||
On(Newname, Funktion)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if type(Name) ~= "string" or string.match(Name, "EEP.+") == nil then
|
|
||||||
print("Verweigere Callback von "..type(Name).." "..tostring(Name))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if not Callbacks[Name] then
|
|
||||||
Callbacks[Name] = {}
|
|
||||||
if _G[Name] ~= nil then
|
|
||||||
print("Warnung: "..Name.."() von KsKit adoptiert")
|
|
||||||
table.insert(Callbacks[Name], _G[Name])
|
|
||||||
end
|
|
||||||
_G[Name] = function(...)
|
|
||||||
for cnt = 1, #Callbacks[Name] do
|
|
||||||
Callbacks[Name][cnt](...)
|
|
||||||
end
|
|
||||||
-- Nur EEPMain braucht dies, aber dringends
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
-- Bei Weichen und Signalen muss EEP vorher informiert werden
|
|
||||||
-- Item ist normal "Switch" oder "Signal"
|
|
||||||
local Item, Number = string.match(Name, 'EEPOn(.+)_(%d+)')
|
|
||||||
if Number ~= nil then
|
|
||||||
_G["EEPRegister"..Item](Number)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(Callbacks[Name], Funktion)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- EEPMain-Callback registrieren
|
-- Basisklasse fuer alle Signale
|
||||||
function Main(Funktion)
|
-- Entspricht den Signalen von vor EEP 6: Stellung 1 ist Fahrt, Stellung 2 ist Halt
|
||||||
On("EEPMain", Funktion)
|
Basissignal = {
|
||||||
|
Begriffe = { Hp1, Hp0 }
|
||||||
|
}
|
||||||
|
setmetatable(Basissignal, Signalmeta)
|
||||||
|
|
||||||
|
function Basissignal:set_1(v)
|
||||||
|
if type(v) ~= "number" then
|
||||||
|
error("Signal ID must be number")
|
||||||
|
end
|
||||||
|
self.ID = v
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Signal-Callback registrieren
|
USignal = {}
|
||||||
function OnSignal(Signal, Funktion)
|
setmetatable(USignal, Signalmeta)
|
||||||
On("EEPOnSignal_"..tostring(Signal), Funktion)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weichen-Callbacks registrieren
|
|
||||||
function OnSwitch(Switch, Funktion)
|
|
||||||
On("EEPOnSwitch_"..tostring(Switch), Funktion)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Datenbank fuer Tabelle
|
-- Datenbank fuer Tabelle
|
||||||
KsFahrstrassen = {}
|
KsFahrstrassen = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user