コード例 #1
0
        public new AutoWeldHistory Save()
        {
            var db = new DataProcess();
            if (Id == null)
            {
                Id = db.saveAutoWeldHistory(this);

                foreach (var sig in Signals)
                {
                    sig.Delta = 0;

                    var interval = sig.Timestamp - Signals[0].Timestamp;
                    var delta = (int)interval.TotalMilliseconds; // Ignore time less tham 1ms.
                    sig.Delta = delta;
                    sig.History = this;
                    sig.Save();
                }
            }
            else
            {
                db.updateAutoWeldHistory(this);
            }

            return this;
        }
コード例 #2
0
        private void UpdateUI(bool autoWeld = false)
        {
            historiesList.Items.Clear();
            var db = new DataProcess();

            if (autoWeld)
            {
                var list = db.AutoWeldHistoryList();
                if (Histories == null)
                {
                    Histories = new List <History>();
                }
                else
                {
                    Histories.Clear();
                }
                list.ForEach((item) => {
                    Histories.Add(item);
                });
                Text = "控制记录";
            }
            else
            {
                Histories = db.HistoryList();
                Text      = "焊接历史";
            }
            Histories.ForEach((history) => {
                var name        = history.Name.Trim();
                var defaultName = autoWeld ? "(未命名控制记录)" : "(未命名焊接记录)";
                historiesList.Items.Add(name.Length == 0 ? defaultName : name);
            });
            ShowHistory();
        }
コード例 #3
0
        public static new AutoWeldHistory Find(long history_id)
        {
            var db      = new DataProcess();
            var history = db.autoWeldHistoryOfId(history_id);

            return(history);
        }
