public static ChannelTempInfo Clone(ChannelTempInfo cti)
        {
            MemoryStream    memoryStream = new MemoryStream();
            BinaryFormatter formatter    = new BinaryFormatter();

            formatter.Serialize(memoryStream, cti);
            memoryStream.Position = 0;
            return((ChannelTempInfo)formatter.Deserialize(memoryStream));
        }
 public static byte[] ProtocolConvert(ChannelTempInfo t)
 {
     try
     {
         ChannelTempInfo channeltempinfo = ChannelTempInfo.Clone(t);
         int             framecount      = channeltempinfo.ChannelTemps.Count / 256;
         if (channeltempinfo.ChannelTemps.Count % 256 != 0)
         {
             framecount += 1;
         }
         byte[] data = new byte[65536 * 2];    //数据
         for (int j = 0; j < data.Length; j++)
         {
             data[j] = 0xff;
         }
         byte[] temp = BitConverter.GetBytes(channeltempinfo.ChannelFiberLen);
         data[2] = temp[1];
         data[3] = temp[0];
         temp    = BitConverter.GetBytes(channeltempinfo.ChannelTempCount);
         data[4] = temp[1];
         data[5] = temp[0];
         temp    = BitConverter.GetBytes((ushort)(channeltempinfo.SampleInterval * ChannelInfos.SampleRate));
         data[6] = temp[1];
         data[7] = temp[0];
         temp    = BitConverter.GetBytes(channeltempinfo.FiberBreakStatus);
         data[8] = temp[1];
         data[9] = temp[0];
         for (int i = 0; i < channeltempinfo.ChannelTemps.Count; i++)
         {
             temp                 = BitConverter.GetBytes((ushort)(channeltempinfo.ChannelTemps[i] * 10));
             data[22 + i * 2]     = temp[1];
             data[22 + i * 2 + 1] = temp[0];
         }
         return(data);
     }catch (Exception ex)
     {
         throw;
     }
 }
        public EquipChannelTempInfo DataConvert(string equipnum, List <ChannelInfos> channelInfo, int channelcount, float SampleInterval)
        {
            this.DTSNum         = equipnum;
            this.SampleInterval = SampleInterval;
            for (int i = 0; i < channelcount; i++)
            {
                ChannelTempInfo equipchanneltempinfo = new ChannelTempInfo();
                equipchanneltempinfo.DTSNum           = equipnum;
                equipchanneltempinfo.ChannelNum       = channelInfo[i].ChannelNum;
                equipchanneltempinfo.SampleInterval   = SampleInterval;
                equipchanneltempinfo.ChannelFiberLen  = Convert.ToUInt16(channelInfo[i].FiberLen);
                equipchanneltempinfo.FiberBreakStatus = channelInfo[i].FiberBreakStatus;
                equipchanneltempinfo.ChannelTempCount = (ushort)(channelInfo[i].TempDatas.Count);
                equipchanneltempinfo.ChannelTemps     = new List <double>();
                for (int j = 0; j < channelInfo[i].TempDatas.Count; j++)
                {
                    equipchanneltempinfo.ChannelTemps.Add(channelInfo[i].TempDatas[j]);
                }

                EquipChannelTempInfos.Add(equipchanneltempinfo);
            }
            return(this);
        }
        public object PopData(string equipnum, ushort slavenum)
        {
            object data = null;

            if (EquipBaseInfos.Keys.Contains(equipnum))
            {
                int count = EquipBaseInfos[equipnum].Count;
                if (count > 0)
                {
                    int equipslavenum = EquipBaseInfos[equipnum][count - 1].SlaveNum;
                    int channelnum    = Math.Abs(slavenum - equipslavenum);
                    if (channelnum == 0)
                    {
                        //取基本信息
                    }
                    else
                    {
                        //取通道温度数据
                        if (EquipChannelTempInfos.Keys.Contains(equipnum))
                        {
                            try
                            {
                                List <EquipChannelTempInfo> listecti = EquipChannelTempInfos[equipnum].ToList();
                                int channelcount = listecti.Count;
                                if (channelcount > 0)
                                {
                                    int             index = listecti[channelcount - 1].EquipChannelTempInfos.FindIndex(item => item.ChannelNum == channelnum);
                                    ChannelTempInfo cti   = ChannelTempInfo.Clone(listecti[channelcount - 1].EquipChannelTempInfos.Find(delegate(ChannelTempInfo c) { return(c.ChannelNum == channelnum); }));
                                    if (index != -1)
                                    {
                                        channelTempInfo = ChannelTempInfo.Clone(cti);
                                    }
                                    else
                                    {
                                        if (channelTempInfo == null)
                                        {
                                            ChannelTempInfo cti1 = new ChannelTempInfo();
                                            cti1.DTSNum          = equipnum;
                                            cti1.ChannelNum      = (ushort)channelnum;
                                            cti1.SampleInterval  = listecti[count - 1].SampleInterval;
                                            cti1.ChannelFiberLen = 0;
                                            channelTempInfo      = cti1;
                                        }
                                    }
                                }
                                else
                                {
                                    if (channelTempInfo == null)
                                    {
                                        ChannelTempInfo cti1 = new ChannelTempInfo();
                                        cti1.DTSNum          = equipnum;
                                        cti1.ChannelNum      = (ushort)channelnum;
                                        cti1.SampleInterval  = listecti[count - 1].SampleInterval;
                                        cti1.ChannelFiberLen = 0;
                                        channelTempInfo      = cti1;
                                    }
                                }
                                data = channelTempInfo;
                            }
                            catch (Exception ex) { }
                        }
                    }
                }
            }
            return(data);
        }