public static void SetFileManager(IFileManager fileManager)
        {
            if (fileManager != null)
            {
                _getCurrentDirectoryDelegate = fileManager.GetCurrentDirectory;
                _fileExistsDelegate = fileManager.FileExists;
                _isAbsolutePathDelegate = fileManager.IsAbsolutePath;
                _toAbsolutePathDelegate = fileManager.ToAbsolutePath;
                _readFileDelegate = fileManager.ReadFile;

                var delegates = new FileManagerDelegates
                {
                    GetCurrentDirectoryDelegate =
                        Marshal.GetFunctionPointerForDelegate(_getCurrentDirectoryDelegate),
                    FileExistsDelegate =
                        Marshal.GetFunctionPointerForDelegate(_fileExistsDelegate),
                    IsAbsolutePathDelegate =
                        Marshal.GetFunctionPointerForDelegate(_isAbsolutePathDelegate),
                    ToAbsolutePathDelegate =
                        Marshal.GetFunctionPointerForDelegate(_toAbsolutePathDelegate),
                    ReadFileDelegate =
                        Marshal.GetFunctionPointerForDelegate(_readFileDelegate)
                };
                FileManagerMarshaller.SetDelegates(delegates);
            }
            else
            {
                UnsetFileManager();
            }
        }
Example #2
0
        private void CreateAll()
        {
            this.m_Datas.Clear();
            this.CreateTableColumnList();
            string cbx_name = "";

            for (int i = 1; i <= 6; i++)
            {
                cbx_name = "CbxTabelle" + FuncString.FillForward(i.ToString(), "0", 2);
                ComboBox obj_cbx_tabelle = (ComboBox)FuncGeneral.GetControlByName(this, cbx_name);
                obj_cbx_tabelle.Items.Clear();
                obj_cbx_tabelle.Items.AddRange(this.m_Tablelist.ToArray());
                obj_cbx_tabelle.SelectedIndexChanged += new System.EventHandler(this.CbxTable_SelectedIndexChanged);
                obj_cbx_tabelle.SelectedIndex         = obj_cbx_tabelle.Items.IndexOf(this.m_ClsIni.getValue("AuswahlTabelle", cbx_name));

                cbx_name = "CbxSpalte" + FuncString.FillForward(i.ToString(), "0", 2);
                ComboBox obj_cbx_column = (ComboBox)FuncGeneral.GetControlByName(this, cbx_name);
                obj_cbx_column.SelectedIndex         = obj_cbx_column.Items.IndexOf(this.m_ClsIni.getValue("AuswahlTabelle", cbx_name));
                obj_cbx_column.SelectedIndexChanged += new System.EventHandler(this.CbxColumn_SelectedIndexChanged);

                cbx_name = "txtFilter" + FuncString.FillForward(i.ToString(), "0", 2);
                TextBox obj_txt_filter = (TextBox)FuncGeneral.GetControlByName(this, cbx_name);
                obj_txt_filter.Text         = this.m_ClsIni.getValue("AuswahlTabelle", cbx_name);
                obj_txt_filter.TextChanged += new System.EventHandler(this.txtFilter_TextChanged);
            }

            for (int i = 1; i <= 2; i++)
            {
                cbx_name = "cbxAndOr" + FuncString.FillForward(i.ToString(), "0", 2);
                ComboBox obj_cbx_column = (ComboBox)FuncGeneral.GetControlByName(this, cbx_name);
                obj_cbx_column.SelectedIndex         = obj_cbx_column.Items.IndexOf(this.m_ClsIni.getValue("AuswahlTabelle", cbx_name));
                obj_cbx_column.SelectedIndexChanged += new System.EventHandler(this.cbxAndOr_SelectedIndexChanged);
            }
        }
Example #3
0
        public void  PlotFuncParallel(FuncString fs, int decimallength = 6, int points = 100, params double[] xstart)
        {
//			if (decimallength==0) {
//				decimallength=6;
//			}
//			if (points==0) {
//				points=100;
//			}
            double  xa = xstart[0];
            double  xb = xstart[1];
            double  x  = xa;
            MyChart mc = new MyChart();

            mc.SetChartArea();
            int times = 0;

            Parallel.For(times, points,
                         (i) => {
//				fc.DealFuncstring( ((decimal)x).ToString());
//				fc.DealFuncstring(x.ToString(("f"+decimallength.ToString())));
                //在调用之前就已经把参数代进去了 fs是经过替换得到的
                double result = uc.GetFuncResult(fs, x.ToString(("f" + decimallength.ToString())));
                mc.CreateSeriesData(x, result);

                x = x + 1.0 * (xb - xa) / points;
            });
//			mc.CreateSeriesDatas(new double[]{1,2,3,4,5,6,7,8},new double[]{1,-1,1,-1,1,-1,1,-1});
            mc.SetSeries();
            FuncFigure ff = new FuncFigure();

            ff.AddChart(mc.GetChart());
            ff.ShowDialog();
        }
