Skip to content

Commit

Permalink
Merge pull request #3 from ut-issl/develop
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
meltingrabbit authored Jul 5, 2022
2 parents eb17467 + d8b1116 commit 6d8aad8
Show file tree
Hide file tree
Showing 28 changed files with 2,206 additions and 0 deletions.
241 changes: 241 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
bin/
Bin/
obj/
Obj/

# Visual Studio 2015 cache/options directory
.vs/
/wwwroot/dist/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config

# Windows Store app package directory
AppPackages/
BundleArtifacts/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
orleans.codegen.cs

# Ceriticate of identity server for production build
!certificate.pfx

/node_modules

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# SQLite files
*.db

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe

# FAKE - F# Make
.fake/

# macOS
*.DS_Store
126 changes: 126 additions & 0 deletions App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using Grpc.Net.Client;
using WINGS.GrpcService;
using WINGS_TMTC_IF.Services;
using WINGS_TMTC_IF.Models;

namespace WINGS_TMTC_IF
{
public class App
{
private readonly IConfiguration _configuration;
private readonly IOperationService _operationService;
private readonly IPortManager _portManager;
private readonly ITmPacketExtractor _tmPacketExtractor;
private readonly ITcPacketHandler _tcPacketHandler;
private readonly TmtcPacketService _tmtcPacketService;

public App(IConfiguration configuration,
IOperationService operationService,
IPortManager portManager,
ITmPacketExtractor tmPacketExtractor,
ITcPacketHandler tcPacketHandler,
TmtcPacketService tmtcPacketService)
{
_configuration = configuration;
_operationService = operationService;
_portManager = portManager;
_tmPacketExtractor = tmPacketExtractor;
_tcPacketHandler = tcPacketHandler;
_tmtcPacketService = tmtcPacketService;
}

public void Run()
{
// Select Opid
Task<List<Operation>> opTask= Task.Run(() => _operationService.FetchOperationAsync());
var opid = ConsoleSelectOperation(opTask.Result);
Console.WriteLine("Operation ID: {0}\n", opid);

// Initialize Port (Automatically open Serial or LAN port correspond to the selected component)
_portManager.Initialize();

// Initialize Packet Handler
_tmPacketExtractor.Initialize(opid);
_tcPacketHandler.Initialize(opid);

// Start gRPC Service
var client = ConfigureGrpcClient();
var tmTask = _tmtcPacketService.TmPacketSendLoop(client);
var tcTask = _tmtcPacketService.TcPacketReceiveLoop(client);
Task.WaitAll(tmTask, tcTask);
Console.ReadKey();
}

private string ConsoleSelectOperation(List<Operation> operations)
{
int num;
Console.WriteLine("Select operation and press enter");
for (int i = 0; i < operations.Count; i++)
{
var operation = operations[i];
Console.WriteLine("[ {0} ] : {1}", i, operation.PathNumber + " " + operation.Comment);
}
while (true)
{
try
{
num = int.Parse(Console.ReadLine());
var operation = operations[num];
if (num < operations.Count)
{
if (!operation.IsTmtcConnected)
{
return operation.Id;
}
else
{
Console.WriteLine("This operation is already connected by another client");
}
}
else
{
Console.WriteLine("Error unexpeced input");
}
}
catch
{
Console.WriteLine("Error unexpeced input");
}
}
}

private TmtcPacket.TmtcPacketClient ConfigureGrpcClient()
{
var env = _configuration["WINGS:Environment"];
var grpcConnectionString = _configuration["WINGS:GrpcConnectionString"];
GrpcChannel channel;

switch (env)
{
case "Windows": // Windows Development Build
case "Docker": // Linux on Docker Production Build
var httpHandler = new HttpClientHandler();
httpHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
channel = GrpcChannel.ForAddress(grpcConnectionString,
new GrpcChannelOptions { HttpHandler = httpHandler });
break;

case "Mac": // Mac Development Build
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
channel = GrpcChannel.ForAddress(grpcConnectionString);
break;

default:
throw new Exception("unsupported environment");
}

return new TmtcPacket.TmtcPacketClient(channel);
}
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Intelligent Space Systems Laboratory, The University of Tokyo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 6d8aad8

Please sign in to comment.