123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Threading;
- using System.Collections;
- namespace IControls_FireManager
- {
- public partial class Form_PointOpcData : Form
- {
-
- Form DialogPopup = new Form();
-
- delegate void Cross_Thread();
-
- string Receiver_ID = null;
-
- DataRowCollection DB_TABLE_DEVICE = null;
-
- public Form_PointOpcData(_RECEIVER RECEIVER)
- {
- InitializeComponent();
-
-
-
- this.StartPosition = FormStartPosition.Manual;
- this.Location = new System.Drawing.Point(MousePosition.X, MousePosition.Y);
-
-
-
-
- Receiver_ID = RECEIVER.ID;
-
- string ReiceiverFolderName = _Text.DEFAULT_FOLDER_RECEIVER_PREFIX + Receiver_ID;
-
- _File.Create_Folder(_Data.Project_Path + "\\" + _Data.Project_Name + "\\" + ReiceiverFolderName + "\\", _Text.DEFAULT_FOLDER_OPC);
-
- this.editBox_ProjectPath.Text = _Data.Project_Path + "\\" + _Data.Project_Name + "\\" + ReiceiverFolderName + "\\" + _Text.DEFAULT_FOLDER_OPC;
-
-
-
-
- this.FormClosing += new FormClosingEventHandler(CreateForm_FormClosing);
- }
-
- public void CreateForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- }
-
- private void uiButton_ProjectPath_Click(object sender, EventArgs e)
- {
-
- FolderBrowserDialog pFolderBrowserDialog = new FolderBrowserDialog();
-
- string ReiceiverFolderName = _Text.DEFAULT_FOLDER_RECEIVER_PREFIX + Receiver_ID;
-
- pFolderBrowserDialog.SelectedPath = _Data.Project_Path + "\\" + _Data.Project_Name + "\\" + ReiceiverFolderName + "\\" + _Text.DEFAULT_FOLDER_OPC;
-
-
-
- if (pFolderBrowserDialog.ShowDialog() == DialogResult.OK)
- {
- this.editBox_ProjectPath.Text = pFolderBrowserDialog.SelectedPath;
- }
- }
-
- private void Delegate_UiProgressBar()
- {
- if (this.InvokeRequired)
- {
- Cross_Thread d = new Cross_Thread(Delegate_UiProgressBar);
- this.Invoke(d, new object[] { });
- }
- else
- {
- UiProgressBar_OpcData.Value++;
- }
- }
-
- private void Delegate_UiButton()
- {
- if (this.InvokeRequired)
- {
- Cross_Thread d = new Cross_Thread(Delegate_UiButton);
- this.Invoke(d, new object[] { });
- }
- else
- {
- label1.Text = "※ 완료되었습니다.";
- UiButton_Apply.Enabled = true;
- UiButton_Close.Enabled = true;
- }
- }
-
- private void UiButton_Close_Click(object sender, EventArgs e)
- {
-
- this.Close();
- }
-
- private void UiButton_Apply_Click(object sender, EventArgs e)
- {
-
- if (editBox_ProjectPath.Text.Length == 0)
- {
-
- _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.NotFolderChoice, 0);
- return;
- }
-
- if (_Data.Enable_Button == false)
- return;
- else
- _Data.Enable_Button = false;
-
-
-
- _Data.DataBaseFilePath_Set(null);
-
- if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")
- {
-
- DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable_NoneBoardID_BigReceiver("1", "I", "", "", "", "", "", Receiver_ID));
- }
- else
- {
-
- DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable("1", "I", "15", "", "", "", "", "", Receiver_ID));
- }
- if (DB_TABLE_DEVICE == null || DB_TABLE_DEVICE.Count == 0)
- {
- _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailDataInform, 0);
- return;
- }
- else
- {
-
- DialogPopup = _Popup.Create(Popup_Type.Dialog, Popup_Style.Normal, _Text.OK, 500, 150, _Text.OpcInfoCreate_Continue, 0);
-
- _Event.PopupClose_SendMessage_Event += new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event);
- }
- }
-
- public void OPC_DataCreate()
- {
-
-
-
-
- string FirePoint = "# Code Name = ReceiverID BoardID,Loop,Repeater,Port" + _Text.CarrageReturn;
- ArrayList CommBoardIDCount = new ArrayList();
- foreach (DataRow dr in DB_TABLE_DEVICE)
- {
- string BoardID = dr["BOARD_ID"].ToString();
- string Loop = dr["LOOP_NO"].ToString();
- string Repeater = _Convert.String_to_Int_ThreeType(dr["REPEATER_ID"].ToString());
- string Repeater_No = dr["REPEATER_ID"].ToString();
- string Port = dr["DEVICE_ID"].ToString();
- FirePoint = FirePoint + "M MI" + Receiver_ID + BoardID + Loop + Repeater + Port +
- "=" + Receiver_ID + "," + BoardID + ",I," + Loop + "," + Repeater_No + "," + Port + _Text.CarrageReturn;
-
- if (CommBoardIDCount.Contains(BoardID) == false)
- CommBoardIDCount.Add(BoardID);
-
- if (UiProgressBar_OpcData.Value <= UiProgressBar_OpcData.Maximum)
- Delegate_UiProgressBar();
- }
-
-
-
- string FireUnit = null;
- foreach (string CommBoardID in CommBoardIDCount)
- FireUnit = FireUnit + "M " + CommBoardID + _Text.CarrageReturn;
-
-
-
- string config = "[RECEIVER]" + _Text.CarrageReturn;
- DataRowCollection DB_TABLE_TB_RECEIVER = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_RECEIVER", Receiver_ID));
- if (DB_TABLE_TB_RECEIVER != null && DB_TABLE_TB_RECEIVER.Count != 0)
- {
- DataRow dr = DB_TABLE_TB_RECEIVER[0];
- config = config + "IP = " + dr["IP_ADDRESS"].ToString() + _Text.CarrageReturn;
- config = config + "EVENT_PORT = " + Util.StrToInt(dr["EVENT_PORT_NO"], 0) + _Text.CarrageReturn;
- config = config + "COMMAND_PORT = " + Util.StrToInt(dr["COMMAND_PORT_NO"], 0);
- }
-
-
-
- _Cfg.Create_Cfg(FirePoint, this.editBox_ProjectPath.Text + "\\" + _Text.DEFAULT_OPC_POINT);
-
- if (UiProgressBar_OpcData.Value <= UiProgressBar_OpcData.Maximum)
- Delegate_UiProgressBar();
- _Cfg.Create_Cfg(FireUnit, this.editBox_ProjectPath.Text + "\\" + _Text.DEFAULT_OPC_UNIT);
-
- if (UiProgressBar_OpcData.Value <= UiProgressBar_OpcData.Maximum)
- Delegate_UiProgressBar();
- _Ini.Create_Ini(config, this.editBox_ProjectPath.Text + "\\" + _Text.DEFAULT_OPC_CONFIG);
-
- if (UiProgressBar_OpcData.Value <= UiProgressBar_OpcData.Maximum)
- Delegate_UiProgressBar();
-
- Delegate_UiButton();
-
- _Data.Enable_Button = true;
- }
-
- public void _Event_PopupClose_SendMessage_Event(object sender, object etc)
- {
-
- Form popup = (Form)sender;
- if (DialogPopup.Name == popup.Name && etc.ToString() == _Text.OK)
- {
-
- UiButton_Apply.Enabled = false;
- UiButton_Close.Enabled = false;
-
- int ProgressBar_TotalCount = 3;
-
- ProgressBar_TotalCount = ProgressBar_TotalCount + DB_TABLE_DEVICE.Count;
-
- UiProgressBar_OpcData.Maximum = ProgressBar_TotalCount;
-
- UiProgressBar_OpcData.Value = 0;
-
- Thread WorkingThread = new Thread(new ThreadStart(OPC_DataCreate));
-
- WorkingThread.Start();
- }
- else
- _Data.Enable_Button = true;
-
- _Event.PopupClose_SendMessage_Event -= new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event);
- }
- }
- }
|