public static EtherCATInitializationForm GetInstance()
 {
     if (_splashScreenForm.IsDisposed)
     {
         _splashScreenForm = new EtherCATInitializationForm();
     }
     return(_splashScreenForm);
 }
Esempio n. 2
0
        private void InitialCard()
        {
            try
            {
                g_uRet = CEtherCAT_DLL.CS_ECAT_Master_Open(ref g_nESCExistCards);
            }
            catch (Exception ex)
            {
                throw new Exception("No EtherCat dll can be found!");
            }
            g_bInitialFlag = false;
            if (g_nESCExistCards == 0)
            {
                throw new Exception("No EtherCat can be found!");
            }
            else
            {
                for (ushort uCount = 0; uCount < g_nESCExistCards; uCount++)
                {
                    ushort uCardNo = 0;
                    g_uRet = CEtherCAT_DLL.CS_ECAT_Master_Get_CardSeq(uCount, ref uCardNo);
                    if (g_uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
                    {
                        throw new Exception("CS_ECAT_Master_Get_CardSeq, " + GetEtherCATErrorCode(g_uRet));
                    }
                    else
                    {
                        g_uESCCardNoList.Add(uCount, new CardInfo()
                        {
                            CardNo = uCardNo
                        });
                    }
                }

                EtherCATInitializationForm.GetInstance().SetCardList(g_uESCCardNoList);

                foreach (var item in g_uESCCardNoList)
                {
                    g_uRet = CEtherCAT_DLL.CS_ECAT_Master_Initial(item.Value.CardNo);
                    if (g_uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
                    {
                        throw new Exception("CS_ECAT_Master_Initial, " + GetEtherCATErrorCode(g_uRet));
                    }
                }
                g_bInitialFlag = true;
            }
        }
Esempio n. 3
0
        protected CEtherCAT(ModulesType modulesType, string parameterFolderPath, string deviceName)
            : base(modulesType, parameterFolderPath, deviceName)
        {
            if (!g_bInitialFlag)
            {
                PrepareErrorCodes();

                FlowControl           flowControl          = ModulesFactory.FlowControlHelper.GetFlowControl("SYNTEKMotion");
                CEtherCAT_CheckStatus etherCAT_CheckStatus = new CEtherCAT_CheckStatus();
                flowControl.AddFlowBase(etherCAT_CheckStatus);
                etherCAT_CheckStatus.Start();

                EtherCATInitializationForm.GetInstance().ShowForm();
                EtherCATInitializationForm.GetInstance().SetStatus("Wait Initial");
                masterCardInitialize();
                EtherCATInitializationForm.GetInstance().CloseForm();

                etherCAT_CheckStatus.Stop();
            }
        }
Esempio n. 4
0
 public override void Flow()
 {
     if (CEtherCAT.g_nESCExistCards > 0)
     {
         for (ushort uCount = 0; uCount < CEtherCAT.g_nESCExistCards; uCount++)
         {
             ushort uConnectStatus = 0, uInitialDone = 0, uRet = 0, uAbnormal_Flag = 0, uWorking_Slave_Cnt = 0;
             uRet = CEtherCAT_DLL.CS_ECAT_Master_Get_Connect_Status(CEtherCAT.g_uESCCardNoList[uCount].CardNo, ref uConnectStatus);
             if (uRet == 0)
             {
                 if (uConnectStatus == 0)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus = "Initial Mode";
                 }
                 else if (uConnectStatus == 1)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus = "Pre-OP Mode";
                 }
                 else if (uConnectStatus == 4)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus = "Safe-OP Mode";
                 }
                 else if (uConnectStatus == 8)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus = "OP Mode";
                 }
             }
             uRet = CEtherCAT_DLL.CS_ECAT_Master_Check_Initial_Done(CEtherCAT.g_uESCCardNoList[uCount].CardNo, ref uInitialDone);
             if (uRet == 0)
             {
                 if (uInitialDone == 0)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].InitialStatus = "Initial Done";
                 }
                 else if (uInitialDone == 1)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].InitialStatus = "Pre Initial";
                 }
                 else if (uInitialDone == 99)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].InitialStatus = "Initial Error";
                 }
             }
             uRet = CEtherCAT_DLL.CS_ECAT_Master_Check_Working_Counter(CEtherCAT.g_uESCCardNoList[uCount].CardNo, ref uAbnormal_Flag, ref uWorking_Slave_Cnt);
             if (CEtherCAT.IsInitialized)
             {
                 if (uAbnormal_Flag == 0)
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus = "Normal";
                 }
                 else
                 {
                     CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus = "Abnormal";
                 }
                 CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus = string.Format("{0} {1} / {2}", CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus, uWorking_Slave_Cnt, CEtherCAT.SlaveInfos.Count);
             }
             else
             {
                 string nowStatus = string.Format("{0}, {1}", CEtherCAT.g_uESCCardNoList[uCount].ConnectStatus, CEtherCAT.g_uESCCardNoList[uCount].InitialStatus);
                 if (nowStatus != _status)
                 {
                     _status = nowStatus;
                     EtherCATInitializationForm.GetInstance().SetStatus(uCount, nowStatus);
                 }
             }
         }
     }
 }