Example #4
0
        public void  PlotFunc(FuncString fs, int decimallength = 6, int points = 100, params double[] xstart)
        {
//			if (decimallength==0) {
//				decimallength=6;
//			}
//			if (points==0) {
//				points=100;
//			}
            double  xa = xstart[0];
            double  xb = xstart[1];
            double  x  = xa;
            MyChart mc = new MyChart();

            mc.SetChartArea();
            for (int i = 0; i < points; i++)
            {
//				fc.DealFuncstring( ((decimal)x).ToString());
//				fc.DealFuncstring(x.ToString(("f"+decimallength.ToString())));
                double result = uc.GetFuncResult(fs, x.ToString(("f" + decimallength.ToString())));
                mc.CreateSeriesData(x, result);

                x = x + 1.0 * (xb - xa) / points;
//				Console.WriteLine(i+"  X={0}\tY={1}",x.ToString(),fc.GetResult());
            }
//			mc.CreateSeriesDatas(new double[]{1,2,3,4,5,6,7,8},new double[]{1,-1,1,-1,1,-1,1,-1});
            mc.SetSeries();
            FuncFigure ff = new FuncFigure();

            ff.AddChart(mc.GetChart());
            ff.ShowDialog();
        }
Example #5
0
        private void CreateO2Curve()
        {
            string       caption   = "O2 Kurve";
            TabPage      tab_page  = this.CreateTabPage(caption, this.m_tabControl);
            GroupBox     group_box = (GroupBox)this.CreateGroupBox(4, 4, this.m_tabControl.Width - 18, this.m_tabControl.Height - 56, caption, tab_page);
            Label        label;
            CompMultiBar multi_bar;
            int          off            = 290;
            int          width_label    = 48;
            int          width          = 30;
            int          space          = 2;
            int          left           = 4;
            int          left_multi_bar = 0;

            for (int i = 0; i < 11; i++)
            {
                string format = "{0:0.00}";
                label          = this.CreateLabel(left, i * 20 + off, width_label, 20, String.Format(format, 10 - i) + "-", group_box);
                left_multi_bar = label.Left + label.Width + space;
            }
            string varname = "";
            int    col     = 0;
            int    row     = 0;

            for (int i = 0; i < 21; i++)
            {
                multi_bar           = this.CreateMultiBar(i * (width + space) + left_multi_bar, off + 13, width, 200, group_box);
                multi_bar.Name      = "compMultiBarBurnerLoad" + i.ToString();
                multi_bar.ColorBar1 = Color.Blue;
                multi_bar.Click    += new System.EventHandler(this.compMultiBarBurnerLoad_Click);

                label   = this.CreateLabel(i * (width + space) + left_multi_bar, multi_bar.Top + multi_bar.Height + space, width, 30, i.ToString(), group_box, ContentAlignment.MiddleCenter);
                varname = "DB55.Burner" + FuncString.FillForward(i.ToString(), "0", 2);
                this.m_dataBinding.AddList(this, multi_bar.Name.ToString(), "Value1", varname);

                PlcItemList plc_item_list = this.GetPlcItemList(varname);

                CompInputBox input_box;
                left = col * (89 + 2) + 72;
                int top = row * (35 + 2) + 30;
                plc_item_list.Varname = varname;
                input_box             = this.CreateInputBox(left, top, plc_item_list.Format, group_box);
                input_box.Name        = "compInputBoxBurnerLoad" + i.ToString();
                input_box.Symbol      = varname;
                input_box.KeyPress   += new System.Windows.Forms.KeyPressEventHandler(this.InputBox_KeyPress);
                input_box.Leave      += new System.EventHandler(this.compInputBoxBurnerLoad_Leave);
                input_box.Enter      += new System.EventHandler(this.compInputBoxBurnerLoad_Enter);
                this.m_dataBinding.AddList(this, input_box.Name.ToString(), "Text", varname);
                this.m_plcItemList.Add(input_box, plc_item_list);
                this.m_userManagement.AddUserRightControl(input_box, plc_item_list.UserRightEnable);
                col++;
                if (col > 6)
                {
                    this.CreateLabel(input_box.Left + input_box.Width + space, input_box.Top, 20, input_box.Height, plc_item_list.Unit, group_box, ContentAlignment.MiddleLeft);
                    row++;
                    col = 0;
                }
            }
        }
Example #6
0
        private void compInputBoxDriveGas_Enter(object sender, EventArgs e)
        {
            this.ResetSelectAllDriveGas();
            CompInputBox obj           = (CompInputBox)sender;
            string       number        = FuncString.GetOnlyNumeric(obj.Name);
            CompMultiBar obj_set_focus = (CompMultiBar)this.m_dataBinding.GetControlByName(this, "compMultiBarCompoundDriveGas" + number);

            obj_set_focus.Choise = true;
        }
