Exemple #1
0
        public int scanNetwork(deviceEntry[] deviceList, tcpNIpInfoStruct portInfo)
        {
            scanInfo sInfo = new scanInfo();

            int    retCode  = -1;
            string serverIP = portInfo.serverIP;

            sInfo.pvMax = portInfo.nDevice;
            sInfo.pvMin = 0;
            sInfo.pvVal = 0;
            sInfo.actOn = actionOnControl.PROGRESS_BAR;
            try
            {
                callBack(sInfo);
                for (int i = 0; i < portInfo.nDevice; i++)
                {
                    deviceEntry entry = new deviceEntry();
                    sInfo.IPAddress = serverIP;
                    sInfo.actOn     = actionOnControl.LEBEL;
                    callBack(sInfo);

                    if (devIdObj.getDeviceInformation(entry, serverIP) == 0)
                    {
                        // update data grid only if device available in the network else look for next device
                        entry.deviceIP   = serverIP;
                        deviceList[i]    = entry;
                        sInfo.deviceInfo = entry;
                        sInfo.actOn      = actionOnControl.DATA_GRID;
                        callBack(sInfo);
                    }
                    long IPLong = utility.IP2LongEndianLess(serverIP);
                    IPLong++; // go for next IP address
                    serverIP = utility.LongToIP(IPLong);

                    // update only progress bar
                    sInfo.pvVal++;
                    sInfo.actOn = actionOnControl.PROGRESS_BAR;
                    callBack(sInfo);
                }//For Loop
                sInfo.actOn = actionOnControl.PROCESS_COMPLETED;
                callBack(sInfo);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(retCode);
        }
Exemple #2
0
        /*********************************END******************************************************************************/

/*********************************END******************************************************************************/
        private void btScan_Click(object sender, RoutedEventArgs e)
        {
            if (txtIPRange.Text == " ")
            {
                MessageBox.Show(" Range value should be 0 to 255");
            }
            if (txtIPStart.Text == " ")
            {
                MessageBox.Show(" Start Address can't be empty  ");
            }

            try
            {
                UInt16 range = Convert.ToUInt16(txtIPRange.Text);
                if (utility.validateIPAddress(txtIPStart.Text) == false)
                {
                    MessageBox.Show(" No a valid IP address ");
                }
                else
                {
                    lbIConStatus.Content = "";
                    pbScanning.Value     = 0;
                    int lstCnt = grdDeviceList.Items.Count;
                    for (int i = 0; i < lstCnt; i++)
                    {
                        grdDeviceList.Items.RemoveAt(0);
                    }
                    btScan.IsEnabled = false;

                    //MessageBox.Show("start Scan");
                    tcpNIpInfoStruct portInfo = new tcpNIpInfoStruct();
                    portInfo.clientIP   = clientipStr;
                    portInfo.clientPort = 0;   // any available port
                    portInfo.serverIP   = txtIPStart.Text.ToString();
                    portInfo.serverPort = 502; // always modbus port
                    portInfo.nDevice    = range;
                    networkScan.startScanNetwork(portInfo);
                    lbIConStatus.Content = "Scanning ....";
                }
            }
            catch
            {
                MessageBox.Show(" Only interger allowed ");
            }
        }
Exemple #3
0
 public StateMachine(scanProgressBar_Callback cb, dgrUpdateListRead_CallBack ucb, callback_ProgressBar cpb)
 {
     updateThread       = new Thread(new ThreadStart(updateTask));
     t6tAccess          = new TeSysTMbAccess(cb);
     ftpupdgr           = new upgradeTask(cpb);
     toolState          = TOOLSTATE.UNINIT;
     upgrade_Callback   = ucb;
     utility            = new ftpMassUpgrade.toolUitility();
     clientPort         = 0;
     serverPort         = 0;
     noOfDevice         = 0;
     deviceList         = new deviceEntry[250];
     upgradedDeviceList = new deviceEntry[250];
     tmpEntry           = new deviceEntry();
     btScanDisabled     = false;
     portInfo           = new tcpNIpInfoStruct();
     fileInfo           = new upgradeFileInfo();
 }
Exemple #4
0
 public void setClientServerPortInfo(tcpNIpInfoStruct pInfo)
 {
     portInfo = pInfo;
 }
 public void startScanNetwork(tcpNIpInfoStruct pInfo)
 {
     portInfo   = pInfo;
     scanThread = new Thread(scanNetwork);
     scanThread.Start();
 }
 public NetworkScan(scanProgressBar_Callback cb)
 {
     t6tAccess  = new TeSysTMbAccess(cb);
     deviceList = new deviceEntry[MAX_DEVICE_SUPPORTED];
     portInfo   = new tcpNIpInfoStruct();
 }
        public int scanNetwork(deviceEntry[] deviceList, tcpNIpInfoStruct portInfo)
        {
            scanInfo sInfo = new scanInfo();

            int    retCode  = -1;
            string serverIP = portInfo.serverIP;

            sInfo.pvMax = portInfo.nDevice;
            sInfo.pvMin = 0;
            sInfo.pvVal = 0;
            sInfo.actOn = actionOnControl.PROGRESS_BAR;
            try
            {
                callBack(sInfo);
                for (int i = 0; i < portInfo.nDevice; i++)
                {
                    deviceEntry entry = new deviceEntry();
                    sInfo.IPAddress = serverIP;
                    sInfo.actOn     = actionOnControl.LEBEL;
                    callBack(sInfo);
                    if (mbClient.modbusInit(portInfo.clientIP, (ushort)portInfo.clientPort) == 0)
                    {
                        if (mbClient.mbOpen(serverIP, (ushort)portInfo.serverPort) == 0)
                        {
                            if (mbClient.mbRead(64, 5, mbReadBuf) == 0)
                            {
                                parseComRef(entry);
                                retCode = 0;
                            }
                            if (mbClient.mbRead(76, 1, mbReadBuf) == 0)
                            {
                                parsekuVer(entry);
                                retCode = 0;
                            }
                            if (mbClient.mbRead(62, 1, mbReadBuf) == 0)
                            {
                                parsekcVer(entry);
                                retCode = 0;
                            }
                            mbClient.mbClose();
                            entry.deviceIP = serverIP;
                        }
                    }
                    long IPLong = utility.IP2LongEndianLess(serverIP);
                    IPLong++; // go for next IP address
                    serverIP = utility.LongToIP(IPLong);

                    sInfo.pvVal++;
                    sInfo.actOn = actionOnControl.PROGRESS_BAR;
                    callBack(sInfo);
                    //update status only in device available
                    if (retCode == 0)
                    {
                        deviceList[i]    = entry;
                        sInfo.deviceInfo = entry;
                        sInfo.actOn      = actionOnControl.DATA_GRID;
                        callBack(sInfo);
                    }
                    retCode = -1;
                }//For Loop
                deviceEntry lastEntry = new deviceEntry();
                sInfo.deviceInfo = lastEntry;
                sInfo.actOn      = actionOnControl.PROCESS_COMPLETED;
                callBack(sInfo);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                mbClient.mbClose();
            }

            return(retCode);
        }