public IJT809BusinessTypeFactory SetMap <TJT809Bodies>() where TJT809Bodies : JT809Bodies { Type type = typeof(TJT809Bodies); var instance = Activator.CreateInstance(type); var msgId = (ushort)type.GetProperty(nameof(JT809Bodies.MsgId)).GetValue(instance); JT809Version version = (JT809Version)type.GetProperty(nameof(JT809Bodies.Version)).GetValue(instance); if (Map.ContainsKey(msgId)) { if (version != JT809Version.JTT2019) { throw new ArgumentException($"{type.FullName} {msgId} An element with the same key already exists."); } } else { Map.Add(msgId, instance); } if (Map_2019.ContainsKey(msgId)) { if (version == JT809Version.JTT2019) { Map_2019[msgId] = instance; } else { throw new ArgumentException($"{type.FullName} {msgId} An element with the same key already exists."); } } else { Map_2019.Add(msgId, instance); } return(this); }
protected JT809GlobalConfigBase(JT809Version version = JT809Version.JTT2011) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding = Encoding.GetEncoding("GBK"); BusinessTypeFactory = new JT809BusinessTypeFactory(); SubBusinessTypeFactory = new JT809SubBusinessTypeFactory(); FormatterFactory = new JT809FormatterFactory(); Version = version; }
protected JT809GlobalConfigBase(JT809Version version = JT809Version.JTT2011) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding = Encoding.GetEncoding("GBK"); BusinessTypeFactory = new JT809BusinessTypeFactory(); SubBusinessTypeFactory = new JT809SubBusinessTypeFactory(); FormatterFactory = new JT809FormatterFactory(); Version = version; AnalyzeCallbacks = new Dictionary <ushort, JT808AnalyzeCallback>(); }
public bool TryGetValue(ushort msgId, JT809Version version, out object instance) { if (version == JT809Version.JTT2019) { return(Map_2019.TryGetValue(msgId, out instance)); } else { return(Map.TryGetValue(msgId, out instance)); } }
public static IJT809Builder AddJT809Configure(this IServiceCollection services, JT809Version version = JT809Version.JTT2011) { DefaultGlobalConfig config = new DefaultGlobalConfig(); config.Version = version; services.AddSingleton <IJT809Config>(config); return(new DefaultBuilder(services, config)); }
public JT809Config(uint sessionId, JT809Version jt809Version, JT809EncryptConfig encryptConfig) { SessionId = sessionId; JT809Version = jt809Version; JT809EncryptConfig = encryptConfig; }
public JT809Config(uint sessionId, JT809Version jt809Version) { SessionId = sessionId; JT809Version = jt809Version; }
/// <summary> /// 目前只支持0x0200定位 /// 0704需要拆分出来 /// </summary> /// <param name="builder"></param> /// <param name="jt808MsgId">0x0200</param> /// <param name="jt808AnalyzeCallback"></param> /// <param name="version"></param> /// <returns></returns> public static IJT809Builder AddJT809_JT808AnalyzeCallback(this IJT809Builder builder, ushort jt808MsgId, JT808AnalyzeCallback jt808AnalyzeCallback, JT809Version version = JT809Version.JTT2011) { builder.Config.AnalyzeCallbacks.Add(jt808MsgId, jt808AnalyzeCallback); return(builder); }