public void init(string service, ServiceFunction <MReq, MRes> callback) { this.service = service; srv_func = callback; helper = new ServiceCallbackHelper <MReq, MRes>(callback); req_datatype = new MReq().msgtype.ToString().Replace("__", "/").Replace("/Request", "__Request"); res_datatype = new MRes().msgtype.ToString().Replace("__", "/").Replace("/Response", "__Response"); srvtype = (SrvTypes)Enum.Parse(typeof(SrvTypes), req_datatype.Replace("__Request", "").Replace("/", "__")); datatype = srvtype.ToString().Replace("__", "/"); md5sum = IRosService.generate(srvtype).MD5Sum; }
public void TestMethod1() { //test all generated msg md5s vs. dump of known ones on kinetic List <MsgTypes> msg_failures = new List <MsgTypes>(); foreach (MsgTypes m in Enum.GetValues(typeof(MsgTypes))) { if (m == MsgTypes.Unknown) { continue; } IRosMessage msg = IRosMessage.generate(m); string type = msg.GetType().FullName.Replace("Messages.", "").Replace(".", "/"); if (!msgSums.ContainsKey(type)) { continue; } string desiredSum = msgSums[type]; string actualSum = msg.MD5Sum(); bool eq = String.Equals(desiredSum, actualSum); Debug.WriteLine("{0}\t{1}", type, eq?"OK":"FAIL"); if (!eq) { msg_failures.Add(m); } } Assert.IsFalse(msg_failures.Any()); //test all generated srv md5s vs. dump of known ones on kinetic List <SrvTypes> srv_failures = new List <SrvTypes>(); foreach (SrvTypes m in Enum.GetValues(typeof(SrvTypes))) { if (m == SrvTypes.Unknown) { continue; } IRosService srv = IRosService.generate(m); string type = srv.GetType().FullName.Replace("Messages.", "").Replace(".", "/"); if (!srvSums.ContainsKey(type)) { continue; } string desiredSum = srvSums[type]; string actualSum = srv.MD5Sum(); bool eq = String.Equals(desiredSum, actualSum); Debug.WriteLine("{0}\t{1}", type, eq ? "OK" : "FAIL"); if (!eq) { srv_failures.Add(m); } } Assert.IsFalse(srv_failures.Any()); }
internal void initialize(Connection connection) { this.connection = connection; connection.DroppedEvent += onConnectionDropped; connection.setHeaderReceivedCallback(onHeaderReceived); IDictionary dict = new Hashtable(); dict["service"] = name; dict["md5sum"] = IRosService.generate((SrvTypes)Enum.Parse(typeof(SrvTypes), RequestType.ToString().Replace("__Request", "").Replace("__Response", ""))).MD5Sum(); dict["callerid"] = this_node.Name; dict["persistent"] = persistent ? "1" : "0"; if (header_values != null) { foreach (object o in header_values.Keys) { dict[o] = header_values[o]; } } connection.writeHeader(dict, onHeaderWritten); }
public bool call(IRosService srv) { return(call(srv.RequestMessage, ref srv.ResponseMessage)); }