Exemplo n.º 1
0
        private void InitAll()
        {
            gb_Embedded.Visible  = EmbeddedMode;
            lbl_OrderNumber.Text = "";

            tb_ShowInformation.Clear();
            _setting              = new SettingHook();
            _plcIpAddress         = _setting.GetPlcIpAdress();
            _traceabilityEnabled  = _setting.GetEnableTraceability();
            _plcScanRate          = _setting.GetPlcScanRate();
            EnableVirtualIndexer  = _setting.GetVirtualIndexer();
            _uniqueIdentityLength = _setting.GetUniqueIdLength();
            _databaseConnection   = _setting.GetDatabaseConnectionString();

            _serverIp = TestConnection.ParseIpAddress(_databaseConnection);
            if (_serverIp != "")
            {
                tmrPingServer_Tick(tmrPingServer, null);
                tmrPingServer.Start();
            }
            SetLabelText(lblServerIp, _serverIp);

            ScanTimerInitialize();
            DaqReInitialize();
            MachineHookInitialize();

            SetMachineInformation();
            SetProductInformation();
            MachineDataReInitialize();
            VirtualIndexerToListBox(lb_Indexer);

            try
            {
                lbl_PlcConnection.Text = @"Connected";
                if (!EnableVirtualIndexer)
                {
                    lbl_VirtualIndexer.Text = @"Not Used";
                }
                _dataAcquisition.SetUniqueIdentityLength(_uniqueIdentityLength);
                _dataAcquisition.UpdateProductInUnloadingStatus(ProductStatus.TraceabilityStatusNotUpdated);
                _dataAcquisition.SetVirtualIndexer(
                    EnableVirtualIndexer ? VirtualIndexerStates.WaitingTraceabilityStatusCheck : VirtualIndexerStates.NotIndexed);

                SetTraceabilityStates(_traceabilityEnabled? TraceabilityStates.WaitingForReference: TraceabilityStates.ByPassed);
                btn_ByPass2.Text = _traceabilityEnabled ? "&By Pass" : "&Activate";
                if (!EnableVirtualIndexer)
                {
                    _machineData.ActiveReference = ReadActiveReference();
                }

                tmr_Scanner.Start();
            }
            catch (Exception exception)
            {
                ShowInformation("Initialize : " + exception.Message);
            }
        }