示例#1
0
        private int elaborateFDX()
        {
            // Turn on Antenna
            GIS_LF_API.TSLF_SetRF(PortHandle, 1);
            int factor = 100 / list.Count;

            while (flashed < list.Count)
            {
                m_oWorker.ReportProgress(flashed * factor);
                if (m_oWorker.CancellationPending)
                {
                    return(-1);
                }
                //CAMBIARE IN readFDX < 0 IN FASE DI PRODUZIONE!!!!!
                if (GIS_LF_API.TSLF_GetTagType(PortHandle, TTYP) > 0 && readFDX() < 0)
                {
                    writeFDX((String)list[flashed]);
                }
                System.Threading.Thread.Sleep(3000);
            }
            // Turn off Antenna
            GIS_LF_API.TSLF_SetRF(PortHandle, 0);
            //Report 100% completion on operation completed
            m_oWorker.ReportProgress(100);
            return(1);
        }
示例#2
0
        private void writeFDX(String str)
        {
            if (PortHandle > 0)
            {
                String identNr     = str.Substring(4, 12);
                String countryCode = str.Substring(0, 4);
                Byte[] FactoryID   = new Byte[8];
                if (IsNumber(identNr))
                {
                    Byte[] Buffer = Int64ToBuffer(Convert.ToInt64(identNr));

                    int Country = 0;
                    if (IsNumber(countryCode))
                    {
                        Country = Convert.ToInt32(countryCode);
                    }
                    else
                    {
                        MessageBox.Show("Enter corret CountryCode");
                    }

                    Console.WriteLine(Country);
                    Console.WriteLine(BufferToInt64(Buffer).ToString());

                    FactoryID[0] = 0;
                    FactoryID[1] = 0;
                    FactoryID[2] = 0;
                    FactoryID[3] = 0;
                    FactoryID[4] = 0;
                    FactoryID[5] = 0;
                    FactoryID[6] = 0;
                    FactoryID[7] = 0;

                    if (GIS_LF_API.TSLF_Write_FDXB(PortHandle, TTYP, FactoryID, Country, Buffer, 8, 1, 0, 0, 0, 0) < 0)
                    {
                        MessageBox.Show("Write Error - " + countryCode + "" + identNr);
                    }
                    else
                    {
                        flashed++;
                    }
                }
                else
                {
                    MessageBox.Show("Enter Ident Nr. (only Digits allowed)");
                }
            }
            else
            {
                MessageBox.Show("No Device attached");
            }
        }
示例#3
0
        private void Close_Click(object sender, EventArgs e)
        {
            if (PortHandle > 0)
            {
                GIS_LF_API.TSLF_Close(PortHandle);
            }

            if (m_oWorker.IsBusy)
            {
                // Notify the worker thread that a cancel has been requested.
                // The cancel will not actually happen until the thread in the
                // DoWork checks the m_oWorker.CancellationPending flag.
                m_oWorker.CancelAsync();
            }
            //Close();
        }
示例#4
0
 private int readFDX()
 {
     if (PortHandle > 0)
     {
         int    Country;
         Byte[] Buffer = new Byte[8];
         int    AnimalFlag;
         int    DatenblockFlag;
         int    Reserved;
         int    Extension;
         return(GIS_LF_API.TSLF_Read_FDXB(PortHandle, out Country, Buffer, 8, out AnimalFlag, out DatenblockFlag, out Reserved, out Extension));
     }
     else
     {
         MessageBox.Show("No Device attached");
         return(-1);
     }
 }
示例#5
0
        private void btn_read_lost_Click(object sender, EventArgs e)
        {
            if (PortHandle > 0)
            {
                Byte[] Buffer = new Byte[5];

                if (GIS_LF_API.TSLF_Read_Unique(PortHandle, Buffer, 5) == 5)
                {
                    tb_tag_id_lost.Text = MakeHexString(Buffer);
                }
                else
                {
                    MessageBox.Show("Read Error");
                }
            }
            else
            {
                MessageBox.Show("No Device attached");
            }
        }
