Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mavlink Status Text. #119

Merged
merged 1 commit into from
May 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions Sources/Dronecode-SDK-Swift/Generated/Telemetry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,78 @@ public class Telemetry {
}
}

public struct StatusText: Equatable {
public let type: StatusType
public let text: String




public enum StatusType: Equatable {
case info
case warning
case critical
case UNRECOGNIZED(Int)

internal var rpcStatusType: DronecodeSdk_Rpc_Telemetry_StatusText.StatusType {
switch self {
case .info:
return .info
case .warning:
return .warning
case .critical:
return .critical
case .UNRECOGNIZED(let i):
return .UNRECOGNIZED(i)
}
}

internal static func translateFromRpc(_ rpcStatusType: DronecodeSdk_Rpc_Telemetry_StatusText.StatusType) -> StatusType {
switch rpcStatusType {
case .info:
return .info
case .warning:
return .warning
case .critical:
return .critical
case .UNRECOGNIZED(let i):
return .UNRECOGNIZED(i)
}
}
}


public init(type: StatusType, text: String) {
self.type = type
self.text = text
}

internal var rpcStatusText: DronecodeSdk_Rpc_Telemetry_StatusText {
var rpcStatusText = DronecodeSdk_Rpc_Telemetry_StatusText()


rpcStatusText.type = type.rpcStatusType




rpcStatusText.text = text



return rpcStatusText
}

internal static func translateFromRpc(_ rpcStatusText: DronecodeSdk_Rpc_Telemetry_StatusText) -> StatusText {
return StatusText(type: StatusType.translateFromRpc(rpcStatusText.type), text: rpcStatusText.text)
}

public static func == (lhs: StatusText, rhs: StatusText) -> Bool {
return lhs.type == rhs.type
&& lhs.text == rhs.text
}
}


public lazy var position: Observable<Position> = createPositionObservable()

Expand Down Expand Up @@ -1254,4 +1326,55 @@ public class Telemetry {
}
.share(replay: 1)
}

public lazy var statusText: Observable<StatusText> = createStatusTextObservable()

private func createStatusTextObservable() -> Observable<StatusText> {
return Observable.create { observer in
let request = DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest()



do {
let call = try self.service.subscribeStatusText(request, completion: { (callResult) in
if callResult.statusCode == .ok || callResult.statusCode == .cancelled {
observer.onCompleted()
} else {
observer.onError(RuntimeTelemetryError(callResult.statusMessage!))
}
})

let disposable = self.scheduler.schedule(0, action: { _ in

while let responseOptional = try? call.receive(), let response = responseOptional {


let statusText = StatusText.translateFromRpc(response.statusText)



observer.onNext(statusText)

}


return Disposables.create()
})

return Disposables.create {
call.cancel()
disposable.dispose()
}
} catch {
observer.onError(error)
return Disposables.create()
}
}
.retryWhen { error in
error.map {
guard $0 is RuntimeTelemetryError else { throw $0 }
}
}
.share(replay: 1)
}
}
68 changes: 68 additions & 0 deletions Sources/Dronecode-SDK-Swift/Generated/telemetry.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,26 @@ class DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeRcStatusCallTestStub:
override class var method: String { return "/dronecode_sdk.rpc.telemetry.TelemetryService/SubscribeRcStatus" }
}

internal protocol DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall: ClientCallServerStreaming {
/// Do not call this directly, call `receive()` in the protocol extension below instead.
func _receive(timeout: DispatchTime) throws -> DronecodeSdk_Rpc_Telemetry_StatusTextResponse?
/// Call this to wait for a result. Nonblocking.
func receive(completion: @escaping (ResultOrRPCError<DronecodeSdk_Rpc_Telemetry_StatusTextResponse?>) -> Void) throws
}

internal extension DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall {
/// Call this to wait for a result. Blocking.
func receive(timeout: DispatchTime = .distantFuture) throws -> DronecodeSdk_Rpc_Telemetry_StatusTextResponse? { return try self._receive(timeout: timeout) }
}

fileprivate final class DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCallBase: ClientCallServerStreamingBase<DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest, DronecodeSdk_Rpc_Telemetry_StatusTextResponse>, DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall {
override class var method: String { return "/dronecode_sdk.rpc.telemetry.TelemetryService/SubscribeStatusText" }
}

class DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCallTestStub: ClientCallServerStreamingTestStub<DronecodeSdk_Rpc_Telemetry_StatusTextResponse>, DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall {
override class var method: String { return "/dronecode_sdk.rpc.telemetry.TelemetryService/SubscribeStatusText" }
}


/// Instantiate DronecodeSdk_Rpc_Telemetry_TelemetryServiceServiceClient, then call methods of this protocol to make API calls.
internal protocol DronecodeSdk_Rpc_Telemetry_TelemetryServiceService: ServiceClient {
Expand Down Expand Up @@ -378,6 +398,11 @@ internal protocol DronecodeSdk_Rpc_Telemetry_TelemetryServiceService: ServiceCli
/// Use methods on the returned object to get streamed responses.
func subscribeRcStatus(_ request: DronecodeSdk_Rpc_Telemetry_SubscribeRcStatusRequest, completion: ((CallResult) -> Void)?) throws -> DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeRcStatusCall

/// Asynchronous. Server-streaming.
/// Send the initial message.
/// Use methods on the returned object to get streamed responses.
func subscribeStatusText(_ request: DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest, completion: ((CallResult) -> Void)?) throws -> DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall

}

