コード例 #1
0
            /// <summary>
            /// Построить гофрированный стакан.
            /// </summary>
            /// <param name="glass">Гофрированный стакан.</param>
            public void Build(IGlass glass)
            {
                _builderBlank.Build(glass);

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.ActiveDocument3D;

                var part = (ksPart)doc.GetPart(
                    (short)Part_Type.pTop_Part);

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var offsetCrimpPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, _calcParams.OffsetFacetedPlane);

                var sketchCrimp = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCrimp.name = "Эскиз рефлёностей";

                var sketchDefCrimp =
                    (ksSketchDefinition)sketchCrimp.GetDefinition();

                sketchDefCrimp.SetPlane(offsetCrimpPlane);

                sketchCrimp.Create();

                GenerateExtrusionCrimp2d(sketchDefCrimp);
                GenerateExtrusionCrimp3d(sketchCrimp, part);
            }
コード例 #2
0
            /// <summary>
            /// Построить граненный стакан в САПР Компас 3D.
            /// </summary>
            /// <param name="glass">Граненный стакан.</param>
            public void Build(IGlass glass)
            {
                _builderBlank.Build(glass);

                _startX = 0;
                _startY = 0;

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.ActiveDocument3D;

                var part = (ksPart)doc.GetPart((short)Part_Type.pTop_Part);

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var offsetCutFacetedPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, _calcParams.OffsetFacetedPlane);

                var sketchCutFaceted = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCutFaceted.name = "Эскиз граней";

                var sketchDefCutFaceted =
                    (ksSketchDefinition)sketchCutFaceted.GetDefinition();

                sketchDefCutFaceted.SetPlane(offsetCutFacetedPlane);

                sketchCutFaceted.Create();

                GenerateCutFaceted2d(sketchDefCutFaceted);
                GenerateCutFaceted3d(sketchCutFaceted, part);
            }
コード例 #3
0
        public void CheckCalculateParams(IGlass glass)
        {
            var actual = new CalcParams(glass);
            var exp    = new CalcParamsFake(glass);

            Assert.That(exp.DiameterFacetedStart,
                        Is.EqualTo(actual.DiameterFacetedStart),
                        "DiameterFacetedStart");
            Assert.That(exp.DiameterSideCutting,
                        Is.EqualTo(actual.DiameterSideCutting),
                        "DiameterSideCutting");
            Assert.That(exp.DiameterStripsCrimp,
                        Is.EqualTo(actual.DiameterStripsCrimp),
                        "DiameterStripsCrimp");
            Assert.That(exp.HeightCutting,
                        Is.EqualTo(actual.HeightCutting),
                        "HeightCutting");
            Assert.That(exp.OffsetFacetedPlane,
                        Is.EqualTo(actual.OffsetFacetedPlane),
                        "OffsetFacetedPlane");
        }
コード例 #4
0
ファイル: CalcModule.cs プロジェクト: martugin/InfoTask2
        private void LoadParams(string fileName, string tablName)
        {
            using (var db = new DaoDb(Dir + fileName + ".accdb"))
            {
                var paramsId = new DicI <CalcParam>();
                using (var rec = new DaoRec(db, tablName + "Params"))
                    while (rec.Read())
                    {
                        var cp = new CalcParam(this, rec, false);
                        CalcParams.Add(cp.Code, cp);
                        paramsId.Add(rec.GetInt("ParamId"), cp);
                    }

                using (var rec = new DaoRec(db, tablName + "SubParams"))
                    while (rec.Read())
                    {
                        var cp    = new CalcParam(this, rec, true);
                        var owner = paramsId[rec.GetInt("ParamId")];
                        owner.SubParams.Add(cp.Code, cp);
                        cp.Owner = owner;
                    }
            }
        }
