Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
ScanOrganic events added to IGAU submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Xjph committed May 25, 2021
1 parent cd0be7e commit 8b3c52e
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 4 deletions.
36 changes: 34 additions & 2 deletions Observatory/CodexReader.cs → Observatory/IGAUReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

namespace Observatory
{
static class CodexReader

static class IGAUReader
{
public static void ProcessCodex(CodexEntry codexEntry)
{
Expand Down Expand Up @@ -45,6 +44,39 @@ public static void ProcessCodex(CodexEntry codexEntry)
}
}

public static void ProcessOrganic(ScanOrganicEvent scanOrganicEvent)
{
if (Properties.Observatory.Default.SendToIGAU)
{
JObject POST_content = JObject.FromObject(
new
{
timestamp = scanOrganicEvent.Timestamp.ToString("yyyy-MM-ddTHH:mm:ssZ"),
EntryID = "-",
Name = scanOrganicEvent.Species
.Replace("$", string.Empty)
.Replace(";", string.Empty)
.Replace("_Name", string.Empty)
.ToLower(),
Name_Localised = scanOrganicEvent.Species_Localised,
System = scanOrganicEvent.CurrentSystem,
SystemAddress = scanOrganicEvent.SystemAddress.ToString(),
App_Name = "Elite_Observatory",
App_Version = Application.ProductVersion
});

var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri($"https://ddss70885k.execute-api.us-west-1.amazonaws.com/Prod"),
Content = new StringContent(POST_content.ToString(Formatting.None))
};

QueueRequest(request);

}
}

private static List<HttpRequestMessage> RequestQueue;

private static bool RequestsSending;
Expand Down
13 changes: 13 additions & 0 deletions Observatory/LogMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ class LogMonitor
private string LogDirectory;
public bool LastScanValid { get; private set; }
public bool LastCodexValid { get; private set; }
public bool LastOrganicValid { get; private set; }
public bool ReadAllInProgress { get; private set; }
public bool ReadAllComplete { get; private set; }
public ScanEvent LastScan { get; private set; }
public CodexEntry LastCodex { get; private set; }
public ScanOrganicEvent LastOrganic { get; private set; }
public Dictionary<(string System, long Body), ScanEvent> SystemBody { get; private set; }
public UserInterest UserInterest { get; private set; }
private JournalPoker Poker;
Expand Down Expand Up @@ -115,6 +117,7 @@ public void ReadAll(ProgressBar progressBar)
CurrentLogLine.Contains("\"event\":\"Location\"") ||
CurrentLogLine.Contains("\"event\":\"FSDJump\"") ||
CurrentLogLine.Contains("\"event\":\"CodexEntry\"") ||
CurrentLogLine.Contains("\"event\":\"ScanOrganic\"") ||
CurrentLogLine.Contains("\"event\":\"SupercruiseExit\""))
{
ProcessLine(CurrentLogLine);
Expand Down Expand Up @@ -212,6 +215,7 @@ private void LogChanged(object source, FileSystemEventArgs e)
checkLine.Contains("\"event\":\"Location\"") ||
checkLine.Contains("\"event\":\"FSDJump\"") ||
checkLine.Contains("\"event\":\"CodexEntry\"") ||
checkLine.Contains("\"evnet\":\"ScanOrganic\"") ||
checkLine.Contains("\"event\":\"SupercruiseExit\""))
{
CurrentLogLine = checkLine;
Expand Down Expand Up @@ -250,6 +254,7 @@ private void ProcessLine(string logLine)
}
LastScanValid = false;
LastCodexValid = false;
LastOrganicValid = false;
//Journals prior to Elite Dangerous 2.3 "The Commanders" had differently formatted scan events which I can't be bothered to support.
if (DateTime.TryParseExact(lastEvent["timestamp"].ToString(), "yyyy-MM-ddTHH:mm:ssZ", null, System.Globalization.DateTimeStyles.RoundtripKind, out DateTime eventTime))
{
Expand Down Expand Up @@ -289,6 +294,14 @@ private void ProcessLine(string logLine)
LastCodexValid = true;
}
break;
case "ScanOrganic":
if (LastOrganic?.Timestamp != lastEvent.ToObject<ScanOrganicEvent>().Timestamp)
{
LastOrganic = lastEvent.ToObject<ScanOrganicEvent>();
LastOrganic.CurrentSystem = currentSystem;
LastOrganicValid = true;
}
break;
case "SupercruiseExit":
if (lastEvent["Body"]?.ToString().Length > 0)
currentBody = lastEvent["Body"].ToString();
Expand Down
3 changes: 2 additions & 1 deletion Observatory/Observatory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CodexEntry.cs" />
<Compile Include="CodexReader.cs" />
<Compile Include="IGAUReader.cs" />
<Compile Include="ColumnSorter.cs" />
<Compile Include="CompanionAPI.cs" />
<Compile Include="CriteriaEdit.cs">
Expand Down Expand Up @@ -122,6 +122,7 @@
<Compile Include="Observatory.cs" />
<Compile Include="LogMonitor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScanOrganicEvent.cs" />
<Compile Include="ScanReader.cs" />
<Compile Include="SettingsFrm.cs">
<SubType>Form</SubType>
Expand Down
6 changes: 5 additions & 1 deletion Observatory/ObservatoryFrm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void LogEvent(object source, EventArgs e)
}
else if (logMonitor.LastCodexValid)
{
CodexReader.ProcessCodex(logMonitor.LastCodex);
IGAUReader.ProcessCodex(logMonitor.LastCodex);

if (Properties.Observatory.Default.IncludeCodex)
{
Expand All @@ -180,6 +180,10 @@ private void LogEvent(object source, EventArgs e)
});
}
}
else if (logMonitor.LastOrganicValid)
{
IGAUReader.ProcessOrganic(logMonitor.LastOrganic);
}
}

private void RemoveUninteresting()
Expand Down
37 changes: 37 additions & 0 deletions Observatory/ScanOrganicEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using Newtonsoft.Json;

namespace Observatory
{
public class ScanOrganicEvent
{
[JsonProperty("timestamp")]
public DateTime Timestamp { get; set; }

[JsonProperty("event")]
public string Event { get; set; }

[JsonProperty("ScanType")]
public string ScanType { get; set; }

[JsonProperty("Genus")]
public string Genus { get; set; }

[JsonProperty("Genus_Localised")]
public string Genus_Localised { get; set; }

[JsonProperty("Species")]
public string Species { get; set; }

[JsonProperty("Species_Localised")]
public string Species_Localised { get; set; }

[JsonProperty("SystemAddress")]
public ulong SystemAddress { get; set; }

[JsonProperty("Body")]
public int Body { get; set; }

public string CurrentSystem;
}
}

0 comments on commit 8b3c52e

Please sign in to comment.