private void Connections_form_Load(object sender, EventArgs e)
        {
            label5.Text = "";
            label6.Text = "";
            if (File.Exists("settings.xml"))
            {
                XmlSerializer XmlSerializer1 = new XmlSerializer(typeof(Settings));
                TextReader reader1 = new StreamReader("settings.xml");
                Settings1 = (Settings)XmlSerializer1.Deserialize(reader1);
                reader1.Dispose();

                this.textBox1.Text = Settings1.SQLConnectionString;
                this.radioButton1.Checked = (Settings1.SQLWindowsAuthorization) ? true : false;
                this.radioButton2.Checked = (Settings1.SQLWindowsAuthorization) ? false : true;
                this.textBox5.Text = Settings1.SQLLogin;
                this.textBox6.Text = Settings1.SQLPassword;
                this.checkBox1.Checked = Settings1.SQLAllowWriteToSFIDatabases;

                this.textBox3.Text = Settings1.OPCConnectionString;
                this.textBox4.Text = Settings1.OPCCounterName;
                this.textBox2.Text = Settings1.OPCSpeedName;

            }
        }
예제 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            #region Indication
            toolStripStatusLabel1.Text = "REAL TIME";
#if !real_time
            toolStripStatusLabel1.ForeColor = Color.Red;
#endif
#if real_time
            toolStripStatusLabel1.ForeColor = Color.Green;
#endif

            toolStripStatusLabel2.Text = "OPC Enagaged";
#if bypass_opc_init
            toolStripStatusLabel2.ForeColor = Color.Red;
#endif
#if !bypass_opc_init
            toolStripStatusLabel2.ForeColor = Color.Green;
#endif
            #endregion

#if hide_future_functional
            tableLayoutPanel9.Visible = false;
            button5.Visible = false;
#endif

            label9.Text = sql_obj.GetWCName();

            //set up components
            #region TimeLine
            timeLine1.LeftMargin = 20;
            timeLine1.RightMargin = 1;
            //timeLine1.TimeLineHeight = 30;
            #endregion
            #region GraphicLine
            graphicLine1.LeftMargin = 0;
            graphicLine1.RightMargin = 1;
            graphicLine1.SetpointSpeed = 40;
            graphicLine1.History.Filename = "graphicLine1Data.xml";
            GLGlobalObject.Discontinuity = graphicLine1.Discontinuity;
            GLGlobalObject.GraphicLineDataArr = graphicLine1.History.LoadFromXML();
            //MessageBox.Show(GLGlobalObject.GraphicLineDataArr[0].datetime.ToString());
            //MessageBox.Show(GLGlobalObject.GraphicLineDataArr[1].datetime.ToString());
            #endregion


            label5.Text = sql_obj.GetCurrentStatusAsString();

            Color temp_color_000 = sql_obj.GetCurrentStatusColor();
            label5.BackColor = temp_color_000;
            if ((((int)temp_color_000.R + (int)temp_color_000.G + (int)temp_color_000.B)) / 3 >= 170)
                label5.ForeColor = Color.Black;
            else
                label5.ForeColor = Color.White;

            //history browser
            tableLayoutPanel2.RowStyles[2].Height = 0;
            try
            {
                if (File.Exists("settings.xml"))
                {
                    XmlSerializer XmlSerializer1 = new XmlSerializer(typeof(Settings));
                    TextReader reader1 = new StreamReader("settings.xml");
                    Settings1 = (Settings)XmlSerializer1.Deserialize(reader1);
                    reader1.Dispose();

                    showHistoryBrowserToolStripMenuItem.Checked = Settings1.GENERALShowHistoryBrowser;
                    tableLayoutPanel2.RowStyles[2].Height = (Settings1.GENERALShowHistoryBrowser) ? 35 : 0;
                }
            }
            catch
            { }

            LabelsCenterPositioning(groupBox1);
            LabelsCenterPositioning(groupBox2);
            LabelsCenterPositioning(groupBox3);

            this.Text += " v1.1.8";

            //OPC
#if !bypass_opc_init
            //opc_obj.CurrentCounterOfMaterial = sql_obj.GetProductionCounter();
            opc_obj.CurrentCounterOfMaterial = sql_obj.GetProductionCounterFromOrder();
            opc_obj.AskAllValues();
            label4.Text = opc_obj.CurrentCounterOfMaterial.ToString();
            opc_obj.lockCount = (sql_obj.GetCurrentStatusAsInt() == 0) ? false : true;
#endif
            
            Tick1sec.Interval = 1000;
            Tick1sec.Tick += Tic1sec_Tick;
            Tick1sec.Start();

            Tick5sec.Interval = 5000;
            Tick5sec.Tick += Tick5sec_Tick;
            Tick5sec.Start();

            Tick60sec.Interval = 60000;
            Tick60sec.Tick += Tick60sec_Tick;
            Tick60sec.Start();

            TickGLDiscontinuity.Interval = graphicLine1.Discontinuity * 1000;
            TickGLDiscontinuity.Tick += TickGLDiscontinuity_Tick;
            TickGLDiscontinuity.Start();

            Tick50msec.Interval = 50;
            Tick50msec.Tick += Tick50msec_Tick;
            Tick50msec.Start();


            #region Check shift

            if (get_CURR().Hour >= 8 && get_CURR().Hour < 20)
                radioButton1.Checked = true;
            else
                radioButton2.Checked = true;
            #endregion
            #region Datetime picker current shift (day/night) and run GlobalPresenter() - value change event
#if !real_time
            DateTime BStartTime = fixed_CURR;
            dateTimePicker1.Value = BStartTime;
#endif
#if real_time
            //if (System.DateTime.Now.Hour < 9)
            //    dateTimePicker1.Value = System.DateTime.Now - TimeSpan.FromDays(1);
            //if (System.DateTime.Now.Hour >= 8)
            dateTimePicker1.Value = System.DateTime.Now;
#endif
            #endregion

            previous_time = get_CURR();
            //toolStripStatusLabel4.Text = dateTimePicker1.Value.ToString();

            DrawTotalScore();

            metersPerShift = LoadFromDumpData();
        }