public override async Task <MessageEntry> CallSetProperty(MessageEntry m) { string ename = m.MemberName; MessageElement me = m.FindElement("value"); MessageEntry mr = new MessageEntry(MessageEntryType.PropertySetRes, ename); switch (ename) { case "d1": { await obj.set_d1((MessageElementUtil.UnpackScalar <double>(me))); break; } case "d2": { await obj.set_d2(MessageElementUtil.UnpackArray <double>(me)); break; } default: throw new MemberNotFoundException("Member not found"); } return(mr); }
protected MessageElement PackPacket(T data, int index, uint packetnumber, bool requestack) { List <MessageElement> elems = new List <MessageElement>(); elems.Add(new MessageElement("packetnumber", packetnumber)); if (!rawelements) { object pdata = PackAnyType(ref data); elems.Add(new MessageElement("packet", pdata)); } else { MessageElement pme = ((MessageElement)(object)data); pme.ElementName = "packet"; elems.Add(pme); } if (requestack) { elems.Add(new MessageElement("requestack", new int[] { 1 })); } MessageElementMap <string> delems = new MessageElementMap <string>(elems); MessageElement me = new MessageElement(index.ToString(), delems); return(me); }
private static CQCode ParseMessageElement(MessageElement messageElement) { if (messageElement?.RawData == null || messageElement.RawData.Count == 0) { return(null); } try { return(messageElement.MsgType switch { CQFunction.Text => new CQCode(CQFunction.Text, messageElement.RawData.ToObject <Text>()), CQFunction.Face => new CQCode(CQFunction.Face, messageElement.RawData.ToObject <Face>()), CQFunction.Image => new CQCode(CQFunction.Image, messageElement.RawData.ToObject <Image>()), CQFunction.Record => new CQCode(CQFunction.Record, messageElement.RawData.ToObject <Record>()), CQFunction.At => new CQCode(CQFunction.At, messageElement.RawData.ToObject <At>()), CQFunction.Share => new CQCode(CQFunction.Share, messageElement.RawData.ToObject <Share>()), CQFunction.Reply => new CQCode(CQFunction.Reply, messageElement.RawData.ToObject <Reply>()), CQFunction.Forward => new CQCode(CQFunction.Forward, messageElement.RawData.ToObject <Forward>()), CQFunction.Xml => new CQCode(CQFunction.Xml, messageElement.RawData.ToObject <Code>()), CQFunction.Json => new CQCode(CQFunction.Json, messageElement.RawData.ToObject <Code>()), _ => new CQCode(CQFunction.Unknown, messageElement.RawData) }); }
public static MessageElement Field(this MessageElement me, string label, int length, string id = "*") { me?.Fields.Add(new FieldElement { Label = label, Length = length, Id = id }); return(me); }
public virtual void async_set_recording_data(byte value, Action <Exception> rr_handler, int rr_timeout = RobotRaconteurNode.RR_TIMEOUT_INFINITE) { using (MessageElement mm = MessageElementUtil.NewMessageElementDispose("value", new byte[] { value })) { rr_async_PropertySet("recording_data", mm, rrend_async_set_recording_data, rr_handler, rr_timeout); } }
public void deleteMessageElement(int id) { DBHelper._MessageElement dbhelp = new DBHelper._MessageElement(); MessageElement existingMessageElement = dbhelp.GetByid(id); dbhelp.Delete(existingMessageElement); }
public void MessageTest() { IppConfigurationSection target = new IppConfigurationSection(); // TODO: Initialize to an appropriate value MessageElement actual = target.Message; Assert.IsNotNull(actual); }
public virtual void async_set_wrench(double[] value, Action <Exception> rr_handler, int rr_timeout = RobotRaconteurNode.RR_TIMEOUT_INFINITE) { using (MessageElement mm = MessageElementUtil.NewMessageElementDispose("value", value)) { rr_async_PropertySet("wrench", mm, rrend_async_set_wrench, rr_handler, rr_timeout); } }
public MessageChain Parse(string text) { var builder = new MessageChainBuilder(); var array = JsonConvert.DeserializeObject <JArray>(text, Shared.SerializerSettings); foreach (var jToken in array) { var obj = (JObject)jToken; var data = (JObject)obj["data"]; MessageElement element = obj.Value <string>("type") switch { "text" => new Plain(data !.Value <string>("text")), "face" => new Face(data !.Value <int>("id")), "image" => data !.Value <string>("type") == "flash" ? new Flash(data !.Value <string>("file"), new UrlSource(new Uri(data.Value <string>("url") ?? $"http://gchat.qpic.cn/gchatpic_new/0/0-0-{data.Value<string>("file")!.Replace(".image", "").ToUpper()}/0?term=0", UriKind.Absolute))) : new Image(data !.Value <string>("file"), new UrlSource(new Uri(data.Value <string>("url") ?? $"http://gchat.qpic.cn/gchatpic_new/0/0-0-{data.Value<string>("file")!.Replace(".image", "").ToUpper()}/0?term=0", UriKind.Absolute))) , "at" => data !.Value <string>("qq") == "all" ? new AtAll() : new At(long.Parse(data !.Value <string>("qq") ?? string.Empty)), "reply" => new Quote(long.Parse(data !.Value <string>("id") ?? string.Empty)), "poke" => new Poke(GetPoke(data !.Value <string>("type"))), "xml" => new XmlContent(data !.Value <string>("data")), "json" => new JsonContent(data !.Value <string>("data")), "music" => new Music(data.Value <string>("type") switch { "qq" => Music.MusicSource.QqMusic, "163" => Music.MusicSource.Music163, "xm" => Music.MusicSource.XiaMi }, data.Value <string>("id")),
public virtual async Task async_set_d2(double[] value, int rr_timeout = RobotRaconteurNode.RR_TIMEOUT_INFINITE) { using (MessageElement mm = MessageElementUtil.PackArray <double>("value", value)) { await rr_async_PropertySet("d2", mm, rr_timeout); } }
public override void CallSetProperty(string membername, MessageElement m, WrappedServiceSkelAsyncAdapter async_adapter) { switch (membername) { case "d1": { if (async_obj != null) { async_adapter.MakeAsync(); async_obj.async_set_d1((MessageElementUtil.UnpackScalar <double>(m))).ContinueWith(t => async_adapter.EndTask(t)); return; } obj.d1 = (MessageElementUtil.UnpackScalar <double>(m)); return; } case "d2": { if (async_obj != null) { async_adapter.MakeAsync(); async_obj.async_set_d2(MessageElementUtil.UnpackArray <double>(m)).ContinueWith(t => async_adapter.EndTask(t)); return; } obj.d2 = MessageElementUtil.UnpackArray <double>(m); return; } default: break; } throw new MemberNotFoundException("Member not found"); }
protected List <MessageElement> PackPacket(T data, TimeSpec time) { List <MessageElement> timespec1 = new List <MessageElement>(); timespec1.Add(new MessageElement("seconds", time.seconds)); timespec1.Add(new MessageElement("nanoseconds", time.nanoseconds)); MessageElementStructure s = new MessageElementStructure("RobotRaconteur.TimeSpec", timespec1); List <MessageElement> elems = new List <MessageElement>(); elems.Add(new MessageElement("packettime", s)); if (!rawelements) { object pdata = PackAnyType(ref data); elems.Add(new MessageElement("packet", pdata)); } else { MessageElement pme = ((MessageElement)(object)data); pme.ElementName = "packet"; elems.Add(pme); } return(elems); }
protected override async Task SendPipePacket(T data, int index, uint packetnumber, bool requestack, Endpoint e = null, CancellationToken cancel = default(CancellationToken)) { MessageElement me = PackPacket(data, index, packetnumber, requestack); MessageEntry m = new MessageEntry(MessageEntryType.PipePacket, MemberName); m.AddElement(me); await stub.SendPipeMessage(m, cancel); }
public static MessageElement Constant(this MessageElement me, string label, int length, string value) { me?.Fields.Add(new ConstantElement { Label = label, Value = value }); return(me); }
/// <summary> /// Returns the critical error message text defined in the app.config file. /// </summary> /// <param name="msg">Message for session reference.</param> /// <returns>Critical error message text from app.config file.</returns> protected string GetCriticalErrorMessageText(MultiPartMessage msg) { VocollectSection configSection = ConfigurationManager.GetSection(VocollectSection.SectionKey) as VocollectSection; MessageElement message = configSection.MessageCollection["CriticalError"]; return(string.Format(message.Text, this.GetType().Name)); }
public override void CallSetProperty(string membername, MessageElement m, WrappedServiceSkelAsyncAdapter async_adapter) { switch (membername) { default: break; } throw new MemberNotFoundException("Member not found"); }
public async Task <double[]> get_d2(CancellationToken cancel = default(CancellationToken)) { MessageEntry m = new MessageEntry(MessageEntryType.PropertyGetReq, "d2"); MessageEntry mr = await ProcessRequest(m, cancel); MessageElement me = mr.FindElement("value"); return(MessageElementUtil.UnpackArray <double>(me)); }
public static SwitchElement Switch(this MessageElement me, string label, string on) { var sw = new SwitchElement { Label = label, On = on }; me?.Fields.Add(sw); return(sw); }
public void bias() { using (vectorptr_messageelement rr_param = new vectorptr_messageelement()) { using (MessageElement rr_me = rr_innerstub.FunctionCall("bias", rr_param)) { } } }
public void stopRecordingData() { using (vectorptr_messageelement rr_param = new vectorptr_messageelement()) { using (MessageElement rr_me = rr_innerstub.FunctionCall("stopRecordingData", rr_param)) { } } }
public static LoopElement Loop(this MessageElement me, string label, string from, string to, string step = "1") { var loop = new LoopElement { Label = label, From = from, To = to, Step = step }; me?.Fields.Add(loop); return(loop); }
public static GroupElement Group(this MessageElement me, string label) { var group = new GroupElement { Label = label }; me?.Fields.Add(group); return(group); }
public override void CallSetProperty(string membername, MessageElement m) { switch (membername) { default: break; } throw new MemberNotFoundException("Member not found"); }
public static PartRefElement PartRef(this MessageElement me, string label, string partId) { var pr = new PartRefElement { PartId = partId, Label = label }; me?.Fields.Add(pr); return(pr); }
public async Task <Dictionary <int, ServiceInfo> > GetLocalNodeServices(CancellationToken rr_cancel = default(CancellationToken)) { MessageEntry rr_mm = new MessageEntry(MessageEntryType.FunctionCallReq, "GetLocalNodeServices"); MessageEntry rr_mr = await ProcessRequest(rr_mm, rr_cancel); MessageElement rr_me = rr_mr.FindElement("return"); return((Dictionary <int, ServiceInfo>)RRContext.UnpackMapType <int, ServiceInfo>(rr_me.Data)); }
public void changeCalibration(byte config) { using (vectorptr_messageelement rr_param = new vectorptr_messageelement()) { MessageElementUtil.AddMessageElementDispose(rr_param, MessageElementUtil.NewMessageElementDispose("config", new byte[] { config })); using (MessageElement rr_me = rr_innerstub.FunctionCall("changeCalibration", rr_param)) { } } }
public void startRecordingData(string filename) { using (vectorptr_messageelement rr_param = new vectorptr_messageelement()) { MessageElementUtil.AddMessageElementDispose(rr_param, MessageElementUtil.NewMessageElementDispose("filename", filename)); using (MessageElement rr_me = rr_innerstub.FunctionCall("startRecordingData", rr_param)) { } } }
public double add_val(double v) { using (vectorptr_messageelement rr_param = new vectorptr_messageelement()) { MessageElementUtil.AddMessageElementDispose(rr_param, MessageElementUtil.PackScalar <double>("v", v)); using (MessageElement rr_me = rr_innerstub.FunctionCall("add_val", rr_param)) { return(MessageElementUtil.UnpackScalar <double>(rr_me)); } } }
protected virtual void rrend_async_changeCalibration(MessageElement ret, Exception err, object param) { Action <Exception> rr_handler = (Action <Exception>)param; if (err != null) { rr_handler(err); return; } rr_handler(null); }
protected virtual void rrend_async_stopRecordingData(MessageElement ret, Exception err, object param) { Action <Exception> rr_handler = (Action <Exception>)param; if (err != null) { rr_handler(err); return; } rr_handler(null); }