Пример #1
0
 private void ProcessRfidTag(ReadingHead readingHead, TagReadData[] tags)
 {
     string[] epcdata = new string[tags.Count()];
     for (int i = 0; i < tags.Count(); i++)
     {
         if (tags[i] != null)
         {
             epcdata[i] = tags[i].EPCString;
             AddLog("读到值:" + epcdata[i]);
             //ListViewItem item = new ListViewItem();
             //listView1.Items.Add(epcdata[i]);
             //MessageBox.Show(epcdata[i]);
         }
     }
 }
Пример #2
0
 public ReadingHeadThreadClass(CallBackDelegateWriteLog callBackDelegateWriteLog, ReadingHead readingHead)
 {
     //this.form = form;
     this.readingHead = readingHead;
     this.callBackDelegateWriteLog = callBackDelegateWriteLog;
 }
Пример #3
0
        private void LoadAscmReadingHead()
        {
            List <AscmReadingHead> listAscmReadingHead = null;

            m_readerWriterLock_readingHead.AcquireReaderLock(10000);
            try
            {
                //listAscmReadingHead = AscmWsInterface.GetInstance().GetAllAscmReadingHeadList();
                listAscmReadingHead = AscmReadingHeadService.GetInstance().GetList(null, null, null, "", "");
                if (listAscmReadingHead != null)
                {
                    listAscmReadingHead = listAscmReadingHead.Where(P => P.ip.Trim() != "0.0.0.0").ToList();
                }
                //
            }
            catch (Exception ex)
            {
                this.AddLog("加载读写器异常:" + ex.Message);
            }
            m_readerWriterLock_readingHead.ReleaseReaderLock();
            try
            {
                //增加
                foreach (AscmReadingHead ascmReadingHead in listAscmReadingHead)
                {
                    ReadingHead readingHead = listReadingHead.Find(e => e.ascmReadingHead.id == ascmReadingHead.id);
                    if (readingHead == null)
                    {
                        readingHead = new ReadingHead();
                        readingHead.ascmReadingHead = ascmReadingHead;
                        //readingHead.StartThread();
                        ReadingHeadThreadClass readingHeadThreadClass = new ReadingHeadThreadClass(WriteLogFile, readingHead);
                        //线程终止后不能重启
                        if (readingHead.thread != null)
                        {
                            readingHead.thread.Abort();
                        }


                        //this.AddLog("加载读写器:" + ascmReadingHead.ip);
                        try
                        {
                            //连接
                            //ascmReadingHead.ip = "192.168.1.100";
                            //readingHead.modulerReader = Reader.Create(ascmReadingHead.ip, ModuleTech.Region.NA, 16);
                            readingHead.modulerReader        = Reader.Create(ascmReadingHead.ip, ModuleTech.Region.NA, 4);
                            readingHead.moduleTech_isConnect = true;
                            //设置天线
                            int[]          ants = new int[] { 1, 2, 3, 4 };//天线全部是四天线;
                            SimpleReadPlan plan = new SimpleReadPlan(ants);
                            readingHead.modulerReader.ParamSet("ReadPlan", plan);
                            //设置功率
                            List <AntPower> antspwr = new List <AntPower>();
                            antspwr.Add(new AntPower((byte)1, 3000, 3000));
                            antspwr.Add(new AntPower((byte)2, 3000, 3000));
                            antspwr.Add(new AntPower((byte)3, 3000, 3000));
                            antspwr.Add(new AntPower((byte)4, 3000, 3000));
                            readingHead.modulerReader.ParamSet("AntPowerConf", antspwr.ToArray());
                            //设置格式
                            readingHead.modulerReader.ParamSet("Gen2Session", ModuleTech.Gen2.Session.Session1);
                            //设置读取位置
                            EmbededCmdData ecd = new EmbededCmdData(ModuleTech.Gen2.MemBank.EPC, 2, 4);
                            readingHead.modulerReader.ParamSet("EmbededCmdOfInventory", ecd);

                            //开启线程
                            readingHead.thread = new Thread(readingHeadThreadClass.Read);
                            readingHead.thread.IsBackground = true;

                            readingHead.bThread = true;
                            readingHead.thread.Start();

                            listReadingHead.Add(readingHead);
                        }
                        catch (Exception ex)
                        {
                            this.AddLog("加载读写器失败[" + ascmReadingHead.ip + "]:" + ex.Message);
                        }
                    }
                }
                //删除没有的设备或失败的线程
                for (int iReadingHead = listReadingHead.Count - 1; iReadingHead >= 0; iReadingHead--)
                {
                    ReadingHead     readingHead     = listReadingHead[iReadingHead];
                    AscmReadingHead ascmReadingHead = listAscmReadingHead.Find(e => readingHead.ascmReadingHead.id == e.id);
                    if (ascmReadingHead == null || readingHead.thread == null || !readingHead.bThread)
                    {
                        readingHead.StopThread();
                        listReadingHead.RemoveAt(iReadingHead);
                    }
                }
            }
            catch (Exception ex)
            {
                this.AddLog("加载读写器异常:" + ex.Message);
            }
        }