コード例 #5
0
            /// <summary>
            /// Построить модель стакана в САПР Компас 3D.
            /// </summary>
            /// <param name="photoFrame">Шаблон стакана.</param>
            /// <exception cref="InvalidOperationException">
            ///     Вызывается тогда, когда параметры стакана
            ///     имеют недопустимые значения.</exception>
            public void Build(IGlass glass)
            {
                if (glass.IsValid == false)
                {
                    var msg = String.Format("Шаблон стакана имеет" +
                                            " недопустимые параметры для построения.");
                    throw new InvalidOperationException(msg);
                }

                _kompas.ShowCAD();

                _startX = 0;
                _startY = 0;

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.Document3D;

                doc.Create();

                var part = (ksPart)doc.GetPart((short)Part_Type.pTop_Part);

                var sketchBase = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchBase.name = "Эскиз основания";

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var sketchDefBase =
                    (ksSketchDefinition)sketchBase.GetDefinition();

                sketchDefBase.SetPlane(basePlane);

                sketchBase.Create();

                var sketchCutSide = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCutSide.name = "Эскиз вырезанных внутренностей";

                var offsetCutPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, glass.Height);

                var sketchDefCutSide =
                    (ksSketchDefinition)sketchCutSide.GetDefinition();

                sketchDefCutSide.SetPlane(offsetCutPlane);

                sketchCutSide.Create();

                GenerateBlank2d(sketchDefBase);
                GenerateBlank3d(sketchBase, part);
                GenerateCutSide2d(sketchDefCutSide);
                GenerateCutSide3d(sketchCutSide, part);

                if (glass.Filleted)
                {
                    FilletedBottomAndTop(glass, part);
                }
            }
コード例 #6
0
        //Компиляция проекта, возвращает количество ошибок компиляции
        public string CompileProject()
        {
            //OnlyOn = true;
            CountsToZero();
            if (State == State.Project || State == State.Empty)//Если не загружены, то загружаем сигналы
            {
                string s = LoadSignals();
                if (s != "")
                {
                    return(s);
                }
            }
            else
            {
                foreach (var sig in SignalsList)
                {
                    sig.InUse         = false;
                    sig.InUseSource   = false;
                    sig.InUseReceiver = false;
                }
            }
            StartAtom(Atom.CompileProject);
            if (State == State.Closed)
            {
                AddError("Копилятор уже был закрыт");
            }
            else
            {
                try
                {
                    //Обнуления поля Expr и т.п.
                    using (var daodb = new DaoDb(_projectFile))
                    {
                        //daodb.Execute("UPDATE CalcParams SET CalcParams.Expr = Null, CalcParams.ErrMess = Null, CalcParams.UsedUnits = Null, CalcParams.CalcNumber = 0;");
                        foreach (string tab in new[] { "CalcParams", "CalcSubParams" })
                        {
                            using (var rec = new RecDao(daodb, tab))
                                while (rec.Read())
                                {
                                    rec.Put("Expr", (string)null);
                                    try { rec.Put("UsedUnits", (string)null); } catch { }
                                    rec.Put("CalcNumber", 0);
                                    rec.Put("ErrMess", (string)null);
                                    rec.Update();
                                }
                        }
                        CalcParams.Clear();
                        CalcParamsId.Clear();
                        CalcParamsAll.Clear();
                        Grafics.Clear();
                        ArchiveParams.Clear();
                        Prevs.Clear();
                        HandSignals.Clear();
                        CalcParamNumber = 0;

                        Procent = 10;
                        AddEvent("Загрузка графиков");
                        using (var rec = new RecDao(daodb, "SELECT GraficsList.Code, GraficsList.Dimension FROM GraficsList"))
                            while (rec.Read())
                            {
                                var gr = new Grafic(rec.GetString("Code"), rec.GetInt("Dimension"));
                                Grafics.Add(gr.Code, gr);
                            }

                        Procent = 15;
                        AddEvent("Загрузка параметров");
                        string spar = OnlyOn ? "WHERE (CalcOn = True) And (TaskOn = True)" : "";
                        using (var rec = new RecDao(daodb, "SELECT CalcParams.* FROM CalcParams " + spar + " ORDER BY CalcParamId"))
                            while (rec.Read())
                            {
                                new CalcParam(rec, this);
                            }

                        Procent = 25;
                        AddEvent("Загрузка подпараметров");
                        string ssub = OnlyOn ? "WHERE (CalcParams.CalcOn = True) And (CalcParams.TaskOn = True) And (CalcSubParams.CalcOn = True)" : "";
                        using (var rec = new RecDao(daodb, "SELECT CalcSubParams.* FROM CalcParams INNER JOIN CalcSubParams ON CalcParams.CalcParamId = CalcSubParams.OwnerId " + ssub))
                            while (rec.Read())
                            {
                                new CalcParam(rec, this, true);
                            }

                        Procent = 35;
                        AddEvent("Разбор выражений");
                        foreach (var cp in CalcParamsId.Values)
                        {
                            cp.Parse();
                        }

                        IsPrevAbs     = false;
                        IsLastBase    = false;
                        IsLastHour    = false;
                        IsLastDay     = false;
                        IsManyBase    = false;
                        IsManyHour    = false;
                        IsManyDay     = false;
                        IsManyMoments = false;

                        Procent = 45;
                        AddEvent("Компиляция выражений");
                        foreach (var cp in CalcParamsId.Values)
                        {
                            if (cp.Stage == CompileStage.NotStarted)
                            {
                                cp.Compile(null);
                            }

                            /*foreach (var d in cp.MethodsId.Values)
                             *  if (d.Stage == CompileStage.NotStarted)
                             *      d.Compile(null);*/
                        }

                        FindCycleLinks();

                        ErrorsCount   = 0;
                        UsedProviders = new SetS();
                        IsAbsolute    = false;
                        IsPeriodic    = false;
                        IsMoments     = false;

                        Procent = 60;
                        AddEvent("Сохранение результатов компиляции параметров");
                        using (var rec = new RecDao(daodb, "SELECT CalcParams.* FROM CalcParams " + spar + " ORDER BY CalcParamId"))
                            SaveCompile(rec, false);

                        Procent = 70;
                        AddEvent("Сохранение результатов компиляции подпараметров");
                        using (var rec = new RecDao(daodb, "SELECT CalcSubParams.* FROM CalcParams INNER JOIN CalcSubParams ON CalcParams.CalcParamId = CalcSubParams.OwnerId " + ssub + " ORDER BY CalcParams.CalcParamId;"))
                            SaveCompile(rec, true);
                    }

                    Procent = 80;
                    AddEvent("Сохранение списка используемых сигналов и графиков");
                    SaveInUse();

                    Procent = 90;
                    AddEvent("Сохранение архивных параметров");
                    SaveArchive();

                    Procent = 96;
                    AddEvent("Сохранение параметров функций Пред");
                    SavePrevs();

                    Procent = 99;
                    SaveUsedProviders();
                    using (var sys = new SysTabl(_projectFile))
                    {
                        sys.PutSubValue("CompileStatus", "LastTimeCompile", DateTime.Now.ToString());
                        sys.PutSubValue("CompileStatus", "ErrorsCount", ErrorsCount.ToString());
                    }
                }
                catch (Exception ex)
                {
                    AddError("Ошибка компилятора", ex);
                }
            }
            return(FinishAtom(State.Compiled, State.Signals, "Проект: " + _code + ";  Ошибок: " + ErrorsCount + ";" + Different.NewLine
                              + "Параметров: " + CalcParamsId.Count + "; Архивных параметров:" + ArchiveParams.Count + ";  Сигналов: " + SignalsInUseCount));
        }
