//to delete EW_PASSWD
        public static bool DeletePrograms(string ipAddress, ushort portNo, short programNumber)
        {
            bool      isdeleted = false;
            focas_ret ret;
            int       ret1           = -1;
            ushort    focasLibHandle = 0;

            ret1 = FocasLib.cnc_allclibhndl3(ipAddress, portNo, 10, out focasLibHandle);
            if (ret1 != 0)
            {
                Logger.WriteErrorLog("cnc_allclibhndl3() failed. return value is = " + ret1);
                return(false);
            }
            short retShort = FocasLib.cnc_delete(focasLibHandle, programNumber);

            Enum.TryParse <focas_ret>(retShort.ToString(), out ret);
            switch (ret)
            {
            case focas_ret.EW_OK:
                Logger.WriteDebugLog("PROGRAM" + programNumber + " has been deleted.");
                isdeleted = true;
                break;

            case focas_ret.EW_DATA:
                Logger.WriteDebugLog("PROGRAM " + programNumber + " doesn't exist.");
                break;

            case focas_ret.EW_PROT:
                Logger.WriteDebugLog("Program " + programNumber + " is PROTECTED.");
                break;

            case focas_ret.EW_BUSY:
                Logger.WriteDebugLog("CNC is busy. Program " + programNumber + "  delete REJECTED.");
                break;

            case focas_ret.EW_PASSWD:
                Logger.WriteDebugLog("Specified program number cannot be deleted because the data is protected.");
                break;
            }
            return(isdeleted);
        }
Пример #2
0
        public static bool DeletePrograms(string ipAddress, ushort portNo, string programNumber, string folderPath, bool isProgramFolderSupports, bool showMsg = true)
        {
            short  tempProgramNo    = 0;
            string tempProgramNoStr = "";

            if (isProgramFolderSupports == false)
            {
                short.TryParse(programNumber.TrimStart(new char[] { 'O', ' ' }), out tempProgramNo);
                if (tempProgramNo == 0)
                {
                    return(false);
                }
            }
            else
            {
                tempProgramNoStr = programNumber;
            }

            bool      isdeleted = false;
            focas_ret ret;
            int       ret1           = -1;
            ushort    focasLibHandle = 0;

            ret1 = FocasLib.cnc_allclibhndl3(ipAddress, portNo, 10, out focasLibHandle);
            if (ret1 != 0)
            {
                Logger.WriteErrorLog("cnc_allclibhndl3() failed. return value is = " + ret1);
                Logger.WriteErrorLog("Not able to connect to CNC machine. Please check the network connection and try again");
                return(false);
            }

            if (isProgramFolderSupports == true)
            {
                string fileName = folderPath + tempProgramNoStr;
                ret1 = FocasLib.cnc_pdf_del(focasLibHandle, fileName);
            }
            else
            {
                ret1 = FocasLib.cnc_delete(focasLibHandle, tempProgramNo);
            }

            if (ret1 != 0 && ret1 != 5)
            {
                Logger.WriteErrorLog("Not able to delete program. Return value = " + ret1);
            }

            Enum.TryParse <focas_ret>(ret1.ToString(), out ret);


            switch (ret)
            {
            case focas_ret.EW_OK:
                if (showMsg)
                {
                    Logger.WriteDebugLog("PROGRAM " + programNumber + " has been deleted.");
                    //  MessageBox.Show("Program " + programNumber + " has been deleted.");
                }
                isdeleted = true;
                break;

            case focas_ret.EW_DATA:
                Logger.WriteDebugLog("PROGRAM " + programNumber + " doesn't exist.");
                //MessageBox.Show("PROGRAM " + programNumber + " doesn't exist.");
                break;

            case focas_ret.EW_PROT:
                Logger.WriteDebugLog("Program " + programNumber + " is PROTECTED.");
                break;

            case focas_ret.EW_BUSY:
                Logger.WriteDebugLog("CNC is busy. Program " + programNumber + "  delete REJECTED.");
                break;

            case focas_ret.EW_PASSWD:
                Logger.WriteDebugLog("Specified program number cannot be deleted because the data is protected.");
                break;
                //case focas_ret.DEL_FAILED:
                //    break;
            }
            FocasLib.cnc_freelibhndl(focasLibHandle);
            return(isdeleted);
        }