Example #7
0
        private void compInputBoxDriveGas_Leave(object sender, EventArgs e)
        {
            CompInputBox obj           = (CompInputBox)sender;
            string       number        = FuncString.GetOnlyNumeric(obj.Name);
            CompMultiBar obj_set_focus = (CompMultiBar)this.m_dataBinding.GetControlByName(this, "compMultiBarCompoundDriveGas" + number);

            obj_set_focus.Choise = false;
            this.InputBox_Leave(sender, e);
        }
        public static void UnsetFileManager()
        {
            FileManagerMarshaller.UnsetDelegates();

            _getCurrentDirectoryDelegate = null;
            _fileExistsDelegate = null;
            _isAbsolutePathDelegate = null;
            _toAbsolutePathDelegate = null;
            _readFileDelegate = null;
        }
Example #9
0
        private void compMultiBarBurnerLoad_Click(object sender, EventArgs e)
        {
            this.ResetSelectAllBurnerLoad();
            CompMultiBar obj    = (CompMultiBar)sender;
            string       number = FuncString.GetOnlyNumeric(obj.Name);

            obj.Choise = true;
            CompInputBox obj_set_focus = (CompInputBox)this.m_dataBinding.GetControlByName(this, "compInputBoxBurnerLoad" + number);

            obj_set_focus.Focus();
        }
Example #10
0
        private void rotaBitButton1_Click(object sender, EventArgs e)
        {
            FuncGeneral.KillProgram("EXCEL");
            ExcelHelper xls = new ExcelHelper();

            xls.Workbook_Hinzufuegen();

            this.m_SqlHelper.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);
            int  i          = 0;
            bool add_select = true;

            foreach (string ert in this.m_Tablelist)
            {
                string   table = m_Tablelist[i];
                string[] cols  = m_ColumnlistOutput[i];
                foreach (string col in cols)
                {
                    if (add_select == true)
                    {
                        add_select = false;
                        this.m_SqlHelper.SQLBuilderHinzufuegen("SELECT TOP 100", SQLHelper.SQLBuilder.DeleteSQL);
                    }
                    string suchen = table + "." + col + ",";
                    this.m_SqlHelper.SQLBuilderHinzufuegen(suchen, SQLHelper.SQLBuilder.NoSpace);
                }
                i++;
            }


            string sql            = "";
            string sql_where      = "";
            string sql_inner_join = "";

            sql = this.m_SqlHelper.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);
            sql = FuncGeneral.DeleteRight(sql, 1);
            this.m_SqlHelper.SQLBuilderHinzufuegen(sql, SQLHelper.SQLBuilder.DeleteSQL);


            sql            = this.m_SqlHelper.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);
            sql_inner_join = this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);
            sql_where      = this.m_SqlHelperWhere.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);

            this.textBox2.Text = sql + sql_inner_join + sql_where;
            xls.SQL2Excel(this.textBox2.Text, m_ConnectionString);
            string file_name = "Messwerte" + FuncString.GetOnlyNumeric(FuncString.GetTimestamp());

            xls.DateiSpeichern(file_name);

            xls.ExcelHelperClose();
            xls = null;
        }
Example #11
0
        /// <summary>
        /// 给定函数的名字 返回修改Funcexpresstemp后的FuncString对象 连同变量一同替换 一步到位
        /// </summary>
        /// <param name="funname">函数名</param>
        /// <returns>FuncString 或者 null</returns>
        public FuncString FindFuncInTDC(string funname)
        {
            FuncString fs = null;

            if (tdc.CheckName(funname))
            {
                FuncString funs        = tdc.GetData(funname).ConvertTOFunString();
                string     funcexpress = ReplaceParamers(funs.GetFuncExpress(), funs.GetParamers());
                if (funcexpress != null)
                {
                    funs.SetFuncExpress(funcexpress);
                }
                fs = funs;
            }
            return(fs);
        }
Example #12
0
        public BlockData ConverToBlock()
        {
            FuncString funstring    = new FuncString(strExpress);
            int        leftBracket  = funstring.FindOp(0, '(');
            int        rightBracket = funstring.FindOp(0, ')');
            int        commaSymbol  = funstring.FindOp(0, ',');

            string[] ab = strExpress.Split(',');
            double   a  = 0;
            double   b  = 0;

            try
            {
                string strA = new ExpData(ab[0].Substring(1)).GetValueEx();
                string strB = new ExpData(ab[1].Substring(0, ab[1].Length - 1)).GetValueEx();
                a = double.Parse(strA);
                b = double.Parse(strB);
            }
            catch (ExpError e)
            {
                throw new AssignedError(e.Message + "\nAssignmentError::区间转换出错" + "\n");
            }
            BlockData bd = new BlockData(a, b);
            bool      left;
            bool      right;

            if (leftBracket != -1 && leftBracket < commaSymbol)
            {
                left = false;
            }
            else
            {
                left = true;
            }
            if (rightBracket != -1 && rightBracket > commaSymbol)
            {
                right = false;
            }
            else
            {
                right = true;
            }
            bd.SetBlockBounderAvailable(left, right);
            cd = bd;
            return(bd);
        }
