示例#1
0
 public static GameObject setEnemy()
 {
     return(InitialMethod.getGameObjectByPrefab("crystal_maiden_econ enemy"));
 }
示例#2
0
 private void SettingView_Load(object sender, EventArgs e)
 {
     gateWay = InitialMethod.GateWayLoad();
     taiwan_DistricsSetting = InitialMethod.Taiwan_DistricsLoad();
     #region 產生電錶填入欄位
     for (int i = 0; i < 30; i++) //toggleSwitch = 啟動, toggleSwitch2 = 總錶
     {
         DevExpress.XtraEditors.ToggleSwitch toggleSwitch = new DevExpress.XtraEditors.ToggleSwitch
         {
             Name     = $"toggleSwitch{ 1 + i * 2}",
             Location = new Point(10, 8 + 25 * i),
             Size     = new Size(48, 19),
             IsOn     = false
         };
         toggleSwitch.Properties.ShowText = false;
         xtraScrollableControl1.Controls.Add(toggleSwitch);
         DevExpress.XtraEditors.ToggleSwitch toggleSwitch2 = new DevExpress.XtraEditors.ToggleSwitch
         {
             Name     = $"toggleSwitch{ 2 + i * 2}",
             Location = new Point(600, 8 + 25 * i),
             Size     = new Size(48, 19),
             IsOn     = false
         };
         toggleSwitch2.Properties.ShowText = false;
         xtraScrollableControl1.Controls.Add(toggleSwitch2);
         toggleSwitches.Add(toggleSwitch);
         toggleSwitches2.Add(toggleSwitch2);
     }
     for (int i = 0; i < 30; i++) //設備名稱
     {
         DevExpress.XtraEditors.TextEdit textEdit = new DevExpress.XtraEditors.TextEdit
         {
             Name     = $"textEdit{1 + i}",
             Location = new Point(65, 6 + 25 * i),
             Size     = new Size(105, 22)
         };
         xtraScrollableControl1.Controls.Add(textEdit);
         textEdits.Add(textEdit);
     }
     for (int i = 0; i < 30; i++) //設備ID
     {
         DevExpress.XtraEditors.SpinEdit spinEdit = new DevExpress.XtraEditors.SpinEdit
         {
             Name     = $"spinEdit{1 + i}",
             Location = new Point(185, 6 + 25 * i),
             Size     = new Size(55, 20)
         };
         spinEdit.Properties.MaxValue     = 254;
         spinEdit.Properties.MinValue     = 1;
         spinEdit.Properties.IsFloatValue = false;
         xtraScrollableControl1.Controls.Add(spinEdit);
         spinEdits.Add(spinEdit);
     }
     for (int i = 0; i < 30; i++) //電錶廠牌
     {
         DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit = new DevExpress.XtraEditors.ComboBoxEdit
         {
             Name     = $"comboBoxEdit{1 + i * 4}",
             Location = new Point(250, 6 + 25 * i),
             Size     = new Size(105, 22),
             Tag      = i
         };
         comboBoxEdit.SelectedIndexChanged += ComboBoxEdit1_SelectedIndexChanged;
         comboBoxEdit.Properties.Items.Add("PA310");
         comboBoxEdit.Properties.Items.Add("HC6600");
         comboBoxEdit.Properties.Items.Add("CPM6");
         comboBoxEdit.Properties.Items.Add("PA60");
         comboBoxEdit.Properties.Items.Add("ABBM2M");
         comboBoxEdit.Properties.AllowFocused    = false;
         comboBoxEdit.Properties.AllowMouseWheel = false;
         comboBoxEdit.Properties.TextEditStyle   = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
         xtraScrollableControl1.Controls.Add(comboBoxEdit);
         comboBoxEdits.Add(comboBoxEdit);
     }
     for (int i = 0; i < 30; i++) //comboBoxEdit2 = 電錶類型, comboBoxEdit3 = 迴路, comboBoxEdit4 = 相位
     {
         DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit2 = new DevExpress.XtraEditors.ComboBoxEdit
         {
             Name     = $"comboBoxEdit{2 + i * 4}",
             Location = new Point(365, 6 + 25 * i),
             Size     = new Size(68, 22),
             Tag      = i
         };
         comboBoxEdit2.SelectedIndexChanged += ComboBoxEdit2_SelectedIndexChanged;
         comboBoxEdit2.Properties.Items.Add("三相");
         comboBoxEdit2.Properties.Items.Add("單相");
         comboBoxEdit2.Properties.AllowFocused    = false;
         comboBoxEdit2.Properties.AllowMouseWheel = false;
         comboBoxEdit2.Properties.TextEditStyle   = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
         xtraScrollableControl1.Controls.Add(comboBoxEdit2);
         DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit3 = new DevExpress.XtraEditors.ComboBoxEdit
         {
             Name     = $"comboBoxEdit{3 + i * 4}",
             Location = new Point(442, 6 + 25 * i),
             Size     = new Size(68, 22),
             Tag      = i
         };
         comboBoxEdit3.Properties.Items.Add("迴路1");
         comboBoxEdit3.Properties.Items.Add("迴路2");
         comboBoxEdit3.Properties.Items.Add("迴路3");
         comboBoxEdit3.Properties.Items.Add("迴路4");
         comboBoxEdit3.Properties.AllowFocused    = false;
         comboBoxEdit3.Properties.AllowMouseWheel = false;
         comboBoxEdit3.Properties.TextEditStyle   = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
         xtraScrollableControl1.Controls.Add(comboBoxEdit3);
         DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit4 = new DevExpress.XtraEditors.ComboBoxEdit
         {
             Name     = $"comboBoxEdit{4 + i * 4}",
             Location = new Point(518, 6 + 25 * i),
             Size     = new Size(68, 22),
             Tag      = i
         };
         comboBoxEdit4.Properties.Items.Add("R相");
         comboBoxEdit4.Properties.Items.Add("S相");
         comboBoxEdit4.Properties.Items.Add("T相");
         comboBoxEdit4.Properties.AllowFocused    = false;
         comboBoxEdit4.Properties.AllowMouseWheel = false;
         comboBoxEdit4.Properties.TextEditStyle   = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
         xtraScrollableControl1.Controls.Add(comboBoxEdit4);
         comboBoxEdits2.Add(comboBoxEdit2);
         comboBoxEdits3.Add(comboBoxEdit3);
         comboBoxEdits4.Add(comboBoxEdit4);
     }
     #endregion
     #region 抓取原先設定
     #region  層資料
     ComtoggleSwitch.IsOn    = gateWay.ControlFlag;
     RecordtoggleSwitch.IsOn = gateWay.RecordFlag;
     ATMtextEdit.Text        = gateWay.GateWays[0].Authorization;
     if (gateWay.GateWays[0].GatewayEnumType == 0)
     {
         labelControl4.Visible         = true;
         labelControl22.Visible        = true;
         ComPortcomboBoxEdit.Visible   = true;
         RTURatetextEdit.Visible       = true;
         ComcomboBoxEdit.SelectedIndex = 0;
         ComPortcomboBoxEdit.Text      = gateWay.GateWays[0].ModbusRTULocation;
         RTURatetextEdit.Text          = Convert.ToString(gateWay.GateWays[0].ModbusRTURate);
     }
     else if (gateWay.GateWays[0].GatewayEnumType == 1)
     {
         labelControl19.Visible        = true;
         labelControl21.Visible        = true;
         ComTCPtextEdit.Visible        = true;
         RatetextEdit.Visible          = true;
         ComcomboBoxEdit.SelectedIndex = 1;
         ComTCPtextEdit.Text           = gateWay.GateWays[0].ModbusTCPLocation;
         RatetextEdit.Text             = Convert.ToString(gateWay.GateWays[0].ModbusTCPRate);
     }
     else if (gateWay.GateWays[0].GatewayEnumType == 2)
     {
         labelControl20.Visible        = true;
         HTTPtextEdit.Visible          = true;
         ComcomboBoxEdit.SelectedIndex = 2;
         HTTPtextEdit.Text             = gateWay.GateWays[0].APILocation;
     }
     else if (gateWay.GateWays[0].GatewayEnumType == 3)
     {
         labelControl19.Visible        = true;
         labelControl21.Visible        = true;
         ComTCPtextEdit.Visible        = true;
         RatetextEdit.Visible          = true;
         ComcomboBoxEdit.SelectedIndex = 3;
         ComTCPtextEdit.Text           = gateWay.GateWays[0].EMSLocation;
         RatetextEdit.Text             = Convert.ToString(gateWay.GateWays[0].EMSRate);
     }
     #endregion
     #region 天氣
     ATMtextEdit.Text      = gateWay.GateWays[0].Authorization;
     CitycomboBoxEdit.Text = gateWay.GateWays[0].LocationName;
     ZonecomboBoxEdit.Text = gateWay.GateWays[0].DistrictName;
     DeviceTypecomboBoxEdit.SelectedIndex = gateWay.GateWays[0].GateWaySenserIDs[0].SenserEnumType;
     DeviceNametextEdit.Text = gateWay.GateWays[0].GateWaySenserIDs[0].DeviceName;
     IDspinEdit.Text         = Convert.ToString(gateWay.GateWays[0].GateWaySenserIDs[0].DeviceID);
     #endregion
     #region 電表
     for (int i = 0; i < gateWay.GateWays[0].GateWayElectricIDs.Count; i++)
     {
         toggleSwitches[i].IsOn          = true;
         textEdits[i].Text               = gateWay.GateWays[0].GateWayElectricIDs[i].DeviceName;
         spinEdits[i].Text               = Convert.ToString(gateWay.GateWays[0].GateWayElectricIDs[i].DeviceID);
         comboBoxEdits[i].SelectedIndex  = gateWay.GateWays[0].GateWayElectricIDs[i].ElectricEnumType;
         comboBoxEdits2[i].SelectedIndex = gateWay.GateWays[0].GateWayElectricIDs[i].PhaseEnumType;
         comboBoxEdits3[i].SelectedIndex = gateWay.GateWays[0].GateWayElectricIDs[i].LoopEnumType;
         comboBoxEdits4[i].SelectedIndex = gateWay.GateWays[0].GateWayElectricIDs[i].PhaseAngleEnumType;
         toggleSwitches2[i].IsOn         = gateWay.GateWays[0].GateWayElectricIDs[i].TotalMeterFlag;
     }
     #endregion
     #endregion
 }
