Пример #1
0
        private static string ConvertGerber(string gerberCode, string filePath)
        {
            Logger.Info(" convertGerber {0}", filePath);
            logFlags      = (uint)Properties.Settings.Default.importLoggerSettings;
            logEnable     = Properties.Settings.Default.guiExtendedLoggingEnabled && ((logFlags & (uint)LogEnable.Level1) > 0);
            logDetailed   = logEnable && ((logFlags & (uint)LogEnable.Detailed) > 0);
            logCoordinate = logEnable && ((logFlags & (uint)LogEnable.Coordinates) > 0);
            if (logEnable)
            {
                Logger.Trace("  logging:{1}", Convert.ToString(logFlags, 2));
            }

            conversionInfo = "";
            shapeCounter   = 0;

            isPenDown  = false;
            isUnitInch = true;
            setX       = 0; setY = 0; setI = 0; setJ = 0;
            gMode      = 1;

            numberFormatIX = 2;
            numberFormatFX = 5;
            numberFormatIY = 2;
            numberFormatFY = 5;
            actualAperture = new aperture();
            apertures      = new Dictionary <string, aperture>();

            messageList.Clear();

            Graphic.Init(Graphic.SourceTypes.Gerber, filePath);
            GetVectorGerber(gerberCode);                        // convert graphics
            conversionInfo += string.Format("{0} elements imported", shapeCounter);
            return(Graphic.CreateGCode());
        }
Пример #2
0
        private static void ParseCommand(string token)
        {
            if (logDetailed)
            {
                Logger.Trace("   ParseCommand {0}", token);
            }
            char command = token[0];

            if (token.Length == 1)
            {
                if (command == 'A')
                {
                    processD(2);
                }
                ;                                       // knife up
                if (command == 'B')
                {
                    setType(geometryKnife); processD(1);
                }                                                               // knife down
                return;
            }
            string val   = token.Substring(1);
            int    value = 0;

            if (int.TryParse(val, NumberStyles.Number, NumberFormatInfo.InvariantInfo, out value))
            {
                //               Logger.Trace("ParseCommand command:{0} value:{1}", token, value);
                if (command == 'X')
                {
                    setXValue(val);  xyIsGivenInCommand = true;
                }
                else if (command == 'Y')
                {
                    setYValue(val);  xyIsGivenInCommand = true;
                }
                else if (command == 'I')
                {
                    setIValue(val);  xyIsGivenInCommand = true;
                }
                else if (command == 'J')
                {
                    setJValue(val);  xyIsGivenInCommand = true;
                }

                else if (command == 'D')
                {
                    if (value < 10)
                    {
                        setType(geometryPen);
                        processD(value);
                    }
                    else
                    {
                        if (apertures.ContainsKey(token))
                        {
                            actualAperture = apertures[token];
                            Graphic.SetLayer(token);// + " " + actualAperture.content);
                            Graphic.SetHeaderInfo(token + " = " + actualAperture.content);
                            Graphic.SetPenWidth(actualAperture.XSize.ToString().Replace(',', '.'));
                            if (logEnable)
                            {
                                Logger.Trace("   apply aperture {0}  {1}", token, actualAperture.apType.ToString());
                            }
                        }
                        else
                        {
                            Logger.Error("Aperture key not found {0}", token);
                        }
                    }
                }

                else if (command == 'G')
                {
                    if ((value >= 1) && (value <= 3))
                    {
                        gMode = value;
                        if (logEnable)
                        {
                            Logger.Trace("   set G {0}", value);
                        }
                    }
                }

                else if (command == 'M')
                {
                    processM(value);
                }


                else if (command == 'N')
                {
                    Graphic.SetLayer("Sequence_" + val.ToString().PadLeft(4, '0'));
                }


                else if (command == 'R')
                {
                }


                else if (command == 'H')
                {
                    numberFormatIX = 6; numberFormatFX = 2;
                    numberFormatIY = 6; numberFormatFY = 2;
                }
            }
            else
            {
                Logger.Trace("ParseCommand command {0} fail int", token);
                if (val.Contains("G04"))
                {
                    Graphic.SetHeaderInfo(val.Substring(3));
                }
            }
        }
Пример #3
0
    public bool PutTcSlitAperture(ref aperture _aperture, ref double size)
    {
        string message = "put/bl_29in_tc1_slit_1_" + _aperture + "/" + size.ToString("F2") + "mm";

        //PutMessage(message);

        return GetBoolResponse(message);
    }
Пример #4
0
    /// <summary>
    /// TCスリットの開口を取得
    /// </summary>
    /// <param name="_aperture">方向</param>
    /// <returns></returns>
    public string GetTCSlitAperture(aperture _aperture)
    {
        string message = "get/bl_29in_tc1_slit_1_" + _aperture + "/aperture";

        return GetResponse(message).Split('/')[3];
    }