private void Write_Port_Click(object sender, System.EventArgs e)
        {
            ushort PortAddr;
            uint   lVal;
            byte   bVal;
            ushort wVal;

            PortAddr    = ushort.Parse(PortW1.Text, NumberStyles.HexNumber);
            PortW1.Text = PortAddr.ToString("X4");
            switch (C_WriteSize.SelectedIndex)
            {
            case 0:
                bVal = byte.Parse(ValW1.Text, NumberStyles.HexNumber);
                TVicPort.WritePort(PortAddr, bVal);
                break;

            case 1:
                wVal = ushort.Parse(ValW1.Text, NumberStyles.HexNumber);
                TVicPort.WritePortW(PortAddr, wVal);
                break;

            case 2:
                lVal = uint.Parse(ValW1.Text, NumberStyles.HexNumber);
                TVicPort.WritePortL(PortAddr, lVal); break;
            }
        }
 private void Open_Driver_Click(object sender, System.EventArgs e)
 {
     TVicPort.OpenTVicPort();
     DriverOpened = TVicPort.IsDriverOpened() != 0;
     if (DriverOpened)
     {
         L_Days.Text = "Evaluation Days Left: " + TVicPort.EvaluationDaysLeft().ToString("d");
     }
     LockControls();
 }
        private void Read_Port_Click(object sender, System.EventArgs e)
        {
            ushort PortAddr;

            PortAddr    = ushort.Parse(PortR1.Text, NumberStyles.HexNumber);
            PortR1.Text = PortAddr.ToString("X4");
            switch (C_ReadSize.SelectedIndex)
            {
            case 0: ValR1.Text = (TVicPort.ReadPort(PortAddr)).ToString("X2"); break;

            case 1: ValR1.Text = (TVicPort.ReadPortW(PortAddr)).ToString("X4"); break;

            case 2: ValR1.Text = (TVicPort.ReadPortL(PortAddr)).ToString("X8"); break;
            }
        }
        private void B_Test_Click(object sender, System.EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            ushort Cycle, NumPortCycles;
            ushort PortAddr;

            byte   DataByte;
            double a, b, r;

            PortAddr      = ushort.Parse(EPortAddr.Text, NumberStyles.HexNumber);
            NumPortCycles = ushort.Parse(E_Cycles.Text, NumberStyles.Integer);
            byte[] buffer = new byte[NumPortCycles];

            // Separate I/O operations

            a = DateTime.Now.Ticks;
            for (Cycle = 1; Cycle <= NumPortCycles; Cycle++)
            {
                DataByte = TVicPort.ReadPort(PortAddr);
            }
            b = DateTime.Now.Ticks;

            r            = System.Math.Abs(b - a) / (10 * NumPortCycles);
            L_Test1.Text = String.Concat(r.ToString("F4"), " microsec");

            // with ReadPortBuffer()

            a = DateTime.Now.Ticks;

            // Declare an unsafe block
            unsafe
            {
                // Fix the byte array.
                fixed(byte *array = buffer)
                {
                    // Make the call here, passing in the array.
                    TVicPort.ReadPortFIFO(PortAddr, NumPortCycles, array);
                }
            }
            b            = DateTime.Now.Ticks;
            r            = System.Math.Abs(b - a) / (10 * NumPortCycles);
            L_Test4.Text = String.Concat(r.ToString("F4"), " microsec");

            Cursor = Cursors.Default;
        }
        unsafe private void B_ReadMemory_Click(object sender, System.EventArgs e)
        {
            String s;
            uint   i, j;
            UInt32 PhysAddr;
            byte * MappedAddr;

            byte[]        b     = new byte[16];
            ASCIIEncoding ascii = new ASCIIEncoding();

            // read the base physical address from Edit box
            PhysAddr = UInt32.Parse(E_Base.Text, System.Globalization.NumberStyles.HexNumber);

            // map this address to the linear address space
            MappedAddr = (byte *)TVicPort.MapPhysToLinear(PhysAddr, 256);

            // display memory dump

            ListAddr.Items.Clear();
            ListHex.Items.Clear();
            ListAscii.Items.Clear();

            for (i = 0; i < 16; i++)            // 16 lines in box
            {
                s = "";
                for (j = 0; j < 16; j++)                // 16 bytes in line
                {
                    b[j] = *(MappedAddr + 16 * i + j);
                    s    = s + b[j].ToString("X2");
                    if (b[j] < 32)
                    {
                        b[j] = 46;                                // replace all nonreadable symbols to "."
                    }
                }

                ListAddr.Items.Add((PhysAddr + 16 * i).ToString("X8"));         // address
                ListHex.Items.Add(s);                                           // hex
                ListAscii.Items.Add(ascii.GetString(b));                        // ascii
            }
        }
 private void PortForm_Closed(object sender, System.EventArgs e)
 {
     TVicPort.CloseTVicPort();
 }
 private void Close_Driver_Click(object sender, System.EventArgs e)
 {
     TVicPort.CloseTVicPort();
     DriverOpened = false;
     LockControls();
 }
 private void linkLabel2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
 {
     TVicPort.LaunchMail();
 }