Example #13
0
        /// <summary>
        /// 给定函数的名字 返回修改Funcexpresstemp后的FuncString对象 连同变量一同替换 一步到位
        /// </summary>
        /// <param name="funname">函数名</param>
        /// <returns>FuncString 或者 null</returns>
        public FuncString FindFuncInTDC(string funname)
        {
            FuncString fs = null;

            if (tdc.CheckName(funname))
            {
                FuncData   fd          = (FuncData)tdc.GetData(funname).GetCalData();
                FuncString funs        = new  FuncString(funname, fd.GetExpValue(), fd.GetParamers());
                string     funcexpress = ReplaceParamers(funs.GetFuncExpress(), funs.GetParamers());
                if (funcexpress != null)
                {
                    funs.SetFuncExpress(funcexpress);
                }
                fs = funs;
            }
            return(fs);
        }
Example #14
0
        private DatenService ParseCommentService(string SymboleName, string Comment)
        {
            DatenService retval;

            string[] commentData = Comment.Split(':');
            string   comment     = commentData[1];

            retval.SymbolTabText = commentData[0];
            retval.SymbolName    = SymboleName;
            retval.Seite         = this.m_TabInfo[retval.SymbolTabText];
            retval.SymbolEinheit = FuncGeneral.Parse("\\[EH.*\\]", ref comment);
            int.TryParse(FuncString.GetOnlyNumeric(FuncGeneral.Parse("\\[ZE[0-9]\\]", ref comment)), out retval.Zeile);
            int.TryParse(FuncString.GetOnlyNumeric(FuncGeneral.Parse("\\[SP[0-9]\\]", ref comment)), out retval.Spalte);
            retval.SymbolKommentar = comment;

            return(retval);
        }
Example #15
0
        /// <summary>
        /// 给定函数FuncString类型 求值
        /// </summary>
        /// <param name="fs">必须得有参数 名字 表达式</param>
        /// <param name="nums">替换的参数</param>
        /// <returns>返回计算结果</returns>
        public double GetFuncResult(FuncString fs, params string[] nums)
        {        //这里的fs应该时是完整的?
            double result = 0;

            if (fs != null)
            {            //改一下
                FuncCal fc = new FuncCal();
                //				FuncString funs=tdc.GetData(fs).ConvertTOFunString();
                fc.SetFuncString(fs);
                fc.DealFuncstring(nums);
                result = fc.GetResult();

                if (fc.IsWrong())
                {
                    PushToShow(fc.ErrorMessage(), "error");
                }
            }
            return(result);
        }
Example #16
0
        public double FuncResult(string fs, TempDataCollection tdcl, params string[] nums)
        {
            double result = 0;

            if (fs != null)
            {
                PushToShow("有括号求值");
                FuncCal    fc   = new FuncCal();
                FuncString funs = tdcl.GetData(fs).ConvertTOFunString();
                fc.SetFuncString(funs);
                fc.DealFuncstring(nums);
                result = fc.GetResult();
                PushToShow("结果:" + fc.GetResult());
                if (fc.IsWrong())
                {
                    PushToShow("出错了!" + fc.ErrorMessage());
                }
            }
            return(result);
        }
Example #17
0
        public double FuncResult(string fs, TempDataCollection tdcl, params string[] nums)
        {
            double result = 0;

            if (fs != null)
            {
                PushToShow("有括号求值");
                FuncCal    fc   = new FuncCal();
                FuncData   fd   = (FuncData)tdc.GetData(fs).GetCalData();
                FuncString funs = new  FuncString(fs, fd.GetExpValue(), fd.GetParamers());
                fc.SetFuncString(funs);
                fc.DealFuncstring(nums);
                result = fc.GetResult();
                PushToShow("结果:" + fc.GetResult());
                if (fc.IsWrong())
                {
                    PushToShow("出错了!" + fc.ErrorMessage());
                }
            }
            return(result);
        }
Example #18
0
        public DataType GetDataType()
        {
            DataType dt = new DataType();

            Function.FuncString funstring = new FuncString(strExpress);

            int leftSquareBracket  = funstring.FindOp(0, '[');
            int rightSquareBracket = funstring.FindOp(0, ']');
            int leftBracket        = funstring.FindOp(0, '(');
            int rightBracket       = funstring.FindOp(0, ')');
            int commaSymbol        = funstring.FindOp(0, ',');
            int semicolon          = funstring.FindOp(0, ';');

            if (commaSymbol == -1 && semicolon == -1)
            {
                dt = DataType.EXP;
                cd = new ExpData(strExpress);
                (cd as ExpData).GetValueFinal();
                return(dt);
            }
            if (semicolon != -1)
            {
                dt = DataType.MATRIX;
                ConvertToMatrix();

                return(dt);
            }
            if (commaSymbol != -1)
            {
                dt = DataType.BLOCK;
                ConverToBlock();
                return(dt);
            }


            return(dt);
        }
