Example #1
0
        public PQdsEvent(int id)
        {
            string localAppData = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}{Path.DirectorySeparatorChar}PQio{Path.DirectorySeparatorChar}DataBase.db";

            connectionstring = $"Data Source={localAppData}; Version=3; Foreign Keys=True; FailIfMissing=True";


            if (id == -1)
            {
                //This means the GUID needs to be generated

                m_Event = new PQio.Model.Event()
                {
                    GUID = System.Guid.NewGuid().ToString()
                };
            }
            else
            {
                using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider))
                {
                    GSF.Data.Model.TableOperations <PQio.Model.Event> evtTable = new GSF.Data.Model.TableOperations <PQio.Model.Event>(connection);
                    m_Event = evtTable.QueryRecordWhere("ID = {0}", id);
                }
            }


            InitializeComponent();
        }
Example #2
0
        public PQdsChannel(int eventId, int channelId)
        {
            string localAppData = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}{Path.DirectorySeparatorChar}PQio{Path.DirectorySeparatorChar}DataBase.db";

            connectionstring = $"Data Source={localAppData}; Version=3; Foreign Keys=True; FailIfMissing=True";

            using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider))
            {
                this.m_channel = (new GSF.Data.Model.TableOperations <PQio.Model.Channel>(connection)).QueryRecordWhere("ID = {0}", channelId);
                this.m_evt     = (new GSF.Data.Model.TableOperations <PQio.Model.Event>(connection)).QueryRecordWhere("ID = {0}", eventId);
            }
            this.alreadySavedFlag = false;

            InitializeComponent();
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider))
            {
                GSF.Data.Model.TableOperations <PQio.Model.Event> evtTable = new GSF.Data.Model.TableOperations <PQio.Model.Event>(connection);
                PQio.Model.Event evt = evtTable.QueryRecordWhere("ID =  {0}", m_Event.ID);

                evt.Name      = faultIDTxtBox.Text;
                evt.EventTime = timeTxtBox.Value;

                if (peakITxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(peakITxtBox.Text) == 0))
                        {
                            evt.PeakCurrent = Convert.ToDouble(peakITxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Peak Current has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }

                if (peakVTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(peakVTxtBox.Text) == 0))
                        {
                            evt.PeakVoltage = Convert.ToDouble(peakVTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Peak Voltage has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }

                if (preITxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(preITxtBox.Text) == 0))
                        {
                            evt.PreEventCurrent = Convert.ToDouble(preITxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Pre-Event Current has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }

                if (preVTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(preVTxtBox.Text) == 0))
                        {
                            evt.PreEventVoltage = Convert.ToDouble(preVTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Pre-Event Voltage has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }

                if (I2tTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(I2tTxtBox.Text) == 0))
                        {
                            evt.FaultI2T = Convert.ToDouble(I2tTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Fault I2(t) has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }


                if (maxVaTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(maxVaTxtBox.Text) == 0))
                        {
                            evt.MaxVA = Convert.ToDouble(maxVaTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase A Voltage Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }
                if (maxVbTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(maxVbTxtBox.Text) == 0))
                        {
                            evt.MaxVB = Convert.ToDouble(maxVbTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase B Voltage Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }
                if (maxVcTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(maxVcTxtBox.Text) == 0))
                        {
                            evt.MaxVC = Convert.ToDouble(maxVcTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase C Voltage Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }

                if (minVaTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(minVaTxtBox.Text) == 0))
                        {
                            evt.MinVA = Convert.ToDouble(minVaTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase A Voltage Minimum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }
                if (minVbTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(minVbTxtBox.Text) == 0))
                        {
                            evt.MinVB = Convert.ToDouble(minVbTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase B Voltage Minimum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }
                if (minVcTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(minVcTxtBox.Text) == 0))
                        {
                            evt.MinVC = Convert.ToDouble(minVcTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase C Voltage Minimum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }

                if (maxIaTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(maxIaTxtBox.Text) == 0))
                        {
                            evt.MaxIA = Convert.ToDouble(maxIaTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase A Current Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }
                if (maxIbTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(maxIbTxtBox.Text) == 0))
                        {
                            evt.MaxIB = Convert.ToDouble(maxIbTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase B Current Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }
                if (maxIcTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(maxIcTxtBox.Text) == 0))
                        {
                            evt.MaxIC = Convert.ToDouble(maxIcTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Phase C Current Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }


                if (durationTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(durationTxtBox.Text) == 0))
                        {
                            evt.Duration = Convert.ToDouble(durationTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Event duration has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }



                if (distanceTxtBox.Text != "")
                {
                    try
                    {
                        if (!(Convert.ToDouble(distanceTxtBox.Text) == 0))
                        {
                            evt.DistanceToFault = Convert.ToDouble(distanceTxtBox.Text);
                        }
                    }
                    catch { MessageBox.Show("Distance to Fault has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
                }



                // Update Data from Comboboxes
                if ((string)FltTypeCombo.SelectedItem == "")
                {
                    evt.FaultType = null;
                }
                else
                {
                    evt.FaultType = Model.FaultType.ToValue((string)FltTypeCombo.SelectedItem);
                }

                if ((string)evtTypeCombo.SelectedItem == "")
                {
                    evt.EventType = null;
                }
                else
                {
                    evt.EventType = Model.EventType.ToValue((string)evtTypeCombo.SelectedItem);
                }


                if ((string)evtCauseCombo.SelectedItem == "")
                {
                    evt.FaultCause = null;
                }
                else
                {
                    evt.FaultCause = Model.FaultCause.ToValue((string)evtCauseCombo.SelectedItem);
                }

                evtTable.AddNewOrUpdateRecord(evt);
            }
            this.Close();
        }