Пример #4
0
 public ReadingHeadThreadClass(CallBackDelegateWriteLog callBackDelegateWriteLog, ReadingHead readingHead)
 {
     //this.form = form;
     this.readingHead = readingHead;
     this.callBackDelegateWriteLog = callBackDelegateWriteLog;
 }
Пример #5
0
 private void ProcessRfidTag(ReadingHead readingHead, TagReadData[] tags)
 {
     string[] epcdata = new string[tags.Count()];
     for (int i = 0; i < tags.Count(); i++)
     {
         if (tags[i] != null)
         {
             epcdata[i] = tags[i].EPCString;
             AddLog("读到值:" + epcdata[i]);
             //ListViewItem item = new ListViewItem();
             //listView1.Items.Add(epcdata[i]);
             //MessageBox.Show(epcdata[i]);
         }
     }
 }
Пример #6
0
        private void LoadAscmReadingHead()
        {
            List<AscmReadingHead> listAscmReadingHead = null;
            m_readerWriterLock_readingHead.AcquireReaderLock(10000);
            try
            {
                //listAscmReadingHead = AscmWsInterface.GetInstance().GetAllAscmReadingHeadList();
                listAscmReadingHead = AscmReadingHeadService.GetInstance().GetList(null, null, null, "", "");
                if (listAscmReadingHead != null)
                {
                    listAscmReadingHead = listAscmReadingHead.Where(P => P.ip.Trim() != "0.0.0.0").ToList();
                }
                //
            }
            catch (Exception ex)
            {
                this.AddLog("加载读写器异常:" + ex.Message);
            }
            m_readerWriterLock_readingHead.ReleaseReaderLock();
            try
            {
                //增加
                foreach (AscmReadingHead ascmReadingHead in listAscmReadingHead)
                {
                    ReadingHead readingHead = listReadingHead.Find(e => e.ascmReadingHead.id == ascmReadingHead.id);
                    if (readingHead == null)
                    {
                        readingHead = new ReadingHead();
                        readingHead.ascmReadingHead = ascmReadingHead;
                        //readingHead.StartThread();
                        ReadingHeadThreadClass readingHeadThreadClass = new ReadingHeadThreadClass(WriteLogFile, readingHead);
                        //线程终止后不能重启
                        if (readingHead.thread != null)
                        {
                            readingHead.thread.Abort();
                        }

                        //this.AddLog("加载读写器:" + ascmReadingHead.ip);
                        try
                        {
                            //连接
                            //ascmReadingHead.ip = "192.168.1.100";
                            //readingHead.modulerReader = Reader.Create(ascmReadingHead.ip, ModuleTech.Region.NA, 16);
                            readingHead.modulerReader = Reader.Create(ascmReadingHead.ip, ModuleTech.Region.NA, 4);
                            readingHead.moduleTech_isConnect = true;
                            //设置天线
                            int[] ants = new int[] { 1,2,3,4};//天线全部是四天线;
                            SimpleReadPlan plan = new SimpleReadPlan(ants);
                            readingHead.modulerReader.ParamSet("ReadPlan", plan);
                            //设置功率
                            List<AntPower> antspwr = new List<AntPower>();
                            antspwr.Add(new AntPower((byte)1, 3000, 3000));
                            antspwr.Add(new AntPower((byte)2, 3000, 3000));
                            antspwr.Add(new AntPower((byte)3, 3000, 3000));
                            antspwr.Add(new AntPower((byte)4, 3000, 3000));
                            readingHead.modulerReader.ParamSet("AntPowerConf", antspwr.ToArray());
                            //设置格式
                            readingHead.modulerReader.ParamSet("Gen2Session", ModuleTech.Gen2.Session.Session1);
                            //设置读取位置
                            EmbededCmdData ecd = new EmbededCmdData(ModuleTech.Gen2.MemBank.EPC, 2, 4);
                            readingHead.modulerReader.ParamSet("EmbededCmdOfInventory", ecd);

                            //开启线程
                            readingHead.thread = new Thread(readingHeadThreadClass.Read);
                            readingHead.thread.IsBackground = true;

                            readingHead.bThread = true;
                            readingHead.thread.Start();

                            listReadingHead.Add(readingHead);
                        }
                        catch (Exception ex)
                        {
                            this.AddLog("加载读写器失败[" + ascmReadingHead.ip + "]:" + ex.Message);
                        }
                    }
                }
                //删除没有的设备或失败的线程
                for (int iReadingHead = listReadingHead.Count - 1; iReadingHead >= 0; iReadingHead--)
                {
                    ReadingHead readingHead = listReadingHead[iReadingHead];
                    AscmReadingHead ascmReadingHead = listAscmReadingHead.Find(e => readingHead.ascmReadingHead.id == e.id);
                    if (ascmReadingHead == null || readingHead.thread == null || !readingHead.bThread)
                    {
                        readingHead.StopThread();
                        listReadingHead.RemoveAt(iReadingHead);
                    }
                }
            }
            catch (Exception ex)
            {
                this.AddLog("加载读写器异常:" + ex.Message);
            }
        }