private void getTCPPort()
        {
            OptoMMP mmp     = new OptoMMP();
            int     success = mmp.Open(pac.IPAddress.ToString(), port, OptoMMP.Connection.UdpIp, timeout, true);

            int[] data = new int[1];
            success = mmp.ReadInts(Opto22Device.portMemoryAddress, 1, data, 0);
            if (success != 0)
            {
                MessageBox.Show("Problem reading TCP port!");
            }
            else
            {
                tbPort.Text = data[0].ToString();
            }
            mmp.Close();
        }
        private void SendChange()
        {
            OptoMMP mmp = new OptoMMP();

            var newIpBytes      = ipIPAddress.IPAddress.GetAddressBytes();
            var newSubnetBytes  = ipSubnetMask.IPAddress.GetAddressBytes();
            var newGatewayBytes = ipGateway.IPAddress.GetAddressBytes();
            var newDnsBytes     = ipDns.IPAddress.GetAddressBytes();

            uint newIp      = 0;
            uint newSubnet  = 0;
            uint newGateway = 0;
            uint newDns     = 0;

            for (int i = 0; i < 4; i++)
            {
                newIp      |= (uint)newIpBytes[i] << (24 - (i * 8));
                newSubnet  |= (uint)newSubnetBytes[i] << (24 - (i * 8));
                newGateway |= (uint)newGatewayBytes[i] << (24 - (i * 8));
                newDns     |= (uint)newDnsBytes[i] << (24 - (i * 8));
            }

            string pacIpAddr = pac.IPAddress.ToString();
            int    success   = mmp.Open(pacIpAddr, port, OptoMMP.Connection.UdpIp, timeout, true);

            if (success != 0)
            {
                MessageBox.Show("Error opening connection to PAC!");
                return;
            }

            ulong[] ipValue      = new ulong[1];
            ulong[] subnetValue  = new ulong[1];
            ulong[] gatewayValue = new ulong[1];
            ulong[] dnsValue     = new ulong[1];
            uint[]  portValue    = new uint[1];

            ipValue[0]      = ((ulong)newIp << 32) + ~newIp;
            subnetValue[0]  = ((ulong)newSubnet << 32) + ~newSubnet;
            gatewayValue[0] = ((ulong)newGateway << 32) + ~newGateway;
            dnsValue[0]     = ((ulong)newDns << 32) + ~newDns;
            portValue[0]    = Convert.ToUInt32(tbPort.Text);

            mmp.WriteULongs(Opto22Device.ipMemoryAddress, 1, ipValue, 0);
            //Thread.Sleep(100);
            mmp.WriteULongs(Opto22Device.subnetMemoryAddress, 1, subnetValue, 0);
            //Thread.Sleep(100);
            mmp.WriteULongs(Opto22Device.gatewayMemoryAddress, 1, gatewayValue, 0);
            //Thread.Sleep(100);
            mmp.WriteULongs(Opto22Device.dnsMemoryAddress, 1, dnsValue, 0);
            //Thread.Sleep(100);
            mmp.WriteUints(Opto22Device.portMemoryAddress, 1, portValue, 0);
            Console.WriteLine(portValue[0]);
            //Thread.Sleep(100);

            mmp.WriteStatusCommand(OptoMMP.StatusWriteCommand.ResetHardware);
            mmp.Close();
            callingForm.RemoveChangedPAC(pac);
            MessageBox.Show("Changes Written!");
            this.Close();
        }