-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from BunnyTub/cutting-edge
Merge 2.0-c into master as 2.0
- Loading branch information
Showing
24 changed files
with
2,721 additions
and
1,717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
# SharpENDEC | ||
# SharpENDEC | ||
|
||
### Credits | ||
``` | ||
BunnyTub - Main Developer | ||
ApatheticDELL - Logo Designer | ||
Google Translate / Microsoft Translator - Translations | ||
``` | ||
|
||
### Libraries | ||
``` | ||
Costura.Fody | ||
Fody | ||
NAudio | ||
Newtonsoft.Json | ||
``` | ||
|
||
> [!NOTE] | ||
> Although SharpENDEC is meant to replicate an ENDEC, it is **not** meant to be a complete ENDEC replacement. | ||
> Physical hardware is usually more stable, and more capable in terms of processing. | ||
## What is it anyway? | ||
SharpENDEC is a Canadian software CAP (Common Alerting Protocol) receiver for alerting. | ||
If you're a little confused, imagine something similar to a physical ENDEC, but based in software. | ||
|
||
## How do I install it? | ||
Well, it's simple! You don't need to. Simply put the executable into a directory of your choice, then run it. If you run into a problem, or you're on an older version of Windows, you'll most likely need to [install .NET Framework 4.8.1](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net481), or fully update Windows. Once you've done that, there isn't anything else that you will need to install or change. | ||
|
||
## How do I set it up? | ||
Well, you don't have to. But you should! There's a lot of stuff that could be of use. But... you should look over [this PDF document from Pelmorex (2021/06)](https://alerts.pelmorex.com/wp-content/uploads/2021/06/NAADS-LMD-User-Guide-R10.0.pdf) for some more knowledge on how Canada's public alerting system works, and its CAP-CP XML data. Once you have a little bit of a better understanding of the system, even just a little bit, come back here! | ||
|
||
Here's something, configurations! You might want to change some default settings, especially if they don't fit for your scenario. If you want to change your settings, press ```C``` during startup. To reset them to factory defaults, press ```R``` instead. I'll let you explore them for yourself! Although... if you can't find any CAP-GP geocodes for use in filtering, you can use [this Excel spreadsheet](https://www.publicsafety.gc.ca/cnt/rsrcs/pblctns/capcp-lctn-rfrncs/capcp-lctn-rfrncs-annex-a-201708.xlsx), which contains the most recent list of geocodes. | ||
|
||
One last thing. If you want to grab the text produced for use in automation, you can use ```static-text.txt``` if you need the newest text. If you want the file to be empty when it is inactive, use ```active-text.txt```. For the opposite, you can use ```inactive-text.txt``` instead. | ||
|
||
## How can I change the audio? | ||
Audio can be added and changed easily! Simply add in files and swap as you please. | ||
|
||
```in.wav``` This sound is used as the lead-in, and is played before all other sounds. It will simply be ignored if it does not exist. | ||
|
||
```attn.wav``` This sound is used as the attention tone for alerts marked as severe and above. The built-in copy will be extracted if it does not exist. | ||
|
||
```attn-minor.wav``` This sound is used as the attention tone for alerts marked as minor and below. It will fallback to **attn.wav** if it does not exist. | ||
|
||
```audio.wav``` This sound is reserved for the program's internal use. Modifying the file should not have any effect, and will be overwritten. | ||
|
||
```out.wav``` This sound is used as the lead-out, and is played after all other sounds. It will simply be ignored if it does not exist. | ||
|
||
## Is there anything else I need to know? | ||
Nope! That's about it. There's nothing else to know here. Thanks ApatheticDELL for this application idea, it worked out really well, and you were also awesome for helping me figure out these things. SharpENDEC (C#) was originally ported from QuantumENDEC (Python), and that was uh, really hard, and annoying to figure out. I did not like translating Python, but once it got going well, everything fit into place, and overall, felt good enough, then later on, I made it better. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace SharpENDEC | ||
{ | ||
public partial class ConsoleForm : Form | ||
{ | ||
public ConsoleForm() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void ConsoleForm_Load(object sender, EventArgs e) | ||
{ | ||
Console.SetOut(new TextBoxOutWriter(textBox1)); | ||
Console.SetError(new TextBoxErrorWriter(textBox1)); | ||
} | ||
|
||
public class TextBoxOutWriter : TextWriter | ||
{ | ||
private readonly TextBox _textBox; | ||
private readonly StringBuilder _buffer; | ||
|
||
public TextBoxOutWriter(TextBox textBox) | ||
{ | ||
_textBox = textBox; | ||
_buffer = new StringBuilder(); | ||
_textBox.Multiline = true; | ||
_textBox.ScrollBars = ScrollBars.Vertical; | ||
} | ||
|
||
public override void Write(char value) | ||
{ | ||
_buffer.Append(value); | ||
if (_buffer.Length >= 2) | ||
{ | ||
Flush(); | ||
} | ||
} | ||
|
||
public override void Write(string value) | ||
{ | ||
_buffer.Append(value); | ||
if (_buffer.Length >= 2) | ||
{ | ||
Flush(); | ||
} | ||
} | ||
|
||
public override Encoding Encoding => Encoding.UTF8; | ||
|
||
public override void Flush() | ||
{ | ||
if (_buffer.Length > 0) | ||
{ | ||
_textBox.Invoke((MethodInvoker)delegate { | ||
_textBox.AppendText(_buffer.ToString()); | ||
_textBox.ForeColor = Color.Lime; | ||
}); | ||
_buffer.Clear(); | ||
} | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (disposing) | ||
{ | ||
Flush(); | ||
} | ||
base.Dispose(disposing); | ||
} | ||
} | ||
|
||
public class TextBoxInReader : TextReader | ||
{ | ||
private TextBox _inputTextBox; | ||
private TextBox _outputTextBox; | ||
private string _inputBuffer; | ||
|
||
public TextBoxInReader(TextBox inputTextBox, TextBox outputTextBox) | ||
{ | ||
_inputTextBox = inputTextBox; | ||
_outputTextBox = outputTextBox; | ||
|
||
// Capture Enter key press in the input TextBox | ||
_inputTextBox.KeyPress += new KeyPressEventHandler(OnEnterKeyPress); | ||
} | ||
|
||
private void OnEnterKeyPress(object sender, KeyPressEventArgs e) | ||
{ | ||
if (e.KeyChar == (char)Keys.Enter) | ||
{ | ||
e.Handled = true; // Prevent the beep sound | ||
|
||
// Capture the input | ||
_inputBuffer = _inputTextBox.Text; | ||
|
||
// Clear input box and append to output box for feedback | ||
_inputTextBox.Clear(); | ||
_outputTextBox.AppendText(_inputBuffer + Environment.NewLine); | ||
} | ||
} | ||
|
||
public override string ReadLine() | ||
{ | ||
// Wait until the Enter key is pressed (simulate input waiting) | ||
while (string.IsNullOrEmpty(_inputBuffer)) | ||
{ | ||
Application.DoEvents(); // Allows processing of other UI events | ||
} | ||
|
||
string result = _inputBuffer; | ||
_inputBuffer = null; // Clear the buffer after use | ||
|
||
return result; | ||
} | ||
|
||
public Encoding Encoding => Encoding.UTF8; | ||
} | ||
|
||
public class TextBoxErrorWriter : TextWriter | ||
{ | ||
private readonly TextBox _textBox; | ||
private readonly StringBuilder _buffer; | ||
|
||
public TextBoxErrorWriter(TextBox textBox) | ||
{ | ||
_textBox = textBox; | ||
_buffer = new StringBuilder(); | ||
_textBox.Multiline = true; | ||
_textBox.ScrollBars = ScrollBars.Vertical; | ||
} | ||
|
||
public override void Write(char value) | ||
{ | ||
_buffer.Append(value); | ||
if (_buffer.Length >= 0) | ||
{ | ||
Flush(); | ||
} | ||
} | ||
|
||
public override void Write(string value) | ||
{ | ||
_buffer.Append(value); | ||
if (_buffer.Length >= 0) | ||
{ | ||
Flush(); | ||
} | ||
} | ||
|
||
public override Encoding Encoding => Encoding.UTF8; | ||
|
||
public override void Flush() | ||
{ | ||
if (_buffer.Length > 0) | ||
{ | ||
_textBox.Invoke((MethodInvoker)delegate { | ||
_textBox.AppendText(_buffer.ToString()); | ||
_textBox.ForeColor = Color.Red; | ||
}); | ||
_buffer.Clear(); | ||
} | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (disposing) | ||
{ | ||
Flush(); | ||
} | ||
base.Dispose(disposing); | ||
} | ||
} | ||
|
||
private void ConsoleForm_KeyDown(object sender, KeyEventArgs e) | ||
{ | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.