コード例 #7
0
        /// <summary>
        /// 根据AppIntegratedInfo的信息生成组合表,包括测量数据、计算数据、备注
        /// </summary>
        /// <param name="num">需要显示数据的个数</param>
        /// <returns></returns>
        public DataTable ConstructTable()
        {
            DataTable dt = null;

            if (CalcParams.Count > 0)
            {
                List <DateTimeOffset> timeList = null;
                //必须具有计算参数
                if (MesParams.Count > 0)
                {
                    timeList = (from i in MesValues
                                select i.Date).Distinct().ToList();
                }
                else
                {
                    //没有测量参数的情况
                    timeList = (from i in CalcValues
                                select i.Date).Distinct().ToList();
                }

                int temp = int.MaxValue;
                if (_topNum > 0)
                {
                    temp = _topNum;
                }

                dt = createDataTableSchema();

                for (int index = 0; index < timeList.Count && index < temp; index++)
                {
                    DataRow row = dt.NewRow();

                    DateTimeOffset date = timeList[index];
                    row[PubConstant.timeColumnName] = date;



                    foreach (MessureValue mv in MesValues.Where(s => s.Date == date))
                    {
                        string aParamName = MesParams.First(s => s.Id == mv.ParamId).ParamName; //mv.messureParam.ParamName;
                        if (mv.Val != null)
                        {
                            row[aParamName] = mv.Val;
                        }
                    }



                    foreach (CalculateValue cv in CalcValues.Where(s => s.Date == date))
                    {
                        string aParamName = CalcParams.First(s => s.Id == cv.ParamId).ParamName; //cv.calculateParam.ParamName;
                        if (cv.Val != null)
                        {
                            row[aParamName] = cv.Val;
                        }
                    }

                    Remark remark = Remarks.FirstOrDefault(s => s.Date == date);
                    if (remark != null)
                    {
                        row[PubConstant.remarkColumnName] = remark.RemarkText;
                    }
                    dt.Rows.Add(row);
                }

                dt.AcceptChanges();
            }

            return(dt);
        }