ATCS Notifications - Full Tutorial (text, email, and more)

Locomotive identification, railfan locations, frequency information, etc. can be found here.
User avatar
J3rsdm5
Speak softly and carry a big tripod
Posts: 360
Joined: Sat Jul 30, 2016 5:29 pm
Location: Chandler, AZ
Contact:

ATCS Notifications - Full Tutorial (text, email, and more)

Unread post by J3rsdm5 »

Here's a guide to set up notifications for movements shown on ATCS Monitor. It may not be the most efficient way to go about doing this, but it is the way I was able to make it work reliably. Feel free to leave questions, issues, and suggestions below!

Table of Contents
  • Required Tools
  • How it works
  • ATCS Monitor - Configuring Rules
  • AutoHotKey - Checking the Text File
  • IFTTT - Receiving the Notification
_________________________________________________________________________________________________________________________________________

Required Tools
  • Computer with ATCS Monitor installed. For best results, a computer that can stay powered on with a constant internet connection throughout the day. (You can find a great installation tutorial for ATCS Monitor here: http://atcswiki-beta.greatlakesnetworki ... edOverview)
  • Any internet connected smart device that you typically carry with you. (A smartphone works best)
  • AutoHotKey. (A quite useful tool for automating actions on your computer: https://autohotkey.com)
  • The IFTTT app. (Also a great automation tool, but mainly for web-based services.)
    Android: https://goo.gl/7koAiK iOS: https://goo.gl/ufBDh7
    If you would not prefer to sign in with your Google account, make sure to sign up for an account here: https://ifttt.com
  • Notepad or any code-editing program of your choice. (Every Windows computer comes with Notepad pre-installed. My preference is Notepad++ )
  • MonitoringScript.ahk (This is an AutoHotKey script that will check the file for contents. Download here: https://goo.gl/2tvviR)
If you downloaded MonitoringScript.ahk before 12/10/2017 at 22:33, I have now fixed a critical bug. You can redownload it above, my apologies!
_________________________________________________________________________________________________________________________________________

How it Works

For those curious, here's what the system will look like when you finish setting it up. This may also indirectly assist with general troubleshooting.

1. The dispatcher lines a train in whichever direction you would like to receive notifications about.
2. The signal sent is picked up by the antenna and sent as a packet across the internet to your computer. (probably something along those lines)
3. ATCS Monitor interprets those packets as track data, and checks if the data received matches the rules you have set.
4. If a match is found, ATCS Monitor writes the packet to a text file.
5. AutoHotKey checks the text file every 30 seconds to see if it contains data. If data is found, it sends an HTTP request to the WebHooks service, which is connected to IFTTT.
6. IFTTT sees the request, then sends a push notification, an email, a text, or whatever type of notification that you have configured, to your phone.
7. Run out to the tracks! :D

Image

_________________________________________________________________________________________________________________________________________

ATCS Monitor - Configuring Rules

ATCS Monitor rules can perform actions on your computer when a clear signal is detected at a certain place, a train occupies a specific block, or any of the other pieces of information gleaned from incoming packets is received.

1. In the "Configure" menu at the top of the main window, open the "Rules..." page.
2. The only rule you should see at the moment is "DataGrams". Leave this one checked.
3. Click "New Rule..." on the bottom left.
4. In the "Name of rule..." field, fill in a name that will remind you what the function of the rule is. I used location and direction.
5. Fill in the "Address Matches:" field with address of the place you would like to monitor. The address is the long number next to the name of your desired location in the "Active MCP Window".
6. Fill in the "Mnemonic matches:" field. This tells ATCS Monitor which indication to activate the rule for. For Elmdale and Fox, the mnemonic denoting a request for the signal to clear for an eastbound is "EGZ", while "WGZ" is a request for a clear for westbounds.

There are many mnemonics to choose from that indicate different commands. For a full reference list, refer to http://atcswiki-beta.greatlakesnetworki ... kReference


:!: Double check! If you're not monitoring Elmdale or Fox, be sure that you have the right mnemonics! Use the Quick Reference link above, or wait for the dispatcher display to show what you're monitoring for (in this case a signal indication), then immediately hold the incoming packets with the "Hold Packet Display" button in the top toolbar of the main window. Look for the packet with the text "CODELINE_CONTROL_MSG" and look for the large group of three letters separated by commas within the same packet. Look up each of these three letter combinations in the Quick Reference for the correct three letters to fill in the mnemonic field. (I hope that makes sense :D )



Image


7. Near the bottom, you can check any of the boxes you like to get notifications, but for our purposes in this tutorial, check the "Log message to file" option.
8. Click the "Filename" button.
9. Now navigate to where you like to store a text file that both ATCS Monitor and AutoHotKey will use.
10. Right click>New>Text File. Name the text file whatever you would like, and hit enter.
11. Right click on the text file, click "Properties", then click "Details".
12. Find the Folder Path, and write it down. You will need this later.

The folder path should look something like: "C:\Users\YOUR_ACCOUNT_HERE\Documents"
Add your text file's name to the end of your written down path, so wherever you wrote it down it now looks like "C:\Users\YOUR_ACCOUNT_HERE\Documents\YOUR_FILENAME.txt"

13. Click "Ok", then head back to ATCS Monitor, click "Ok" in the New Rule window, then click "Close" in the Configure Rules window.

:!: Make sure to save the profile before exiting ATCS Monitor, or else your new rule will be gone next time you open ATCS Mon! Click File > Save Profile

_________________________________________________________________________________________________________________________________________

AutoHotKey - Checking the Text File

"AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks such as: form fillers, auto-clicking, macros, etc." (From https://autohotkey.com) We will use AutoHotKey to check if the text file we created contains data. (Written by ATCS Monitor) If so, it will send an HTTP request to IFTTT.

1. If you haven't already, install AutoHotKey from https://autohotkey.com.
2. Give it a run to check if everything is working properly. If greeted by a welcome screen, you can exit the program.
3. Find MonitoringScript.ahk, Right click > Open with > Notepad. (Downloaded earlier. If not, download here: https://goo.gl/VCNvam)


(This is Notepad++, which is built for writing and editing code. Default Notepad works as well, this just formats code in a way much easier to see and interpret.)
Image

Image Key:
1. Replace this with the File Path you wrote earlier.
2. This is the URL that is sent the HTTP request. We will replace it later on with the one that will be connected to your IFTTT account.
3. This is the amount of time that AutoHotKey waits before checking the text file again. It can be easily changed to whatever best fits your intentions. The time is in milliseconds, so 1000 milliseconds = 1 second. Warning: I forgot this when first setting it up and accidentally had it running 100 times per second. That's a big CPU hog, so make sure to double check!
4. Save and exit.

_________________________________________________________________________________________________________________________________________

IFTTT - Getting the Notification

"IFTTT is the free way to get all your apps and devices talking to each other. Not everything on the internet plays nice, so we're on a mission to build a more connected world." (From https://ifttt.com) If This Then That (IFTTT) is one of the most useful web services I have ever come across. You can easily connect it to hundreds of smart devices and websites in order to automate tasks. We will be using it to send the notification to your device; the last piece of the puzzle.

1. Sign into your account on the website. If you would like, you can disable the default applet that sends you their newsletter by going to the "My Applets" page. Also sign into the app on your mobile device, and make sure that notifications are allowed.
2. Click on your username in the top right corner, then click New Applet.
3. Click "+this", then in the Search services field, type "Webhooks".
4. Click Webhooks, hit Connect, then click "Receive a web request"
5. Type out whatever you would like the trigger to be. I chose "train_coming".
6. Click Connect, click "+that", and here's where the fun begins.

Image

7. Now you can choose any service you like to get a notification. Text, call, email, notification, flash your smart lightbulbs, many many things. For this tutorial, and for those who go part of the work day without cell signal but still have an internet connection (yours truly), we'll go with a notification from the IFTTT app.
8. Search for "Notifications" in the Search services field, and click through to Step 5, "Complete action fields"
9. Type whatever works for you to let you know about the specific action taking place on the railroad. This one is configured for Elmdale, so I used "Eastbound lined at Elmdale".
10. Now click through and hit Finish.
11. Remember the URL I mentioned in the AutoHotKey section? The last step is to replace the URL in MonitoringScript.ahk with the one generated for your account. Go back to the IFTTT main page, click your username again, but this time, click: "Services."
12. Go to Webhooks, then in the top right, click Documentation.
13. Replace "{event}" with the event trigger you chose. Mine was train_coming.

Now you have a URL that should look something like: https://maker.ifttt.com/trigger/train_c ... ateKeyHere

14. Copy and paste this URL into your web browser to test that the notifications are working.
15. Now replace the current URL in MonitoringScript.ahk with this one, then save and exit.
16. Double click on MonitoringScript.ahk wherever you saved it in order to get it running. You should see a small AutoHotKey logo in the taskbar to show if it is running. Keep in mind, this script and ATCS Monitor must both be running in order to receive notifications!
17. As a final test, open the text file, type over 200 characters, then save and exit. (You can copy and paste this sentence around 10 times for the sake convenience if desired.)
18. A notification should arrive within 45 seconds and the text file should be empty when you open it again.

Now just wait for the next train, and if a notification arrives, you're all set!

Congratulations! If all went according to plan, you now have a working notification system for oncoming trains! I've been using this system for about a week or so, and it works wonders. :D Let me know if you have any questions or issues, and tell me how it went!
Last edited by J3rsdm5 on Sun Dec 10, 2017 10:39 pm, edited 4 times in total.
"If it ain't all red, it ain't red at all"
Image JJRicks Studios

User avatar
amtrak1007
MP 25 Productions Co-Founder
Posts: 2978
Joined: Wed Apr 12, 2006 12:55 am
Location: Fisher FB97
Contact:

Re: ATCS Notifications - Full Tutorial (text, email, and mor

Unread post by amtrak1007 »

can I copy this over to the atcs wiki? this is good stuff right here!

User avatar
J3rsdm5
Speak softly and carry a big tripod
Posts: 360
Joined: Sat Jul 30, 2016 5:29 pm
Location: Chandler, AZ
Contact:

Re: ATCS Notifications - Full Tutorial (text, email, and mor

Unread post by J3rsdm5 »

amtrak1007 wrote:can I copy this over to the atcs wiki? this is good stuff right here!
Absolutely, thanks! :D
"If it ain't all red, it ain't red at all"
Image JJRicks Studios

User avatar
amtrak1007
MP 25 Productions Co-Founder
Posts: 2978
Joined: Wed Apr 12, 2006 12:55 am
Location: Fisher FB97
Contact:

Re: ATCS Notifications - Full Tutorial (text, email, and mor

Unread post by amtrak1007 »

OK got a note here since i've now reread the whole thing EGZ/WGZ are the controls ASKING for the signal EGK/WGK's would be the indication back from the signal that these states actually have taken place. Same for NWK/RWK for switch positions, or the new fun one SMK for snow melter's on....

Other than that nice job!!!!

User avatar
J3rsdm5
Speak softly and carry a big tripod
Posts: 360
Joined: Sat Jul 30, 2016 5:29 pm
Location: Chandler, AZ
Contact:

Re: ATCS Notifications - Full Tutorial (text, email, and mor

Unread post by J3rsdm5 »

amtrak1007 wrote:OK got a note here since i've now reread the whole thing EGZ/WGZ are the controls ASKING for the signal EGK/WGK's would be the indication back from the signal that these states actually have taken place. Same for NWK/RWK for switch positions, or the new fun one SMK for snow melter's on....

Other than that nice job!!!!
Aha thanks! I'll edit accordingly. I had wondered what the difference was. :)
"If it ain't all red, it ain't red at all"
Image JJRicks Studios

User avatar
J3rsdm5
Speak softly and carry a big tripod
Posts: 360
Joined: Sat Jul 30, 2016 5:29 pm
Location: Chandler, AZ
Contact:

Re: ATCS Notifications - Full Tutorial (text, email, and mor

Unread post by J3rsdm5 »

Important!
If you downloaded MonitoringScript.ahk before 12/10/2017 at 22:33, I have updated it and it is now working.
You can download here or at the link above, which I have fixed.
My apologies for that! :(
https://goo.gl/2tvviR


Last bumped by J3rsdm5 on Sat Dec 16, 2017 3:21 pm.
"If it ain't all red, it ain't red at all"
Image JJRicks Studios

Post Reply