Improved installer, and added more info to readme.

This commit is contained in:
Andrew Lalis 2022-05-30 09:08:25 +02:00
parent 637dee747d
commit b84f271a40
3 changed files with 34 additions and 3 deletions

View File

@ -1,6 +1,12 @@
# Rail Signal
A comprehensive solution to tracking and managing your rail system, in real time.
## Setup
To set up your own Rail Signal, system, you will need to follow the following steps:
1. Download and run the Rail Signal API and web app. Go to the [releases](https://github.com/andrewlalis/RailSignalAPI/releases) page to download the latest release. Then, place the JAR file in your desired location, and run it with `java -jar rail-signal.jar`.
2. Open the web app (http://localhost:8080 by default) and create a new rail system, and add components and segments to build your network. More information about this will be given later.
3. Add components to your actual rail system, and install a driver script onto your device. For Minecraft rail systems using Immersive railroading and some computer mod, you can run `pastebin run jKyAiE8k` to run an installation script. *Please make an issue if you have a system for which there is not yet any available driver.*
## Development
To work on and develop Rail Signal, you will need to run both the Java/Spring-Boot backend API, and the Vue/Quasar frontend app.

View File

@ -6,8 +6,12 @@ import nl.andrewl.railsignalapi.dao.ComponentRepository;
import nl.andrewl.railsignalapi.dao.LinkTokenRepository;
import nl.andrewl.railsignalapi.live.dto.ComponentDataMessage;
import nl.andrewl.railsignalapi.live.dto.ComponentMessage;
import nl.andrewl.railsignalapi.live.dto.SegmentStatusMessage;
import nl.andrewl.railsignalapi.live.dto.SwitchUpdateMessage;
import nl.andrewl.railsignalapi.live.websocket.AppUpdateService;
import nl.andrewl.railsignalapi.model.component.Component;
import nl.andrewl.railsignalapi.model.component.Signal;
import nl.andrewl.railsignalapi.model.component.Switch;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -52,6 +56,19 @@ public class ComponentDownlinkService {
downlink.send(msg);
appUpdateService.sendUpdate(c.getRailSystem().getId(), msg);
// Send initial data updates to make sure that devices' state is up to date immediately.
if (c instanceof Signal sig) {
downlink.send(new SegmentStatusMessage(c.getId(), sig.getSegment().getId(), sig.getSegment().isOccupied()));
} else if (c instanceof Switch sw) {
long activeConfigId;
if (sw.getActiveConfiguration() != null) {
activeConfigId = sw.getActiveConfiguration().getId();
} else {
activeConfigId = sw.getPossibleConfigurations().stream().findAny().orElseThrow().getId();
}
downlink.send(new SwitchUpdateMessage(c.getId(), activeConfigId));
}
Set<ComponentDownlink> downlinks = downlinksByCId.computeIfAbsent(c.getId(), aLong -> new HashSet<>());
downlinks.add(downlink);
}

View File

@ -148,12 +148,20 @@ end
-- SCRIPT START
local config = {}
local args = {...}
print("Rail Signal Driver Installer for CC:Tweaked")
print("-------------------------------------------")
print("Please enter the base URL for your Rail System site.")
print(" For example: http://localhost:8080")
local baseUrl = readUrl()
if #args < 1 then
print("Error: Missing required baseURL argument.")
return
end
local baseUrl = args[1]
config.apiUrl = baseUrl .. "/api"
local statusResponse = http.get(config.apiUrl .. "/status")
if not statusResponse then
print("Error: Could not reach the the Rail Signal system at " .. config.apiUrl .. "/status")
return
end
if startsWith(baseUrl, "https") then
config.wsUrl = "wss" .. string.sub(baseUrl, 6) .. "/api/ws/component"
else