Example #19
0
        private void CbxTable_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cbx_table  = (ComboBox)sender;
            string   nummer     = FuncString.FillForward(FuncString.GetOnlyNumeric(cbx_table.Name), "0", 2);
            string   obj_name   = "CbxSpalte" + nummer;
            ComboBox cbx_column = (ComboBox)FuncGeneral.GetControlByName(this, obj_name);

            cbx_column.Items.Clear();

            cbx_column.Items.AddRange(this.m_Columnlist[cbx_table.SelectedIndex]);

            int id = cbx_column.Items.IndexOf(this.m_ClsIni.getValue("AuswahlTabelle", obj_name));

            if (id > -1)
            {
                cbx_column.SelectedIndex = id;
            }
            else
            {
                cbx_column.Text = "";
            }
            this.m_ClsIni.setValue("AuswahlTabelle", cbx_table.Name, cbx_table.SelectedItem.ToString());
            this.m_ClsIni.Save();
        }
Example #20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.helperLibNoDave.LoadPlcData();
            this.LoadComponentBindings();
            glb_plc.IP   = "10.100.72.125";
            glb_plc.Rack = 0;
            glb_plc.Slot = 2;
            glb_plc.Open();
            glb_plc.Read();


            FrmRelease frmRelease = new FrmRelease();
            FrmError   frmError   = new FrmError();
            FrmPara    frmPara    = new FrmPara();
            FrmService frmService = new FrmService();


            List <Helper.Valve> Schieber = new List <Helper.Valve>();

            Schieber.Add(this.ValveV100);
            Schieber.Add(this.ValveV110);
            Schieber.Add(this.ValveV120);
            Schieber.Add(this.ValveV130);
            Schieber.Add(this.ValveV140);

            Schieber.Add(this.ValveV200);
            Schieber.Add(this.ValveV210);
            Schieber.Add(this.ValveV220);

            Schieber.Add(this.ValveV300);
            Schieber.Add(this.ValveV310);
            Schieber.Add(this.ValveV320);

            Schieber.Add(this.ValveV400);
            Schieber.Add(this.ValveV410);
            Schieber.Add(this.ValveV420);

            Schieber.Add(this.ValveV500);
            Schieber.Add(this.ValveV510);

            Schieber.Add(this.ValveV600);
            Schieber.Add(this.ValveV610);
            Schieber.Add(this.ValveV620);
            Schieber.Add(this.ValveV630);
            Schieber.Add(this.ValveV640);
            Schieber.Add(this.ValveV650);
            Schieber.Add(this.ValveV660);
            Schieber.Add(this.ValveV670);
            Schieber.Add(this.ValveV680);
            Schieber.Add(this.ValveV690);
            Schieber.Add(this.ValveV700);
            Schieber.Add(this.ValveV710);


            frmSchieber = new FrmSchieber[Schieber.Count];

            int counter = 0;

            foreach (Helper.Valve schieber in Schieber)
            {
                schieber.Click              += new System.EventHandler(this.valve);
                frmSchieber[counter]         = new FrmSchieber();
                frmSchieber[counter].TopMost = true;
                string frmName = "FrmSchieber" + schieber.Name;
                frmSchieber[counter].Name = frmName;
                string titelFormular = "Schieber " + schieber.Name.Substring(5, 2) + "." + schieber.Name.Substring(7);
                frmSchieber[counter].Text = titelFormular;
                frmMng.FormularAdd(frmSchieber[counter], frmName);
                frmSchieber[counter].BindDatas(FuncString.GetOnlyNumeric(schieber.Name));
                Point xyValve = FuncGeneral.GetMiddle(schieber);

                Point xyFrm = FuncGeneral.GetMiddle(frmSchieber[counter]);

                Point valvePos = new Point();
                valvePos.X = schieber.Left + xyValve.X;
                valvePos.Y = schieber.Top - xyValve.Y;

                frmSchieber[counter].Left = valvePos.X - xyFrm.X;
                frmSchieber[counter].Top  = valvePos.Y - xyFrm.Y * 2 - xyValve.Y + 35;

                if (frmSchieber[counter].Left < 0)
                {
                    frmSchieber[counter].Left = 0;
                }
                if (frmSchieber[counter].Top < 0)
                {
                    frmSchieber[counter].Top = valvePos.Y + xyValve.Y + 70;
                }
            }

            List <Helper.Scale> Behaelter = new List <Helper.Scale>();

            Behaelter.Add(this.ScaleT1);

            frmBehaelter = new FrmBehaelter[Behaelter.Count];

            counter = 0;
            foreach (Helper.Scale behaelter in Behaelter)
            {
                behaelter.Click              += new System.EventHandler(this.Behaelter);
                frmBehaelter[counter]         = new FrmBehaelter();
                frmBehaelter[counter].TopMost = true;
                string frmName = "FrmBehaelter" + behaelter.Name;
                frmBehaelter[counter].Name = frmName;
                string titelFormular = "Behaelter " + behaelter.Name.Substring(5, 2) + "." + behaelter.Name.Substring(7);
                frmBehaelter[counter].Text = titelFormular;
                frmMng.FormularAdd(frmBehaelter[counter], frmName);
                frmBehaelter[counter].BindDatas(FuncString.GetOnlyNumeric(behaelter.Name));
                Point xyValve = FuncGeneral.GetMiddle(behaelter);

                Point xyFrm = FuncGeneral.GetMiddle(frmBehaelter[counter]);

                Point valvePos = new Point();
                valvePos.X = behaelter.Left + xyValve.X;
                valvePos.Y = behaelter.Top - xyValve.Y;

                frmBehaelter[counter].Left = valvePos.X - xyFrm.X;
                frmBehaelter[counter].Top  = valvePos.Y - xyFrm.Y * 2 - xyValve.Y + 35;

                if (frmBehaelter[counter].Left < 0)
                {
                    frmBehaelter[counter].Left = 0;
                }
                if (frmBehaelter[counter].Top < 0)
                {
                    frmBehaelter[counter].Top = valvePos.Y + xyValve.Y + 70;
                }


                ToolTip toolTip1 = new ToolTip();
                toolTip1.AutoPopDelay = 0;
                toolTip1.ShowAlways   = true;
                toolTip1.UseAnimation = false;
                toolTip1.SetToolTip(this.BTN_Menu, "Menue");
                toolTip1.SetToolTip(this.BTN_Error, "Fehlermeldungen");
            }

            this.Left            = 0;
            this.Top             = 0;
            this.Width           = Screen.PrimaryScreen.Bounds.Width;
            this.Height          = Screen.PrimaryScreen.Bounds.Height;
            this.timer1.Interval = 100;
            this.timer1.Enabled  = true;
        }
