forked from sictransit/wefax
-
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.
implemented command line args for source file + BCH
- Loading branch information
1 parent
584bb41
commit 644e7e9
Showing
6 changed files
with
90 additions
and
50 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace net.sictransit.wefax | ||
{ | ||
//1- Satellite name(8 characters) NOAA-11 | ||
//2- Spectral band(3 characters) DIR | ||
//3- Date(YYMMDD) (6 characters) 910125 | ||
//4- Time(HHMM) (4 characters) 1315 | ||
//5- Sector name(4 Characters) W020 | ||
//6- Open(25 characters) non-standard info | ||
|
||
class BinaryCodedHeader | ||
{ | ||
private readonly string satelliteName; | ||
private readonly string spectralBand; | ||
private readonly string sectorName; | ||
private readonly string open; | ||
private readonly string date; | ||
private readonly string time; | ||
|
||
public BinaryCodedHeader(string satelliteName, string spectralBand, string date, string time, string sectorName, string open) | ||
{ | ||
this.satelliteName = TrimClipAndPad(satelliteName ?? string.Empty, 8); | ||
this.spectralBand = TrimClipAndPad(spectralBand ?? string.Empty, 3); | ||
this.date = TrimClipAndPad(date ?? string.Empty, 6); | ||
this.time = TrimClipAndPad(time ?? string.Empty, 4); | ||
this.sectorName = TrimClipAndPad(sectorName ?? string.Empty, 4); | ||
this.open = TrimClipAndPad(open ?? string.Empty, 25); | ||
} | ||
|
||
public bool IsEmpty => string.IsNullOrWhiteSpace(Text); | ||
|
||
private string TrimClipAndPad(string s, int length) | ||
{ | ||
var trimmed = s.Trim(); | ||
|
||
return trimmed.Substring(0, Math.Min(trimmed.Length, length)).PadRight(length); | ||
} | ||
|
||
public string Text => string.Concat(satelliteName, spectralBand, date, time, sectorName, open); | ||
|
||
public IEnumerable<int> Binary => Text.Select(c => Convert.ToString(c, 2).PadLeft(8, '0')).SelectMany(x => x).Select(c => c == '1' ? 1 : 0); | ||
} | ||
} |
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
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,28 @@ | ||
using CommandLine; | ||
|
||
namespace net.sictransit.wefax | ||
{ | ||
public class Options | ||
{ | ||
[Option(Required = false, Default = "img/EIA_Resolution_Chart_1956.png", HelpText = "source image file to fax")] | ||
public string SourceImage { get; set; } | ||
|
||
[Option(Required = false, HelpText = "[BCH] satellite name (8 chars, e.g. \"NOAA-11\")")] | ||
public string SatelliteName { get; set; } | ||
|
||
[Option(Required = false, HelpText = "[BCH] spectral band (3 chars, e.g. \"DIR\")")] | ||
public string SpectralBane { get; set; } | ||
|
||
[Option(Required = false, HelpText = "[BCH] date (6 chars, \"yyMMdd\")")] | ||
public string Date { get; set; } | ||
|
||
[Option(Required = false, HelpText = "[BCH] time (4 chars, \"hhmm\")")] | ||
public string Time { get; set; } | ||
|
||
[Option(Required = false, HelpText = "[BCH] sector name (4 chars, e.g. \"W020\")")] | ||
public string SectorName { get; set; } | ||
|
||
[Option(Required = false, HelpText = "[BCH] non-standard info (25 chars)")] | ||
public string Open { get; set; } | ||
} | ||
} |
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
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