Skip to content
Snippets Groups Projects
Verified Commit 374936d8 authored by Bayu Samudra's avatar Bayu Samudra
Browse files

feat: adding receiver

parent dcf3695e
Branches
No related merge requests found
# Radar Viewer
This repository contains client of radar server and display it using OpenGL.
\ No newline at end of file
This repository contains repository of radar server and display it using OpenGL.
\ No newline at end of file
......@@ -68,6 +68,8 @@ repositories {
dependencies {
testImplementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0-RC")
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
implementation("org.lwjgl", "lwjgl")
......
import connection.Connection
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.runBlocking
import repository.ProcessedClient
import window.Window
fun main(args: Array<String>) {
println("Hello World!")
println("Radar Viewer")
val conn = Connection("localhost", 8080)
val processRepo = ProcessedClient(conn)
// Try adding program arguments via Run/Debug configuration.
// Learn more about running applications: https://www.jetbrains.com/help/idea/running-applications.html.
println("Program arguments: ${args.joinToString()}")
val h = Hello()
h.run()
// val h = Window()
// h.run()
println("Collecting")
runBlocking {
println("Meow")
val ref = processRepo.getReflectivity()
ref.collect {
println("Process time ${it.time}")
}
}
}
\ No newline at end of file
package connection
import io.grpc.ManagedChannel
import io.grpc.ManagedChannelBuilder
class Connection(host: String, port: Int) {
private val channelData: ManagedChannel
init {
this.channelData = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build()
}
val channel: ManagedChannel
get() = this.channelData
}
\ No newline at end of file
package repository
import com.radarsystem.producer.protos.ProcessedGrpcKt
import com.radarsystem.producer.protos.data.EmptyRequest
import com.radarsystem.producer.protos.data.ProcessedInfo
import com.radarsystem.producer.protos.data.Reflectivity
import connection.Connection
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.Flow
class ProcessedClient(connection: Connection) {
private val stub: ProcessedGrpcKt.ProcessedCoroutineStub
init {
this.stub = ProcessedGrpcKt.ProcessedCoroutineStub(connection.channel)
}
fun getReflectivity(): Flow<Reflectivity> {
return stub.getReflectivity(EmptyRequest.newBuilder().build())
}
suspend fun getInformation(): ProcessedInfo {
return stub.getRawInformation(EmptyRequest.newBuilder().build())
}
}
\ No newline at end of file
package window
import org.lwjgl.*
import org.lwjgl.glfw.*
......@@ -9,7 +11,7 @@ import org.lwjgl.system.MemoryStack.*
import org.lwjgl.system.MemoryUtil.*
class Hello {
class Window {
private var window: Long = NULL;
fun run() {
......@@ -33,7 +35,7 @@ class Hello {
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE)
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE)
window = glfwCreateWindow(300,300, "Hello, World!", NULL, NULL)
window = glfwCreateWindow(500,500, "Hello, World!", NULL, NULL)
if(window == NULL) {
throw Exception("Unable to create GLFW window")
}
......
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.radarsystem.producer.protos.data";
option java_outer_classname = "ProducerData";
message EmptyRequest {
}
message PingReply {
string status = 1;
}
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.radarsystem.producer.protos.data";
option java_outer_classname = "ReflectivityData";
message ProcessedInfo {
int64 range_resolution = 1;
repeated int64 range = 2;
}
message Reflectivity {
double time = 1;
repeated double diff_reflectivity = 2;
}
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.radarsystem.producer.protos";
option java_outer_classname = "ProcessedProto";
import "processed.proto";
import "data.proto";
package server;
service Processed {
/* Processed Producer */
rpc GetReflectivity(EmptyRequest) returns (stream Reflectivity) {}
rpc GetRawInformation(EmptyRequest) returns (ProcessedInfo) {}
}
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.radarsystem.producer.protos";
option java_outer_classname = "ProducerProto";
package server;
import "data.proto";
service Producer {
rpc Ping(EmptyRequest) returns (PingReply) {}
}
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.radarsystem.producer.protos.data";
option java_outer_classname = "RawData";
message BeatSignal {
double time = 1;
repeated int32 signal_i_hh = 2;
repeated int32 signal_i_vv = 3;
repeated int32 signal_i_vh = 4;
repeated int32 signal_q_hh = 5;
repeated int32 signal_q_vv = 6;
repeated int32 signal_q_vh = 7;
}
message RawInformation {
double radiation_wavelength = 2;
double sweep_time = 3;
int64 tx_power = 1;
double beam_width = 4;
double elevation = 5;
repeated int64 sample_beat = 6;
}
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.radarsystem.producer.protos";
option java_outer_classname = "RawProto";
import "raw.proto";
import "data.proto";
package raw;
service Raw {
/* Processed Producer */
rpc GetBeatSignal(EmptyRequest) returns (stream BeatSignal) {}
rpc GetRawInformation(EmptyRequest) returns (RawInformation) {}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment