Storing IQ Data inside MinIO!
This commit is contained in:
parent
c618e87a4a
commit
ee13de9594
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.HighPerformance.Buffers;
|
||||
using Minio;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
@ -10,7 +6,16 @@ using Minio.Exceptions;
|
||||
using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
|
||||
using skyscraper8.DvbNip;
|
||||
using skyscraper8.Ietf.FLUTE;
|
||||
using skyscraper8.Skyscraper.Drawing;
|
||||
using skyscraper8.Skyscraper.Scraper.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Minio.DataModel.Response;
|
||||
|
||||
namespace skyscraper5.Data
|
||||
{
|
||||
@ -38,6 +43,10 @@ namespace skyscraper5.Data
|
||||
//putObjectArgs = putObjectArgs.WithObjectSize(buffer.Length);
|
||||
putObjectArgs = putObjectArgs.WithContentType(mime);
|
||||
putObjectArgs = putObjectArgs.WithHeaders(optionalData);
|
||||
if (buffer.CanSeek)
|
||||
{
|
||||
putObjectArgs = putObjectArgs.WithObjectSize(buffer.Length);
|
||||
}
|
||||
|
||||
lock (_tasks)
|
||||
{
|
||||
@ -250,6 +259,31 @@ namespace skyscraper5.Data
|
||||
{
|
||||
GetVersioningArgs args = new GetVersioningArgs().WithBucket(_minioBucket);
|
||||
VersioningConfiguration vc = _minioClient.GetVersioningAsync(args).Result;
|
||||
|
||||
byte[] buffer = new byte[2048];
|
||||
Random rng = new Random();
|
||||
rng.NextBytes(buffer);
|
||||
string fname = String.Format("/test_write_{0}.bin", rng.NextInt64());
|
||||
|
||||
PutObjectArgs putObjectArgs = new PutObjectArgs();
|
||||
putObjectArgs = putObjectArgs.WithBucket(_minioBucket);
|
||||
putObjectArgs = putObjectArgs.WithObject(fname);
|
||||
putObjectArgs = putObjectArgs.WithStreamData(new MemoryStream(buffer));
|
||||
putObjectArgs = putObjectArgs.WithContentType("application/octet-stream");
|
||||
putObjectArgs = putObjectArgs.WithObjectSize(2048);
|
||||
|
||||
PutObjectResponse objectResponse = _minioClient.PutObjectAsync(putObjectArgs).Result;
|
||||
if (objectResponse.ResponseStatusCode != HttpStatusCode.OK)
|
||||
throw new Exception(objectResponse.ResponseContent);
|
||||
|
||||
RemoveObjectArgs removeObjectArgs = new RemoveObjectArgs();
|
||||
removeObjectArgs = removeObjectArgs.WithBucket(_minioBucket);
|
||||
removeObjectArgs = removeObjectArgs.WithObject(fname);
|
||||
|
||||
Task removeObjectResponse = _minioClient.RemoveObjectAsync(removeObjectArgs);
|
||||
removeObjectResponse.Wait();
|
||||
if (removeObjectResponse.Exception != null)
|
||||
throw removeObjectResponse.Exception;
|
||||
}
|
||||
|
||||
public bool DvbNipTestForFile(string announcedFileContentLocation)
|
||||
@ -265,5 +299,20 @@ namespace skyscraper5.Data
|
||||
Stream stream = listener.ToStream();
|
||||
WriteObject(path, stream);
|
||||
}
|
||||
|
||||
public void StoreIqGraph(Guid jobGuid, long frequency, char polarity, IqChartData plot)
|
||||
{
|
||||
if (definetlyKnownFiles == null)
|
||||
definetlyKnownFiles = new HashSet<string>();
|
||||
if (definetlyMissingFiles == null)
|
||||
definetlyMissingFiles = new HashSet<string>();
|
||||
|
||||
string fullName = String.Format("/iq/{0}/{1}_{2}.iq", jobGuid.ToString("D"),frequency,polarity);
|
||||
MemoryStream ms = new MemoryStream();
|
||||
plot.SaveTo(ms);
|
||||
ms.Position = 0;
|
||||
|
||||
WriteObject(fullName, ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,27 +353,39 @@ namespace SDL2Demo.Jobs
|
||||
public SearchResult2 sr2;
|
||||
|
||||
public bool Satellite { get; private set; }
|
||||
|
||||
public string FrequencyAndPolarityToString()
|
||||
|
||||
public long GetFrequency()
|
||||
{
|
||||
if (Satellite)
|
||||
{
|
||||
char polarity;
|
||||
switch (sr1.Pol)
|
||||
{
|
||||
case 0: polarity = 'H'; break;
|
||||
case 1: polarity = 'V'; break;
|
||||
case 2: polarity = 'L'; break;
|
||||
case 3: polarity = 'R'; break;
|
||||
default: polarity = 'W'; break; //W for WTF?
|
||||
}
|
||||
return String.Format("{0}_{1}", sr1.Freq, polarity);
|
||||
return sr1.Freq;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format("{0}", sr2.Freq);
|
||||
return sr2.Freq;
|
||||
}
|
||||
}
|
||||
|
||||
public char GetPolarity()
|
||||
{
|
||||
if (Satellite)
|
||||
{
|
||||
char polarity;
|
||||
switch (sr1.Pol)
|
||||
{
|
||||
case 0: polarity = 'H'; break;
|
||||
case 1: polarity = 'V'; break;
|
||||
case 2: polarity = 'L'; break;
|
||||
case 3: polarity = 'R'; break;
|
||||
default: polarity = 'W'; break; //W for WTF?
|
||||
}
|
||||
return polarity;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'C';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool RunBlindscan()
|
||||
|
||||
@ -843,12 +843,11 @@ namespace SDL2Demo.Jobs
|
||||
{
|
||||
result.State = BlindscanResultState.IqCollecting;
|
||||
IqChartData plot = GatherIqGraph();
|
||||
result.State = BlindscanResultState.IqSaving;
|
||||
string fname = String.Format("{0}_{1}.bin", jobInDb.JobGuid.ToString("D"), result.FrequencyAndPolarityToString());
|
||||
FileStream fileStream = File.OpenWrite(fname);
|
||||
plot.SaveTo(fileStream);
|
||||
fileStream.Flush();
|
||||
fileStream.Close();
|
||||
if (plot != null)
|
||||
{
|
||||
result.State = BlindscanResultState.IqSaving;
|
||||
JobContext.ObjectStorage.StoreIqGraph(jobInDb.JobGuid, result.GetFrequency(), result.GetPolarity(), plot);
|
||||
}
|
||||
}
|
||||
|
||||
for (int mis = 0; mis < misCounter; mis++)
|
||||
|
||||
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using skyscraper5.src.Sophtainer;
|
||||
|
||||
namespace skyscraper8.Skyscraper.Drawing
|
||||
{
|
||||
@ -89,13 +90,14 @@ namespace skyscraper8.Skyscraper.Drawing
|
||||
totalSamples += (buffer.Length / 2);
|
||||
}
|
||||
|
||||
public void SaveTo(FileStream fs)
|
||||
public void SaveTo(Stream fs)
|
||||
{
|
||||
fs.WriteUInt8(0x41);
|
||||
Sophtainer sophtainer = Sophtainer.CreateSophtainer(fs, 538988873, new Version(1, 1, 0, 0));
|
||||
OffsetStream offsetStream = sophtainer.GetStream();
|
||||
foreach (byte[] packet in packets)
|
||||
{
|
||||
fs.WriteInt32LE(packet.Length);
|
||||
fs.Write(packet, 0, packet.Length);
|
||||
offsetStream.WriteInt32LE(packet.Length);
|
||||
offsetStream.Write(packet, 0, packet.Length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ using skyscraper8.DvbI;
|
||||
using skyscraper8.DvbNip;
|
||||
using skyscraper8.Ietf.FLUTE;
|
||||
using skyscraper8.Ses;
|
||||
using skyscraper8.Skyscraper.Drawing;
|
||||
using skyscraper8.Skyscraper.Scraper.Storage;
|
||||
using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform;
|
||||
|
||||
@ -1454,6 +1455,11 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem
|
||||
inStream.Dispose();
|
||||
}
|
||||
|
||||
public void StoreIqGraph(Guid jobGuid, long frequency, char polarity, IqChartData plot)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool DvbNipPrivateDataSpecifier(NipActualCarrierInformation currentCarrierInformation, DateTime versionUpdate,
|
||||
uint privateDataSpecifier, List<string> privateDataSessions)
|
||||
{
|
||||
|
||||
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
|
||||
using skyscraper8.DvbNip;
|
||||
using skyscraper8.Ietf.FLUTE;
|
||||
using skyscraper8.Skyscraper.Drawing;
|
||||
|
||||
namespace skyscraper8.Skyscraper.Scraper.Storage
|
||||
{
|
||||
@ -77,5 +78,10 @@ namespace skyscraper8.Skyscraper.Scraper.Storage
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void StoreIqGraph(Guid jobGuid, long frequency, char polarity, IqChartData plot)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
|
||||
using skyscraper5.Teletext;
|
||||
using skyscraper8.DvbNip;
|
||||
using skyscraper8.Ietf.FLUTE;
|
||||
using skyscraper8.Skyscraper.Drawing;
|
||||
|
||||
namespace skyscraper8.Skyscraper.Scraper.Storage
|
||||
{
|
||||
@ -25,5 +26,6 @@ namespace skyscraper8.Skyscraper.Scraper.Storage
|
||||
void Ping();
|
||||
bool DvbNipTestForFile(string announcedFileContentLocation);
|
||||
void DvbNipFileArrival(NipActualCarrierInformation carrier, FluteListener listener);
|
||||
void StoreIqGraph(Guid jobGuid, long frequency, char polarity, IqChartData plot);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user