示例#6
0
        public Happy_Hounds()
        {
            InitializeComponent();
            //Initialise Variables
            int MaxLength  = 255;
            int ListLength = 0;
            int DeviceListLength;

            SByte[] NameList   = new SByte[1000];
            SByte[] DeviceList = new SByte[MaxLength];
            //Grab USB Device Names
            DeviceListLength = GIS_LF_API.TSLF_GetUSBDeviceNames(DeviceList, MaxLength) - 1;
            CopyArrayTo(DeviceList, 0, NameList, ListLength, DeviceListLength);
            ListLength += DeviceListLength;
            ListLength++;

            if (ListLength > 1)
            {
                string DeviceName;
                // Use first Device in List
                DeviceName = MakeStringFromArray(NameList, 0);

                PortHandle = GIS_LF_API.TSLF_Open(MakeArrayFromString(DeviceName), 19200, 0, 500);
                if (GIS_LF_API.TSLF_IsProgrammer(PortHandle) != 1)
                {
                    MessageBox.Show("Device is not a Programmer");
                }
            }
            else
            {
                PortHandle = 0;
            }

            if (PortHandle <= 0)
            {
                MessageBox.Show("Device could not be opened");
            }
        }
示例#7
0
        public Form1()
        {
            InitializeComponent();

            btnStart.Enabled = false;
            btnStop.Enabled  = false;

            m_oWorker = new BackgroundWorker();

            // Create a background worker thread that ReportsProgress &
            // SupportsCancellation
            // Hook up the appropriate events.
            m_oWorker.DoWork          += new DoWorkEventHandler(m_oWorker_DoWork);
            m_oWorker.ProgressChanged += new ProgressChangedEventHandler
                                             (m_oWorker_ProgressChanged);
            m_oWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler
                                                (m_oWorker_RunWorkerCompleted);
            m_oWorker.WorkerReportsProgress      = true;
            m_oWorker.WorkerSupportsCancellation = true;

            int MaxLen  = 255;
            int ListLen = 0;
            int DevListLen;

            SByte[] NamenListe = new SByte[1000];
            SByte[] DevList    = new SByte[MaxLen];

            DevListLen = GIS_LF_API.TSLF_GetUSBDeviceNames(DevList, MaxLen) - 1;
            CopyArrayTo(DevList, 0, NamenListe, ListLen, DevListLen);
            ListLen   += DevListLen;
            DevListLen = GIS_LF_API.TSLF_GetLanDeviceNames(DevList, MaxLen) - 1;
            CopyArrayTo(DevList, 0, NamenListe, ListLen, DevListLen);
            ListLen   += DevListLen;
            DevListLen = GIS_LF_API.TSLF_GetCOMDeviceNames(DevList, MaxLen) - 1;
            CopyArrayTo(DevList, 0, NamenListe, ListLen, DevListLen);
            ListLen += DevListLen;
            ListLen++;

            if (ListLen > 1)
            {
                string DeviceName;
                // Use first Device in List
                DeviceName = MakeStringFromArray(NamenListe, 0);

                PortHandle = GIS_LF_API.TSLF_Open(MakeArrayFromString(DeviceName), 19200, 0, 500);
                if (GIS_LF_API.TSLF_IsProgrammer(PortHandle) != 1)
                {
                    MessageBox.Show("Device is no Programmer");
                    GIS_LF_API.TSLF_Close(PortHandle);
                    PortHandle = 0;
                }
                else
                {
                    // Get device version from device, to cehck if read device is connected.
                    // The first 3 digits of the string give the device number
                    // valid device number is 039 for TS-W34AC, 244 for TS-RW38AC
                    sbyte[] Version            = new sbyte[4];
                    sbyte[] InternalDeviceName = new sbyte[32];
                    int     nReturn            = GIS_LF_API.TSLF_GetDeviceVersion(PortHandle, Version, 4, InternalDeviceName, 32);
                    if (nReturn == -1)
                    {
                        int Error = GIS_LF_API.TSLF_GetLastError(PortHandle);
                        MessageBox.Show("DeviceVersion can not be read");
                        GIS_LF_API.TSLF_Close(PortHandle);
                        PortHandle = 0;
                    }
                    else
                    {
                        if (IsAnimalHDXProgrammer(Version))
                        {
                            // Device is valid
                        }
                        else
                        {
                            // Invalid device, will be closed
                            MessageBox.Show("Connected device is no Animal programmer!");
                            GIS_LF_API.TSLF_Close(PortHandle);
                            PortHandle = 0;
                        }
                    }
                }
            }
            else
            {
                PortHandle = 0;
            }

            if (PortHandle <= 0)
            {
                MessageBox.Show("Device could not be opened");
            }
            else
            {
                // Turn off Antenna
                GIS_LF_API.TSLF_SetRF(PortHandle, 0);
            }
        }