Example #1
0
        private void ProUpload(string msg, int addr)
        {
            int            num  = 0;
            YJ_LmstMsg_sum _sum = new YJ_LmstMsg_sum();

            if ((this.state_pl != 0) && (this.addr_pl == addr))
            {
                try
                {
                    _sum = (YJ_LmstMsg_sum)JsonConvert.DeserializeObject(msg, typeof(YJ_LmstMsg_sum));
                }
                catch
                {
                    YJ_Log.DEBUG("ProUpload recv error", 0);
                }
                if (string.Compare(_sum.c, "DataReq") == 0)
                {
                    YJ_Log.DEBUG(msg, 0);
                    if (this.ses_pl == _sum.n)
                    {
                        this.SendUploadData(addr, this.ses_pl, this.Buff_pl, this.DataLen_pl);
                    }
                    else if ((this.ses_pl + 1) == _sum.n)
                    {
                        try
                        {
                            num = this.reader_pl.Read(this.Buff_pl, 0, 0x80);
                        }
                        catch
                        {
                            YJ_Log.DEBUG("reader_pl recv error", 0);
                        }
                        if (num > 0)
                        {
                            this.DataLen_pl     = num;
                            this.ReadOffset_pl += num;
                            this.ses_pl++;
                            this.flags_pl++;
                            this.UploadFirmwareSchedule = (this.ReadOffset_pl * 100) / this.FileLen_pl;
                            this.SendUploadData(addr, this.ses_pl, this.Buff_pl, this.DataLen_pl);
                        }
                    }
                    else
                    {
                        YJ_Log.DEBUG("(ses_pl + 1) != m.n", 0);
                    }
                }
                else if (string.Compare(_sum.c, "UpdateFinish") == 0)
                {
                    this.file_pl.Close();
                    this.reader_pl.Close();
                    this.state_pl            = 0;
                    this.UploadFirmwareState = 1;
                    YJ_Log.DEBUG("UpdateFinish", 0);
                }
            }
        }
Example #2
0
        private void ProNodeData(string msg, int addr)
        {
            this.refreshNode(addr);
            int num = addr;

            if (num <= 0x20)
            {
                switch (num)
                {
                case 0x10:
                    try
                    {
                        this.ServoMotorNodeParam = (YJ_LmstMsg_sum)JsonConvert.DeserializeObject(msg, typeof(YJ_LmstMsg_sum));
                    }
                    catch
                    {
                        YJ_Log.DEBUG("ServoMotorNodeParam recv error", 0);
                    }
                    break;

                case 0x20:
                    try
                    {
                        this.SensorNodeParam = (YJ_LmstMsg_sum)JsonConvert.DeserializeObject(msg, typeof(YJ_LmstMsg_sum));
                    }
                    catch
                    {
                        YJ_Log.DEBUG("SensorNodeParam recv error", 0);
                    }
                    break;
                }
            }
            else
            {
                switch (num)
                {
                case 0x30:
                    try
                    {
                        this.DivingNodeParam = (YJ_LmstMsg_sum)JsonConvert.DeserializeObject(msg, typeof(YJ_LmstMsg_sum));
                    }
                    catch
                    {
                        YJ_Log.DEBUG("DivingNodeParam recv error", 0);
                    }
                    return;

                case 0xe0:
                    try
                    {
                        this.HeadNodeParam = (YJ_LmstMsg_sum)JsonConvert.DeserializeObject(msg, typeof(YJ_LmstMsg_sum));
                    }
                    catch
                    {
                        YJ_Log.DEBUG("HeadNodeParam recv error", 0);
                    }
                    return;
                }
                if (num == 240)
                {
                    try
                    {
                        this.TailNodeParam = (YJ_LmstMsg_sum)JsonConvert.DeserializeObject(msg, typeof(YJ_LmstMsg_sum));
                    }
                    catch
                    {
                        YJ_Log.DEBUG("TailNodeParam recv error", 0);
                    }
                }
            }
        }