Example #21
0
        //   2*3e
        void AnalyseInputG(int blacket)
        {
            if (blacket == 4)              //有括号的
            {
                if (IsOrder())
                {
//					PushToShow("进入命令程序");
                    Command cm   = new Command();
                    var     funs = funstring.GetFuncExpressTemp();
                    switch (funstring.GetFuncName())
                    {
                    case "plot":
                        string[]   paramers = funstring.GetParamersData();
                        FuncString funcs    = FindFuncInTDC(paramers[0]);
                        double     left     = 0;
                        double     right    = 1;
                        try {
                            left  = double.Parse(paramers[1]);
                            right = double.Parse(paramers[2]);
                        } catch {
                            if (tdc.CheckName(paramers[1]))
                            {
                                BlockData bd = (BlockData)tdc.GetData(paramers[1]).GetCalData();
                                if (bd != null)
                                {
                                    left  = bd.GetXStart();
                                    right = bd.GetXEnd();
                                }
                            }
                        }
                        if (funcs != null)
                        {
                            new Thread(new ThreadStart(() => cm.PlotFunc(funcs, 6, 1000, left, right))).Start();
//								new Thread(new ThreadStart(()=>cm.PlotFuncParallel(funcs, 6, 1000, -10, 10))).Start();
                        }
                        else
                        {
                            PushToShow("Wrong!");
                        }
                        break;

                    case "list":

                        #region 处理list
                        bool     needJudge = true;
                        DataType dt        = DataType.NONE;
                        switch (funs)
                        {
                        case "exp":
                            dt = DataType.EXP;
                            break;

                        case "matrix":
                            dt = DataType.MATRIX;
                            break;

                        case "block":
                            dt = DataType.BLOCK;
                            break;

                        case "func":
                            dt = DataType.FUNC;
                            break;

                        default:
                            needJudge = false;
                            break;
                        }
                        TempData td;
                        for (int i = 1; i < tdc.GetLength(); i++)
                        {
                            td = tdc.GetData(i);
                            bool show = false;
                            if (td != null)
                            {
                                CalData cd = td.GetCalData();
                                if (cd.CalType == dt)
                                {
                                    show = true;
                                }



                                if (!needJudge || show)
                                {
                                    PushToShow(td.ToString());
                                }
                            }
                        }
                        #endregion

                        break;

                    case "beep":
                        int times = 10;
                        int.TryParse(funs, out times);
                        if (times == 0)
                        {
                            times = 10;
                        }
                        for (int i = 0; i < times; i++)
                        {
                            PushToShow("倒计时" + (times - i - 1) + "s");
                            Console.Beep(1000 * 7, 500);
                            Console.Beep(500, 500);
                        }
                        Console.Beep(30000, 1000);

                        break;

                    case "matrix":
                        ConsoleCal.UIController uc = new ConsoleCal.UIController();
                        uc.Run();
                        break;

                    case "clc":

                        if (string.IsNullOrEmpty(funs))
                        {
                            tdc.RemoveAll();
                            PushToShow("已清空存储数据");
                        }
                        else
                        {
                            if (tdc.CheckName(funs))
                            {
                                tdc.Remove(tdc.FindPosition(funs));
                                PushToShow("clear " + funs);
                            }
                            else
                            {
                                PushToShow("fail to clear.Can't find " + funs);
                            }
                        }
                        break;

                    case "exit":
                        Environment.Exit(0);
                        break;

                    case "clear":
                        Console.Clear();
                        break;                                //----------------------这个GetFuncExpressTemp最多返回""不会返回null

                    case "help":
                        cm.Help(funstring.GetFuncExpressTemp());
                        break;
                    }
                    return;
                }
                if (tdc.CheckName(funstring.GetFuncName()))
                {
                    PushToShow("该函数存在数据中");

                    if (funstring.GetParamers() != null)
                    {
                        PushToShow("进入函数求值过程");
                        FuncString funs   = FindFuncInTDC(funstring.GetFuncName());
                        double     result = GetFuncResult(funs, new FuncString(InputData).GetParamersData());
                        PushToShow("结果:" + result);
                    }
                    else
                    {
                        PushToShow("没有输入参数");
                    }
                    return;
//					PushToShow("这是啥:" + tdc.GetData(funstring.GetFuncName()).GetValue().ToString());
                }
                {
                    var str = SimpleCal(InputData);
                    if (str == null)
                    {
                        PushToShow("没有此函数");
                    }
                    else
                    {
                        PushToShow(str);
                    }

                    return;
                }
            }


            if (blacket == 1)              //没有括号 Name即是计算的表达式
            {
                var Name = funstring.GetFuncName();
                CheckDataType(Name);
            }
        }
