From 282f7b5940870986266bc1761a9d481d080f9745 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 27 Oct 2015 16:34:34 +0100 Subject: Split files --- tda.erl | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'tda.erl') diff --git a/tda.erl b/tda.erl index 0f47516..b2e7042 100644 --- a/tda.erl +++ b/tda.erl @@ -1,9 +1,6 @@ -module(tda). -export([start/0, client/1, stop/0]). --export([rose/1]). - --include("Remote-Operations-Generic-ROS-PDUs.hrl"). -define(TIMEOUT, 300000). -define(CONNECT_TIMEOUT, 3000). @@ -57,12 +54,10 @@ loop(Sock) -> timeout end. -rose(Msg) -> 'Remote-Operations-Generic-ROS-PDUs':decode('ROS', Msg). - decode(Sock, Msg) -> case dispatch(Msg) of rose -> - {ok, Rose} = rose(Msg), + {ok, Rose} = rose:decode(Msg), io:format("ROSE> ~p~n", [Rose]), rose_handler(Sock, Rose); acse -> @@ -71,15 +66,10 @@ decode(Sock, Msg) -> acse:accepted(Acse) end. -rose_handler(Sock, {invoke, Rose}) -> - gen_tcp:send(Sock, invoke_handler(Rose)), +rose_handler(Sock, {invoke, Msg}) -> + gen_tcp:send(Sock, rose:dispatch(Msg)), ok. -invoke_handler(#'Invoke'{invokeId = Id, opcode = Op}) -> - case Op of - {_, 211} -> system_status(Id, Op) - end. - dispatch(<>) -> case Head of 96 -> acse; @@ -90,11 +80,3 @@ dispatch(<>) -> 161 -> rose; 162 -> rose end. - -system_status(Id, Op) -> - RR = #'ReturnResult_result'{opcode = Op, result = <<5,0>>}, - R = #'ReturnResult'{invokeId = Id, result = RR}, - case 'Remote-Operations-Generic-ROS-PDUs':encode('ROS', {returnResult, R}) of - {ok, Invoke} -> Invoke; - {error, Reason} -> Reason - end. -- cgit v1.2.3