Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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>();
 }
Exemplo n.º 4
0
 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));
     }
 }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
 public JT809Config(uint sessionId, JT809Version jt809Version, JT809EncryptConfig encryptConfig)
 {
     SessionId          = sessionId;
     JT809Version       = jt809Version;
     JT809EncryptConfig = encryptConfig;
 }
Exemplo n.º 7
0
 public JT809Config(uint sessionId, JT809Version jt809Version)
 {
     SessionId    = sessionId;
     JT809Version = jt809Version;
 }
Exemplo n.º 8
0
 /// <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);
 }