internal final class DronecodeSdk_Rpc_Telemetry_TelemetryServiceServiceClient: ServiceClientBase, DronecodeSdk_Rpc_Telemetry_TelemetryServiceService {
Expand Down Expand Up @@ -493,6 +518,14 @@ internal final class DronecodeSdk_Rpc_Telemetry_TelemetryServiceServiceClient: S
.start(request: request, metadata: metadata, completion: completion)
}

/// Asynchronous. Server-streaming.
/// Send the initial message.
/// Use methods on the returned object to get streamed responses.
internal func subscribeStatusText(_ request: DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest, completion: ((CallResult) -> Void)?) throws -> DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall {
return try DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCallBase(channel)
.start(request: request, metadata: metadata, completion: completion)
}

}

class DronecodeSdk_Rpc_Telemetry_TelemetryServiceServiceTestStub: ServiceClientTestStubBase, DronecodeSdk_Rpc_Telemetry_TelemetryServiceService {
Expand Down Expand Up @@ -608,6 +641,14 @@ class DronecodeSdk_Rpc_Telemetry_TelemetryServiceServiceTestStub: ServiceClientT
return subscribeRcStatusCalls.first!
}

var subscribeStatusTextRequests: [DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest] = []
var subscribeStatusTextCalls: [DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall] = []
func subscribeStatusText(_ request: DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest, completion: ((CallResult) -> Void)?) throws -> DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextCall {
subscribeStatusTextRequests.append(request)
defer { subscribeStatusTextCalls.removeFirst() }
return subscribeStatusTextCalls.first!
}

}

/// To build a server, implement a class that conforms to this protocol.
Expand All @@ -628,6 +669,7 @@ internal protocol DronecodeSdk_Rpc_Telemetry_TelemetryServiceProvider: ServicePr
func subscribeFlightMode(request: DronecodeSdk_Rpc_Telemetry_SubscribeFlightModeRequest, session: DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeFlightModeSession) throws -> ServerStatus?
func subscribeHealth(request: DronecodeSdk_Rpc_Telemetry_SubscribeHealthRequest, session: DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeHealthSession) throws -> ServerStatus?
func subscribeRcStatus(request: DronecodeSdk_Rpc_Telemetry_SubscribeRcStatusRequest, session: DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeRcStatusSession) throws -> ServerStatus?
func subscribeStatusText(request: DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest, session: DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSession) throws -> ServerStatus?
}

extension DronecodeSdk_Rpc_Telemetry_TelemetryServiceProvider {
Expand Down Expand Up @@ -707,6 +749,11 @@ extension DronecodeSdk_Rpc_Telemetry_TelemetryServiceProvider {
handler: handler,
providerBlock: { try self.subscribeRcStatus(request: $0, session: $1 as! DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeRcStatusSessionBase) })
.run()
case "/dronecode_sdk.rpc.telemetry.TelemetryService/SubscribeStatusText":
return try DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSessionBase(
handler: handler,
providerBlock: { try self.subscribeStatusText(request: $0, session: $1 as! DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSessionBase) })
.run()
default:
throw HandleMethodError.unknownMethod
}
Expand Down Expand Up @@ -1007,3 +1054,24 @@ fileprivate final class DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeRcSt

class DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeRcStatusSessionTestStub: ServerSessionServerStreamingTestStub<DronecodeSdk_Rpc_Telemetry_RcStatusResponse>, DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeRcStatusSession {}

internal protocol DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSession: ServerSessionServerStreaming {
/// Send a message to the stream. Nonblocking.
func send(_ message: DronecodeSdk_Rpc_Telemetry_StatusTextResponse, completion: @escaping (Error?) -> Void) throws
/// Do not call this directly, call `send()` in the protocol extension below instead.
func _send(_ message: DronecodeSdk_Rpc_Telemetry_StatusTextResponse, timeout: DispatchTime) throws

/// Close the connection and send the status. Non-blocking.
/// This method should be called if and only if your request handler returns a nil value instead of a server status;
/// otherwise SwiftGRPC will take care of sending the status for you.
func close(withStatus status: ServerStatus, completion: (() -> Void)?) throws
}

internal extension DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSession {
/// Send a message to the stream and wait for the send operation to finish. Blocking.
func send(_ message: DronecodeSdk_Rpc_Telemetry_StatusTextResponse, timeout: DispatchTime = .distantFuture) throws { try self._send(message, timeout: timeout) }
}

fileprivate final class DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSessionBase: ServerSessionServerStreamingBase<DronecodeSdk_Rpc_Telemetry_SubscribeStatusTextRequest, DronecodeSdk_Rpc_Telemetry_StatusTextResponse>, DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSession {}

class DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSessionTestStub: ServerSessionServerStreamingTestStub<DronecodeSdk_Rpc_Telemetry_StatusTextResponse>, DronecodeSdk_Rpc_Telemetry_TelemetryServiceSubscribeStatusTextSession {}

Loading