示例#3
0
        public Form1()
        {
            #region Serilog initial
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .WriteTo.File($"{AppDomain.CurrentDomain.BaseDirectory}\\log\\log-.txt",
                                       rollingInterval: RollingInterval.Day,
                                       outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
                         .CreateLogger();       //宣告Serilog初始化
            #endregion

            #region Loading initial
            FluentSplashScreenOptions op = new FluentSplashScreenOptions();
            op.Title                = "太陽能資料蒐集系統";//太陽能資料蒐集系統  帆宣自動化抄表系統
            op.Subtitle             = "Automatic Meter Reading System";
            op.LeftFooter           = "Copyright © 2021 SIN MAO Energy CO., LTD." + Environment.NewLine + "All Rights reserved.";
            op.LoadingIndicatorType = FluentLoadingIndicatorType.Dots;
            op.OpacityColor         = Color.FromArgb(62, 91, 135);
            op.Opacity              = 130;
            SplashScreenManager.ShowFluentSplashScreen(
                op,
                parentForm: this,
                useFadeIn: true,
                useFadeOut: true
                );
            #endregion

            #region  入資料庫JSON
            op.RightFooter = $"載入資料庫資訊";
            SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
            SystemSetting = InitialMethod.SystemLoad();
            Thread.Sleep(1000);
            #endregion

            #region  入按鈕JSON
            op.RightFooter = $"載入按鈕資訊";
            SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
            ButtonSetting = InitialMethod.InitialButtonLoad();
            Thread.Sleep(1000);
            #endregion

            #region  入匯出報表JSON
            op.RightFooter = $"載入匯出報表資訊";
            SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
            XtraReportSetting = InitialMethod.InitialXtraReportLoad();

            Thread.Sleep(1000);
            #endregion

            #region JSON錯誤資訊檢查
            if (SystemSetting == null && ButtonSetting == null && XtraReportSetting == null)
            {
                ErrorStr = "資料庫與按鈕Json錯誤";
            }
            else if (SystemSetting != null && ButtonSetting == null && XtraReportSetting != null)
            {
                ErrorStr = "按鈕Json錯誤";
            }
            else if (SystemSetting == null && ButtonSetting != null && XtraReportSetting != null)
            {
                ErrorStr = "資料庫Json錯誤";
            }
            else if (SystemSetting != null && ButtonSetting != null && XtraReportSetting == null)
            {
                ErrorStr = "匯出報表Json錯誤";
            }
            if (ErrorStr == "")
            {
                op.RightFooter = $"載入完成";
                SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
                Thread.Sleep(1000);
                SplashScreenManager.CloseForm();
            }
            else
            {
                op.RightFooter = $"{ErrorStr}";
                SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
                Thread.Sleep(5000);
                SplashScreenManager.CloseForm();
            }
            #endregion

            InitializeComponent();
            if (ErrorStr == "")
            {
                Change_Logo();                                                                   //載入Logo
                SettingbarButtonItem.ImageOptions.Image = imageCollection1.Images["technology"]; //設定按鈕圖
                #region 建立資料庫物件
                MysqlMethod = new MysqlMethod(SystemSetting);
                if (SystemSetting != null)
                {
                    GatewayConfigs = MysqlMethod.Search_GatewayConfig();
                }
                #endregion

                #region 建立通訊
                if (GatewayConfigs != null)
                {
                    foreach (var item in GatewayConfigs)
                    {
                        GatewayTypeEnum gatewayType = (GatewayTypeEnum)item.GatewayTypeEnum;
                        switch (gatewayType)
                        {
                        case GatewayTypeEnum.ModbusRTU:
                        {
                            SerialportMasterComponent serialport = new SerialportMasterComponent(item, MysqlMethod)
                            {
                                MysqlMethod = MysqlMethod
                            };
                            serialport.MyWorkState = true;
                            Field4Components.Add(serialport);
                        }
                        break;

                        case GatewayTypeEnum.ModbusTCP:
                        {
                            TCPMasterComponent TCP = new TCPMasterComponent(item, MysqlMethod)
                            {
                                MysqlMethod = MysqlMethod
                            };
                            TCP.MyWorkState = true;
                            Field4Components.Add(TCP);
                        }
                        break;
                        }
                    }
                }
                #endregion

                #region 建立按鈕物件
                NavigationFrame = new NavigationFrame()
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.Parent = ViewpanelControl;
                ButtonMethod           = new ButtonMethod()
                {
                    Form1 = this, navigationFrame = NavigationFrame
                };
                ButtonMethod.AccordionLoad(accordionControl1, ButtonSetting);
                #endregion

                #region 建立畫面
                foreach (var Componentitem in Field4Components)
                {
                    foreach (var Absprotocolitem in Componentitem.ElectricAbsProtocols)
                    {
                        ElectricAbsProtocols.Add(Absprotocolitem);
                    }
                }
                #region 主畫面
                MainUserControl main = new MainUserControl(MysqlMethod, ElectricAbsProtocols)
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.AddPage(main);
                Field4UserControls.Add(main);
                #endregion
                #region 報表畫面
                ChartUserControl chart = new ChartUserControl(MysqlMethod)
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.AddPage(chart);
                Field4UserControls.Add(chart);
                #endregion
                #region 月報表畫面
                xtraReportUserControl = new XtraReportUserControl(MysqlMethod)
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.AddPage(xtraReportUserControl);
                #endregion
                #endregion
            }
            timer1.Interval = 1000;
            timer1.Enabled  = true;
        }
        public Form1()
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .WriteTo.File($"{AppDomain.CurrentDomain.BaseDirectory}\\log\\log-.txt",
                                       rollingInterval: RollingInterval.Day,
                                       outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
                         .CreateLogger(); //宣告Serilog初始化

            MySqlSetting  = InitialMethod.MySqlLoad();
            ButtonSetting = InitialMethod.InitialButtonLoad();
            InitializeComponent();
            NavigationFrame = new NavigationFrame()
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.Parent = DisPlaypanelControl;

            ButtonMethod = new ButtonMethod()
            {
                Form1 = this, navigationFrame = NavigationFrame
            };
            ButtonMethod.AccordionLoad(accordionControl1, ButtonSetting);

            #region Ewatch平台
            Ewatch_MySqlMethod                = new Ewatch_MySqlMethod(MySqlSetting);
            Ewatch_MySqlComponent             = new Ewatch_MySqlComponent(Ewatch_MySqlMethod);
            Ewatch_MySqlComponent.MyWorkState = true;
            Ewatch_Field4Component.Add(Ewatch_MySqlComponent);
            Ewatch_AlarmComponent             = new Ewatch_AlarmComponent(Ewatch_MySqlMethod);
            Ewatch_AlarmComponent.MyWorkState = true;
            Ewatch_Field4Component.Add(Ewatch_AlarmComponent);

            EwatchConnectionUserControl ewatchConnectionUserControl = new EwatchConnectionUserControl(Ewatch_MySqlComponent)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(ewatchConnectionUserControl);
            Ewatch_Field4UserControl.Add(ewatchConnectionUserControl);

            CaseUserControl caseUserControl = new CaseUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(caseUserControl);
            Ewatch_Field4UserControl.Add(caseUserControl);

            AiSettingUserControl aiSettingUserControl = new AiSettingUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(aiSettingUserControl);
            Ewatch_Field4UserControl.Add(aiSettingUserControl);

            AiConfigUserControl aiConfigUserControl = new AiConfigUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(aiConfigUserControl);
            Ewatch_Field4UserControl.Add(aiConfigUserControl);

            ElectricSettingUserControl electricSettingUserControl = new ElectricSettingUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(electricSettingUserControl);
            Ewatch_Field4UserControl.Add(electricSettingUserControl);

            StateSettingUserControl stateSettingUserControl = new StateSettingUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(stateSettingUserControl);
            Ewatch_Field4UserControl.Add(stateSettingUserControl);
            #endregion

            #region ChungHsin平台
            ChungHsin_MySqlMethod                = new ChungHsin_MySqlMethod(MySqlSetting);
            ChungHsin_MySqlComponent             = new ChungHsin_MySqlComponent(ChungHsin_MySqlMethod);
            ChungHsin_MySqlComponent.MyWorkState = true;
            ChungHsin_Field4Component.Add(ChungHsin_MySqlComponent);

            ChumgHsinConnectionUserControl chumgHsinConnectionUserControl = new ChumgHsinConnectionUserControl(ChungHsin_MySqlComponent)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(chumgHsinConnectionUserControl);
            ChungHsin_Field4UserControl.Add(chumgHsinConnectionUserControl);

            DeviceConfigUserControl deviceConfigUserControl = new DeviceConfigUserControl(ChungHsin_MySqlMethod)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(deviceConfigUserControl);
            ChungHsin_Field4UserControl.Add(deviceConfigUserControl);

            CH_CaseSettingUserControl cH_CaseSettingUserControl = new CH_CaseSettingUserControl(ChungHsin_MySqlMethod)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(cH_CaseSettingUserControl);
            ChungHsin_Field4UserControl.Add(cH_CaseSettingUserControl);

            ReceiveSettingUserControl receiveSettingUserControl = new ReceiveSettingUserControl(ChungHsin_MySqlMethod)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(receiveSettingUserControl);
            ChungHsin_Field4UserControl.Add(receiveSettingUserControl);
            #endregion

            timer1.Interval = 1000;
            timer1.Enabled  = true;
        }