Example #22
0
        //f(x,y)=x+y+t

        /// <summary>
        /// 替换已知变量,fstr是一个字符串表达式:x+y 不是f=x+y ,
        /// 没有变量是会原串返回的
        /// 里面找未知数时会调用底层 CalString 的函数,里面已经自动排除sin,cos,avg等 函数名了
        /// </summary>
        /// <param name="fstr">含参表达式</param>
        /// <param name="ps">排除变量</param>
        /// <returns>返回FuncExpressTemp为替换后的string
        /// 或含有未知变量返回null</returns>
        public static string ReplaceParamers(string fstr, string[] ps = null)
        {
            string[]   strarr = null;
            FuncString fs     = new FuncString(fstr);

//			fs.SetFuncExpressTemp(fstr);
            fs.SetFuncExpress(fstr);            //为向下兼容不出错


            FuncCal fc = new FuncCal();

            if (ps == null)
            {
                strarr = fs.FindUnKnown();
            }
            else
            {
                strarr = fs.FindUnKnown(ps);
            }

            fs.SetParamers(strarr);            //为向下兼容不出错,不明觉厉
            if (strarr.Length != 0)
            {
                PushToShow("含有未知数 尝试替换已知变量");
            }

            string[] paramersdata = new string[strarr.Length];
            fc.SetFuncString(fs);
            for (int i = 0; i < strarr.Length; i++)
            {
                if (tdc.CheckName(strarr[i]))
                {
                    CalData datatemp = tdc.GetData(strarr[i]).GetCalData();

                    switch (datatemp.CalType)
                    {
                    case DataType.BLOCK:
                    {
                        PushToShow("Type not match!");
                    }
                    break;

                    case DataType.EXP:
                    {
                        ExpData ed = (ExpData)datatemp;
                        paramersdata[i] = ed.GetValueEx();
                        PushToShow("提取" + strarr[i] + "的值:" + paramersdata[i]);
                        break;
                    }

                    case DataType.MATRIX:
                    {
                        Matrix matrix = (Matrix)datatemp;
                        PushToShow(matrix.ToString());
                    }
                    break;
                    }

//					if (datatemp.CalType == DataType.EXP) {
//						ExpData ed = (ExpData)datatemp;
//						paramersdata[i] = ed.GetValueEx();
//						PushToShow("提取" + strarr[i] + "的值:" + paramersdata[i]);
//					}
//
//					else
//						PushToShow("Type not match!");
                    continue;
                }

                PushToShow("未发现变量" + strarr[i] + "还未定义其值\n退出");
                return(null);
            }
            if (paramersdata.Length != 0)
            {
                fc.DealFuncstring(paramersdata);
            }
            else
            {
                fs.SetFuncExpressTemp(fstr);
            }
            return(fc.GetFuncString().GetFuncExpressTemp());
        }
Example #23
0
 public override string ToString()
 {
     return(FuncString.ToString());
 }