コード例 #4
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var input  = new InputBox("请输入一个名字:", "新增操作者", "");
            var result = input.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var  name       = input.InputResult.Trim();
                bool nameExists = false;
                foreach (string n in OperatorsListBox.Items)
                {
                    if (n == name)
                    {
                        nameExists = true;
                        break;
                    }
                }

                if (!nameExists)
                {
                    var db = new DataProcess();
                    db.addOperator(name);
                    OperatorsListBox.Items.Add(name);
                }
                else
                {
                    MessageBox.Show(this, "名字已存在,请勿重复添加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }
コード例 #5
0
        private void SaveAutoWeldHistory(bool interupted = false)
        {
            //SaveRecordButton.Enabled = false; // Disable it.
            var dict = new Dictionary <string, object>();

            dict["task_name"]        = TaskNameTextBox.Text.Trim();
            dict["gangtao_type"]     = GangTaoTypeComboBox.Text.Trim();
            dict["welding_item"]     = WeldingItemComboBox.Text.Trim();
            dict["welding_current"]  = WeldingCurrentTextBox.Text.Trim();
            dict["ar_flow"]          = ArGasFlowTextBox.Text.Trim();
            dict["room_temperature"] = RoomTempTextBox.Text.Trim();
            var op = OperatorNameComboBox.Text.Trim();

            dict["operator"]   = op;
            dict["history_id"] = History.Id;

            if (op != "") // Valid op.
            {
                var db  = new DataProcess();
                var ops = db.OperatorList();
                if (!ops.Contains(op))
                {
                    db.addOperator(op); // Save operator
                }
            }

            // If all OK, close.
            DateTime dt = DateTime.Now;

            dict["created_at"] = dt;
            try
            {
                dict["name"]       = "";
                dict["interupted"] = false;
                var history = new AutoWeldHistory(dict);
                history.Signals = signalCache;
                // Decide interupted by signal count.
                // We can decide interupt by pass in argument.
                // Fixme: Which is better?
                if (history.Template.Signals.Count() == signalCache.Count())
                {
                    history.Interupted = false;
                }
                else
                {
#if DEBUG
                    Console.WriteLine("Control signals: {0}, received signals: {1}", history.Template.Signals.Count(), signalCache.Count());
#endif
                    history.Interupted = true;
                }
                history.Save();
            }
            catch (Exception excp)
            {
#if DEBUG
                Console.WriteLine(excp.StackTrace);
#endif
                throw;
            }
        }
コード例 #6
0
        public new AutoWeldHistory Save()
        {
            var db = new DataProcess();

            if (Id == null)
            {
                Id = db.saveAutoWeldHistory(this);

                foreach (var sig in Signals)
                {
                    sig.Delta = 0;

                    var interval = sig.Timestamp - Signals[0].Timestamp;
                    var delta    = (int)interval.TotalMilliseconds; // Ignore time less tham 1ms.
                    sig.Delta   = delta;
                    sig.History = this;
                    sig.Save();
                }
            }
            else
            {
                db.updateAutoWeldHistory(this);
            }

            return(this);
        }
コード例 #7
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var input = new InputBox("请输入一个名字:", "新增操作者", "");
            var result = input.ShowDialog(this);
            if (result == DialogResult.OK)
            {
                var name = input.InputResult.Trim();
                bool nameExists = false;
                foreach (string n in OperatorsListBox.Items) {
                    if (n == name)
                    {
                        nameExists = true;
                        break;
                    }
                }

                if (!nameExists)
                {
                    var db = new DataProcess();
                    db.addOperator(name);
                    OperatorsListBox.Items.Add(name);
                }
                else
                {
                    MessageBox.Show(this, "名字已存在,请勿重复添加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }
コード例 #8
0
ファイル: Template.cs プロジェクト: venj/Welding-Recorder
 public void Delete()
 {
     var db = new DataProcess();
     if (Id != null)
     {
         db.deleteTemplate(this);
     }
 }
コード例 #9
0
        public void Delete()
        {
            var db = new DataProcess();

            if (Id != null)
            {
                db.deleteSignal(this);
            }
        }
コード例 #10
0
 private void LoadOperatorsList()
 {
     OperatorsListBox.Items.Clear();
     var db = new DataProcess();
     var operatorList = db.OperatorList();
     operatorList.ForEach((item) => {
         OperatorsListBox.Items.Add(item);
     });
 }
コード例 #11
0
        public void Delete()
        {
            var db = new DataProcess();

            if (Id != null)
            {
                db.deleteTemplate(this);
            }
        }
コード例 #12
0
 private void DeleteButton_Click(object sender, EventArgs e)
 {
     var name = OperatorsListBox.SelectedItem;
     if (name != null)
     {
         var db = new DataProcess();
         db.deleteOperator(name.ToString());
         LoadOperatorsList();
     }
 }
コード例 #13
0
        private void LoadOperatorsList()
        {
            OperatorsListBox.Items.Clear();
            var db           = new DataProcess();
            var operatorList = db.OperatorList();

            operatorList.ForEach((item) => {
                OperatorsListBox.Items.Add(item);
            });
        }
コード例 #14
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            var name = OperatorsListBox.SelectedItem;

            if (name != null)
            {
                var db = new DataProcess();
                db.deleteOperator(name.ToString());
                LoadOperatorsList();
            }
        }
コード例 #15
0
 private void PopulateData()
 {
     var db = new DataProcess();
     var templates = db.TemplateList();
     var sortedTemplates = from tpl in templates orderby tpl.Item, int.Parse(tpl.Type) select tpl;
     SortedTemplates = sortedTemplates.ToList();
     TemplatesListBox.Items.Clear();
     SortedTemplates.ForEach((template) => {
         TemplatesListBox.Items.Add(template.ShortDescription());
     });
 }
コード例 #16
0
        private void PopulateData()
        {
            var db = new DataProcess();
            var templates = db.TemplateList();
            var sortedTemplates = from tpl in templates orderby tpl.Item, int.Parse(tpl.Type) select tpl;

            SortedTemplates = sortedTemplates.ToList();
            TemplatesListBox.Items.Clear();
            SortedTemplates.ForEach((template) => {
                TemplatesListBox.Items.Add(template.ShortDescription());
            });
        }
コード例 #17
0
        private void PopulateData()
        {
            var db = new DataProcess();
            var templates = db.TemplateList();
            var sortedTemplates = from tpl in templates orderby tpl.Item, int.Parse(tpl.Type) select tpl;

            SortedTemplates = sortedTemplates.ToList();
            SortedTemplates.ForEach((tpl) =>
            {
                TemplateListView.Items.Add(tpl.ToListItem());
            });
            TemplateListLabel.Text = string.Format("焊接模板(共{0}条)", SortedTemplates.Count());
        }
コード例 #18
0
ファイル: History.cs プロジェクト: imvenj/Welding-Recorder
        public static History LatestHistory()
        {
            var db              = new DataProcess();
            var histories       = db.HistoryList();
            var sortedHistories = from h in histories where true orderby h.CreatedAt descending select h;

            if (sortedHistories.Count() == 0)
            {
                return(null);
            }
            else
            {
                return(sortedHistories.First());
            }
        }
コード例 #19
0
        private void SaveSignalDataAndClose()
        {
            var dict = new Dictionary <string, object>();

            dict["task_name"]        = TaskNameTextBox.Text.Trim();
            dict["gangtao_type"]     = GangTaoTypeComboBox.Text.Trim();
            dict["welding_item"]     = WeldingItemComboBox.Text.Trim();
            dict["welding_current"]  = WeldingCurrentTextBox.Text.Trim();
            dict["ar_flow"]          = ArGasFlowTextBox.Text.Trim();
            dict["room_temperature"] = RoomTempTextBox.Text.Trim();
            var op = OperatorNameComboBox.Text.Trim();

            dict["operator"] = op;

            if (op != "") // Valid op.
            {
                var db  = new DataProcess();
                var ops = db.OperatorList();
                if (!ops.Contains(op))
                {
                    db.addOperator(op); // Save operator
                }
            }

            // If all OK, close.
            DateTime dt = DateTime.Now;

            dict["created_at"] = dt;
            try
            {
                //Fixme: Generate a meaningful name.
                dict["name"] = "";
                var history = new History(dict);
                history.Signals = signalCache;
                history.Save();
                Console.WriteLine("Signal history saved.");
            }
            catch (Exception excp)
            {
                //TODO: Save Result and crash.
#if DEBUG
                Console.WriteLine(excp.StackTrace);
#endif
                throw;
            }

            DialogResult = DialogResult.OK;
        }
コード例 #20
0
        // Load static data from database to UI.
        private void loadWeldingDataLists()
        {
            var db          = new DataProcess();
            var gangtaoList = db.GangTaoList();

            gangtaoList.ForEach((item) => {
                GangTaoTypeComboBox.Items.Add(item);
            });
            var operatorList = db.OperatorList();

            operatorList.ForEach((item) => {
                OperatorNameComboBox.Items.Add(item);
            });
            var weldingItemList = db.WeldingItemList();

            weldingItemList.ForEach((item) => {
                WeldingItemComboBox.Items.Add(item);
            });
        }
コード例 #21
0
ファイル: Template.cs プロジェクト: venj/Welding-Recorder
 public Template Save()
 {
     var db = new DataProcess();
     if (History == null)
     {
         throw new TemplateException("Template should have a history reference.");
     }
     else
     {
         if (Id == null)
         {
             Id = db.saveTemplate(this);
         }
         else
         {
             db.updateTemplate(this);
         }
         return this;
     }
 }
コード例 #22
0
        private void LoadWeldingDataLists()
        {
            var db          = new DataProcess();
            var gangtaoList = db.GangTaoList();

            GangTaoTypeComboBox.Items.Clear();
            gangtaoList.ForEach((item) => {
                GangTaoTypeComboBox.Items.Add(item);
            });
            var weldingItemList = db.WeldingItemList();

            WeldingItemComboBox.Items.Clear();
            weldingItemList.ForEach((item) => {
                WeldingItemComboBox.Items.Add(item);
            });
            histories = db.HistoryList();
            HistoriesListBox.Items.Clear();
            histories.ForEach((item) => {
                HistoriesListBox.Items.Add(item.ShortDescription());
            });
        }
コード例 #23
0
        public Signal Save()
        {
            var db = new DataProcess();

            if (History == null)
            {
                throw new SignalException("Signal should be associated to history.");
            }
            else
            {
                if (this.Id == null)
                {
                    Id = db.saveSignal(this);
                }
                else
                {
                    db.updateSignal(this);
                }
                return(this);
            }
        }
コード例 #24
0
        public Template Save()
        {
            var db = new DataProcess();

            if (History == null)
            {
                throw new TemplateException("Template should have a history reference.");
            }
            else
            {
                if (Id == null)
                {
                    Id = db.saveTemplate(this);
                }
                else
                {
                    db.updateTemplate(this);
                }
                return(this);
            }
        }
コード例 #25
0
        // Load static data from database to UI.
        private void loadWeldingDataLists()
        {
#if DEBUG
            sendMessageInfoLabel.Visible = true;
            sendMessageButton.Visible    = true;
#else
            sendMessageInfoLabel.Visible = false;
            sendMessageButton.Visible    = false;
#endif
            var db          = new DataProcess();
            var gangtaoList = db.GangTaoList();
            gangtaoList.ForEach((item) => {
                GangTaoTypeComboBox.Items.Add(item);
            });
            var operatorList = db.OperatorList();
            operatorList.ForEach((item) => {
                OperatorNameComboBox.Items.Add(item);
            });
            var weldingItemList = db.WeldingItemList();
            weldingItemList.ForEach((item) => {
                WeldingItemComboBox.Items.Add(item);
            });
        }
コード例 #26
0
ファイル: History.cs プロジェクト: venj/Welding-Recorder
 public virtual void Delete()
 {
     var db = new DataProcess();
     db.deleteHistory(this);
 }
コード例 #27
0
ファイル: RecordForm.cs プロジェクト: venj/Welding-Recorder
 // Load static data from database to UI.
 private void loadWeldingDataLists()
 {
     #if DEBUG
     sendMessageInfoLabel.Visible = true;
     sendMessageButton.Visible = true;
     #else
     sendMessageInfoLabel.Visible = false;
     sendMessageButton.Visible = false;
     #endif
     var db = new DataProcess();
     var gangtaoList = db.GangTaoList();
     gangtaoList.ForEach((item) => {
         GangTaoTypeComboBox.Items.Add(item);
     });
     var operatorList = db.OperatorList();
     operatorList.ForEach((item) => {
         OperatorNameComboBox.Items.Add(item);
     });
     var weldingItemList = db.WeldingItemList();
     weldingItemList.ForEach((item) => {
         WeldingItemComboBox.Items.Add(item);
     });
 }
コード例 #28
0
ファイル: RecordForm.cs プロジェクト: venj/Welding-Recorder
        private void SaveSignalDataAndClose()
        {
            var dict = new Dictionary<string, object>();
            dict["task_name"] = TaskNameTextBox.Text.Trim();
            dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim();
            dict["welding_item"] = WeldingItemComboBox.Text.Trim();
            dict["welding_current"] = WeldingCurrentTextBox.Text.Trim();
            dict["ar_flow"] = ArGasFlowTextBox.Text.Trim();
            dict["room_temperature"] = RoomTempTextBox.Text.Trim();
            var op = OperatorNameComboBox.Text.Trim();
            dict["operator"] = op;

            if (op != "") // Valid op.
            {
                var db = new DataProcess();
                var ops = db.OperatorList();
                if (!ops.Contains(op))
                {
                    db.addOperator(op); // Save operator
                }
            }

            // If all OK, close.
            DateTime dt = DateTime.Now;
            dict["created_at"] = dt;
            try
            {
                //Fixme: Generate a meaningful name.
                dict["name"] = "";
                var history = new History(dict);
                history.Signals = signalCache;
                history.Save();
                Console.WriteLine("Signal history saved.");
            }
            catch (Exception excp)
            {
                //TODO: Save Result and crash.
            #if DEBUG
                Console.WriteLine(excp.StackTrace);
            #endif
                throw;
            }

            DialogResult = DialogResult.OK;
        }
コード例 #29
0
        private void SaveAutoWeldHistory(bool interupted = false)
        {
            //SaveRecordButton.Enabled = false; // Disable it.
            var dict = new Dictionary<string, object>();
            dict["task_name"] = TaskNameTextBox.Text.Trim();
            dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim();
            dict["welding_item"] = WeldingItemComboBox.Text.Trim();
            dict["welding_current"] = WeldingCurrentTextBox.Text.Trim();
            dict["ar_flow"] = ArGasFlowTextBox.Text.Trim();
            dict["room_temperature"] = RoomTempTextBox.Text.Trim();
            var op = OperatorNameComboBox.Text.Trim();
            dict["operator"] = op;
            dict["history_id"] = History.Id;

            if (op != "") // Valid op.
            {
                var db = new DataProcess();
                var ops = db.OperatorList();
                if (!ops.Contains(op))
                {
                    db.addOperator(op); // Save operator
                }
            }

            // If all OK, close.
            DateTime dt = DateTime.Now;
            dict["created_at"] = dt;
            try
            {
                dict["name"] = "";
                dict["interupted"] = false;
                var history = new AutoWeldHistory(dict);
                history.Signals = signalCache;
                // Decide interupted by signal count.
                // We can decide interupt by pass in argument.
                // Fixme: Which is better?
                if (history.Template.Signals.Count() == signalCache.Count())
                {
                    history.Interupted = false;
                }
                else
                {
            #if DEBUG
                    Console.WriteLine("Control signals: {0}, received signals: {1}", history.Template.Signals.Count(), signalCache.Count());
            #endif
                    history.Interupted = true;
                }
                history.Save();
            }
            catch (Exception excp)
            {
            #if DEBUG
                Console.WriteLine(excp.StackTrace);
            #endif
                throw;
            }
        }
コード例 #30
0
ファイル: History.cs プロジェクト: imvenj/Welding-Recorder
        public virtual void Delete()
        {
            var db = new DataProcess();

            db.deleteHistory(this);
        }
コード例 #31
0
 public static new AutoWeldHistory Find(long history_id)
 {
     var db = new DataProcess();
     var history = db.autoWeldHistoryOfId(history_id);
     return history;
 }
コード例 #32
0
 public override void Delete()
 {
     var db = new DataProcess();
     db.deleteAutoWeldHistory(this);
 }
コード例 #33
0
 // Load static data from database to UI.
 private void loadWeldingDataLists()
 {
     var db = new DataProcess();
     var gangtaoList = db.GangTaoList();
     gangtaoList.ForEach((item) => {
         GangTaoTypeComboBox.Items.Add(item);
     });
     var operatorList = db.OperatorList();
     operatorList.ForEach((item) => {
         OperatorNameComboBox.Items.Add(item);
     });
     var weldingItemList = db.WeldingItemList();
     weldingItemList.ForEach((item) => {
         WeldingItemComboBox.Items.Add(item);
     });
 }
コード例 #34
0
ファイル: History.cs プロジェクト: venj/Welding-Recorder
 public static History LatestHistory()
 {
     var db = new DataProcess();
     var histories = db.HistoryList();
     var sortedHistories = from h in histories where true orderby h.CreatedAt descending select h;
     if (sortedHistories.Count() == 0)
     {
         return null;
     }
     else
     {
         return sortedHistories.First();
     }
 }
コード例 #35
0
 private void UpdateUI(bool autoWeld = false)
 {
     historiesList.Items.Clear();
     var db = new DataProcess();
     if (autoWeld)
     {
         var list = db.AutoWeldHistoryList();
         if (Histories == null)
         {
             Histories = new List<History>();
         }
         else
         {
             Histories.Clear();
         }
         list.ForEach((item) => {
             Histories.Add(item);
         });
         Text = "控制记录";
     }
     else
     {
         Histories = db.HistoryList();
         Text = "焊接历史";
     }
     Histories.ForEach((history) => {
         var name = history.Name.Trim();
         var defaultName = autoWeld ? "(未命名控制记录)" : "(未命名焊接记录)";
         historiesList.Items.Add(name.Length == 0 ? defaultName : name);
     });
     ShowHistory();
 }
コード例 #36
0
ファイル: Signal.cs プロジェクト: venj/Welding-Recorder
 public void Delete()
 {
     var db = new DataProcess();
     if (Id != null)
     {
         db.deleteSignal(this);
     }
 }
コード例 #37
0
        public override void Delete()
        {
            var db = new DataProcess();

            db.deleteAutoWeldHistory(this);
        }
コード例 #38
0
 private void PopulateData()
 {
     var db = new DataProcess();
     var templates = db.TemplateList();
     var sortedTemplates = from tpl in templates orderby tpl.Item, int.Parse(tpl.Type) select tpl;
     SortedTemplates = sortedTemplates.ToList();
     SortedTemplates.ForEach((tpl) =>
     {
         TemplateListView.Items.Add(tpl.ToListItem());
     });
     TemplateListLabel.Text = string.Format("焊接模板(共{0}条)", SortedTemplates.Count());
 }
コード例 #39
0
ファイル: Signal.cs プロジェクト: venj/Welding-Recorder
 public Signal Save()
 {
     var db = new DataProcess();
     if (History == null)
     {
         throw new SignalException("Signal should be associated to history.");
     }
     else
     {
         if (this.Id == null)
         {
             Id = db.saveSignal(this);
         }
         else
         {
             db.updateSignal(this);
         }
         return this;
     }
 }
コード例 #40
0
 private void LoadWeldingDataLists()
 {
     var db = new DataProcess();
     var gangtaoList = db.GangTaoList();
     GangTaoTypeComboBox.Items.Clear();
     gangtaoList.ForEach((item) => {
         GangTaoTypeComboBox.Items.Add(item);
     });
     var weldingItemList = db.WeldingItemList();
     WeldingItemComboBox.Items.Clear();
     weldingItemList.ForEach((item) => {
         WeldingItemComboBox.Items.Add(item);
     });
     histories = db.HistoryList();
     HistoriesListBox.Items.Clear();
     histories.ForEach((item) => {
         HistoriesListBox.Items.Add(item.ShortDescription());
     });
 }