Example #24
0
        private void btnStartQuery_Click(object sender, EventArgs e)
        {
            string cbx_name    = "";
            string txt_name    = "";
            string conjunction = "";
            bool   add_where   = true;
            bool   add_select  = true;

            this.m_SqlHelper.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.DeleteSQL);
            this.m_SqlHelperWhere.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.DeleteSQL);
            for (int i = 1; i <= 6; i++)
            {
                cbx_name = "CbxTabelle" + FuncString.FillForward(i.ToString(), "0", 2);
                ComboBox obj_cbx_tabelle = (ComboBox)FuncGeneral.GetControlByName(this, cbx_name);
                cbx_name = "CbxSpalte" + FuncString.FillForward(i.ToString(), "0", 2);
                ComboBox obj_cbx_column = (ComboBox)FuncGeneral.GetControlByName(this, cbx_name);
                txt_name = "txtFilter" + FuncString.FillForward(i.ToString(), "0", 2);
                TextBox obj_txt_filter = (TextBox)FuncGeneral.GetControlByName(this, txt_name);
                if (obj_cbx_tabelle.SelectedItem != null)
                {
                    string table = obj_cbx_tabelle.SelectedItem.ToString();
                    if (obj_cbx_column.SelectedItem != null)
                    {
                        if (add_select == true)
                        {
                            add_select = false;
                            this.m_SqlHelper.SQLBuilderHinzufuegen("SELECT TOP 100", SQLHelper.SQLBuilder.DeleteSQL);
                        }

                        string column = obj_cbx_column.SelectedItem.ToString();

                        string      suchen       = table + column;
                        TableStruct table_struct = (TableStruct)this.m_Datas[suchen];
                        string      display      = table_struct.Display;

                        this.m_SqlHelper.SQLBuilderHinzufuegen(table, SQLHelper.SQLBuilder.NoSpace);
                        this.m_SqlHelper.SQLBuilderHinzufuegen(".", SQLHelper.SQLBuilder.NoSpace);
                        this.m_SqlHelper.SQLBuilderHinzufuegen(column, SQLHelper.SQLBuilder.NoSpace);
                        if (display.Length > 0)
                        {
                            this.m_SqlHelper.SQLBuilderHinzufuegen(" AS");
                            this.m_SqlHelper.SQLBuilderHinzufuegen(display, SQLHelper.SQLBuilder.NoSpace);
                            this.m_SqlHelper.SQLBuilderHinzufuegen(",", SQLHelper.SQLBuilder.NoSpace);
                        }
                        else
                        {
                            this.m_SqlHelper.SQLBuilderHinzufuegen(",", SQLHelper.SQLBuilder.NoSpace);
                        }
                        if (obj_txt_filter.Text.Length > 0)
                        {
                            if (add_where == true)
                            {
                                add_where = false;
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen("WHERE", SQLHelper.SQLBuilder.DeleteSQL);
                            }

                            if (conjunction.Length > 0)
                            {
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen(conjunction);
                            }

                            if ((table_struct.Columntype == "char") || (table_struct.Columntype == "nchar"))
                            {
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen(table_struct.Table + "." + table_struct.Column);
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen("LIKE");
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen("N'%", SQLHelper.SQLBuilder.NoSpace);
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen(obj_txt_filter.Text, SQLHelper.SQLBuilder.NoSpace);
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen("%'", SQLHelper.SQLBuilder.NoSpace);
                            }
                            else
                            {
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen(table_struct.Table + "." + table_struct.Column);
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen("=");
                                this.m_SqlHelperWhere.SQLBuilderHinzufuegen(obj_txt_filter.Text, SQLHelper.SQLBuilder.NoSpace);
                            }
                            if (i >= 1 || i < 3)
                            {
                                conjunction = " AND";
                            }

                            if (i == 4)
                            {
                                conjunction = " " + this.cbxAndOr01.Text;
                            }
                            if (i == 5)
                            {
                                conjunction = " " + this.cbxAndOr02.Text;
                            }
                        }
                    }
                }
            }
            string sql            = "";
            string sql_where      = "";
            string sql_inner_join = "";

            sql = this.m_SqlHelper.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);
            sql = FuncGeneral.DeleteRight(sql, 1);
            this.m_SqlHelper.SQLBuilderHinzufuegen(sql, SQLHelper.SQLBuilder.DeleteSQL);


            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("FROM", SQLHelper.SQLBuilder.DeleteSQL);
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("MW_KENNDATEN_EINGABE");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("INNER JOIN");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("MW_ERGEBNIS");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("ON");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("MW_KENNDATEN_EINGABE.LINK = MW_ERGEBNIS.Link");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("INNER JOIN");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("MW_WERTE_MESSUNG");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("ON");
            this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("MW_KENNDATEN_EINGABE.LINK = MW_WERTE_MESSUNG.Link");


            sql            = this.m_SqlHelper.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);
            sql_inner_join = this.m_SqlHelperInnerJoin.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);
            sql_where      = this.m_SqlHelperWhere.SQLBuilderHinzufuegen("", SQLHelper.SQLBuilder.NoSpace);

            this.textBox1.Text = sql + sql_inner_join + sql_where;

            this.BindData(this.textBox1.Text, this.m_BS_Auswahl);
        }