1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics; // 2010.10.28, k.s.d, for debug funtion.
- namespace FPER
- {
- public partial class frmProgress : Form
- {
- private CmdInfo commandinfo; //명령정보
- private SocketUI socketUI; //명령받는곳
- private Boolean complete = false; // 완료여부
- private controlWriteDevType[] devTypes; //연동타입차단을위해
- private RepeaterDeviceTypeInfo[] repinfo; //중계기설정정보-설정쓰기를 위해
- private BoardTypeInfo[] brdinfos; //통신보드차단명령을 위해
- private ReceiverConfigVo configVoChg; //환경정보변경 명령을 위해 --변경된 데이터
- private ReceiverConfigVo configVoMy; //환경정보변경 명령을 위해 --원래 데이터
- private ReceiverTypeInfo configReceiverPoint; //전체 수신기 데이터
- bool configReceiverPointAllWrite = false; //전체수신기 데이터 쓰기 여부
- public ReceiverConfigVo ConfigVoMy { set { this.configVoMy = value; } }
- public CmdInfo Commandinfo { get { return this.commandinfo; } set { this.commandinfo = value; } }
- public SocketUI ui { get { return this.socketUI; } set { this.socketUI = value; } }
- public int download_type = 0;// 2010.10.28, k.s.d, only one click device linkage change support value .
- // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
- public MDIParent mdi = null;
- public frmProgress(MDIParent pMdi)
- {
- InitializeComponent();
- mdi = pMdi;
- }
- private void frmProgress_Load(object sender, EventArgs e)
- {
- try
- {
- progressBar1.Value = 0;
- btnOK.Enabled = false;
- //명령별 작업진행
- progress_Run();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- public void SetLinkageCut()// 2010.10.28, k.s.d, only one click device linkage change support .
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- //lblDescription.Text = "연동타입차단명령";
- progressBar1.Maximum = 100;
- progressBar1.Value += 1;
- progressBar1.Refresh();
- btnOK.Visible = false;//2010.10.29,k.s.d, ok button unvisible.
- lblDescription.Visible = false;
- // progressBar1.Visible = false;
- listView1.Visible = false;
- ProgressLabel.Visible = true;
- //이벤트정의
- dCommandResponse d = new dCommandResponse(command_complete);
- this.commandinfo.dEvent = d;
- this.commandinfo.CommId = 1;
- this.commandinfo.loopNo = 0;
- //명령 생성
- ui.runCommand(this.commandinfo);
- progressBar1.Value = 50;
- //string actionMsg = commandinfo.Status == 0 ? "해제" : "설정";
- ////Device_Type_Name
- //actionMsg = commandinfo.Status == 1 ? "정지" : "연동";//2010.11.12,k.s.d, display message bug fix( 정지 <-> 연동 )
- //DacDeviceConfig dacDeviceConfig = new DacDeviceConfig();
- //string deviceTypeName = dacDeviceConfig.Device_Type_Name(code_InOutType.Output, string.Format("O{0}", commandinfo.SubType));
- //string thisLog = String.Format("{0} 연동타입 {1}명령", deviceTypeName, actionMsg);
- //ListViewLogAdd(thisLog + ": 진행중" );
- progressBar1.Refresh();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- this.Cursor = Cursors.Default;
- }
- }
- //작업시작
- private void progress_Run()
- {
- try
- {
- if (this.commandinfo == null) return;
- progressBar1.Value = 0;
- listView1.Items.Clear();
- this.Show();
- if (!ui.Connected)
- {
- MessageBox.Show("통신상태를 확인하세요..", Application.ProductName);
- this.Close();
- return;
- }
- if (download_type != 0)// 2010.10.28, k.s.d, only one click device linkage change support .
- {
- this.SetLinkageCut();
- return;
- }
- switch (this.commandinfo.Command)
- {
- //중계기 Unit 에 정보 쓰기
- case prt_cmd_define.write_repeater_info_unit:
- this.Text = "중계기 정보 UNIT 쓰기중.....";
- lblDescription.Text = "중계기 정보 UNIT 쓰기";
- if (this.commandinfo.boardNo > 0)
- {
- progressBar1.Maximum = 127;
- if (this.commandinfo.CommandData != null)
- {
- //중계기 쓰기 정보를 저장한다.. commanddata를 재사용하므로
- this.repinfo = (RepeaterDeviceTypeInfo[])this.commandinfo.CommandData;
- //중계기 Unit 에 정보 쓰기---시작
- repeater_info_unit_write_progress();
- }
- else
- {
- MessageBox.Show("데이터가 유효하지 않습니다.. 설정데이터를 알수 없습니다.");
- //완료
- CompleteProgress();
- }
- }
- else
- {
- this.Text = "중계기 정보 UNIT 전체 쓰기중.....";
- lblDescription.Text = "중계기 정보 UNIT 전체 쓰기";
- progressBar1.Maximum = 16 * 2 * 127;
- //전체수신기 쓰기를 한다고 저장.
- this.configReceiverPointAllWrite = true;
- //전체 수신기 데이터를 DB에서 읽어온다..
- //수신기 설정정보 CLASS 생성 - DB에서 설정정보를 읽어와 저장한다..
- UIReceiverInfo cfg = new UIReceiverInfo(this.commandinfo.receiverID);
- this.configReceiverPoint = cfg.ReadAll_ReceiverTypeInfo(mdi);
- this.commandinfo.CommandData = null;
- this.commandinfo.boardNo = 1;
- this.commandinfo.loopNo = 0;
- this.commandinfo.repeaterNo = 0; //시작시 중계기 번호를 증가시키므로 0 으로 초기화
- //보드존재유무
- bool runBoardIdOK = false;
- while (!runBoardIdOK)
- {
- BoardTypeInfo brdinfo = this.configReceiverPoint.Get_RepeaterType(this.commandinfo.boardNo); //통신보드savBoardID의 설정값
- if (brdinfo != null)
- {
- // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
- if (this.commandinfo.loopNo == 0)
- {
- this.repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
- }
- else if (this.commandinfo.loopNo == 1)
- {
- this.repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
- }
- else if (this.commandinfo.loopNo == 2)
- {
- this.repinfo = brdinfo.Loop2_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
- }
- else if (this.commandinfo.loopNo == 3)
- {
- this.repinfo = brdinfo.Loop3_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
- }
- runBoardIdOK = true;
- }
- }
- if (runBoardIdOK)
- {
- //중계기 Unit 에 정보 전체 쓰기---시작
- repeater_info_unit_all_write_progress();
- }
- else
- {
- MessageBox.Show("설정된 통신보드가 없습니다..");
- //완료
- CompleteProgress();
- }
- }
- break;
- case prt_cmd_define.read_command_status:
- switch (this.commandinfo.CommandType)
- {
- //차단명령
- case "DC":
- {
- this.Text = "차단설정 명령중..";
- if (this.commandinfo.CommandData != null)
- {
- if (this.commandinfo.ApplyRange.Equals("L")) //Loop16개 차단시
- {
- lblDescription.Text = "계통차단명령";
- this.brdinfos = (BoardTypeInfo[])this.commandinfo.CommandData;
- progressBar1.Maximum = this.brdinfos.Length;
- }
- else if (this.commandinfo.ApplyRange.Equals("R")) //중계기 차단시
- {
- lblDescription.Text = "중계기차단명령";
- this.repinfo = (RepeaterDeviceTypeInfo[])this.commandinfo.CommandData;
- progressBar1.Maximum = this.repinfo.Length;
- }
- else if (this.commandinfo.ApplyRange.Equals("A")) //연동타입 차단시
- {
- lblDescription.Text = "연동타입차단명령";
- this.devTypes = (controlWriteDevType[])this.commandinfo.CommandData;
- progressBar1.Maximum = this.devTypes.Length;
- }
- else if (this.commandinfo.ApplyRange.Equals("I")) //입력회로 차단시
- {
- lblDescription.Text = "입력회로 차단명령";
- progressBar1.Maximum = 2;
- }
- else if (this.commandinfo.ApplyRange.Equals("O")) //출력회로 차단시
- {
- lblDescription.Text = "출력회로 차단명령";
- progressBar1.Maximum = 2;
- }
- cut_flag_progress();
- }
- else
- {
- MessageBox.Show("데이터가 유효하지 않습니다.. 설정데이터를 알수 없습니다.");
- //완료
- CompleteProgress();
- }
- break;
- }
- //환경정보변경
- case "CS":
- {
- progressBar1.Maximum = 4;
- this.Text = "환경설정 변경중..";
- lblDescription.Text = "환경설정 변경명령";
- if (this.commandinfo.CommandData != null)
- {
- this.configVoChg = (ReceiverConfigVo)this.commandinfo.CommandData;
- config_change_progress();
- }
- else
- {
- MessageBox.Show("데이터가 유효하지 않습니다.. 설정데이터를 알수 없습니다.");
- //완료
- CompleteProgress();
- }
- break;
- }
- default:
- lblDescription.Text = "알수없는명령";
- break;
- }
- break;
- default:
- break;
- }
- this.Refresh();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
- }
- }
- //환경설정변경 진행
- private void config_change_progress()
- {
- try
- {
- //명령 생성 여부
- bool runCommandOK = false;
- progressBar1.Value += 1;
- progressBar1.Refresh();
- //이벤트정의
- dCommandResponse d = new dCommandResponse(command_complete);
- this.commandinfo.dEvent = d;
- if (this.configVoChg.Fire_accumulation_mode != this.configVoMy.Fire_accumulation_mode)
- {
- //축적모드 변경 명령
- bool mode = this.configVoChg.Fire_accumulation_mode;
- this.commandinfo.SubType = "A";
- this.commandinfo.Status = mode ? 1 : 0;
- this.configVoMy.Fire_accumulation_mode = mode;
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- return;
- }
- //축적모드일경우만 시간을 보냄
- if (this.configVoChg.Fire_accumulation_mode && this.configVoChg.Fire_accumulation_time != this.configVoMy.Fire_accumulation_time)
- {
- //축적시간 변경 명령
- this.commandinfo.SubType = "T";
- this.commandinfo.Status = this.configVoChg.Fire_accumulation_time;
- this.configVoMy.Fire_accumulation_time = this.configVoChg.Fire_accumulation_time;
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- return;
- }
- if (this.configVoChg.Fire_process_mode != this.configVoMy.Fire_process_mode)
- {
- //화재모드 변경 명령
- bool mode = this.configVoChg.Fire_process_mode;
- this.commandinfo.SubType = "F";
- this.commandinfo.Status = mode ? 1 : 0;
- this.configVoMy.Fire_process_mode = mode;
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- return;
- }
- //지구경종모드 없음
- //생성한 명령이 없으므로 종료
- if (!runCommandOK) CompleteProgress();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- // 차단설정 진행
- private void cut_flag_progress()
- {
- try
- {
- //명령 생성 여부
- bool runCommandOK = false;
- progressBar1.Value += 1;
- progressBar1.Refresh();
- //이벤트정의
- dCommandResponse d = new dCommandResponse(command_complete);
- this.commandinfo.dEvent = d;
- switch (this.commandinfo.ApplyRange) //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
- {
- case "A"://연동타입차단
- {
- foreach (controlWriteDevType devtp in this.devTypes)
- {
- if (devtp.ChangeFlag)
- {
- this.commandinfo.CommId = 1;
- this.commandinfo.loopNo = 0;
- this.commandinfo.Status = devtp.Use_flag ? 0 : 1; //k.s.d 20101022, devtp.Use_flag ? 1 : 0; -> devtp.Use_flag ? 0 : 1; with jys(ub).
- this.commandinfo.SubType = devtp.Dev_type.Substring(1); //연동출력타입1자리
- devtp.ChangeFlagReset();
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- break;
- }
- }
- if (!runCommandOK) CompleteProgress();
- break;
- }
- case "C": break;
- case "B": break; //
- case "L": //Loop
- {
- // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
- int boardID_init = 0;
- int boardID_cnt = 0;
- // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
- if (mdi.ReceiverModel == "IFC3300")
- {
- boardID_init = 0;
- boardID_cnt = 65;
- }
- else
- {
- boardID_init = 0;
- boardID_cnt = 16;
- }
- for (int i = boardID_init; i < boardID_cnt; i++) // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
- {
- if (this.brdinfos[i] != null)
- {
- if (this.brdinfos[i].Loop0CutFlagChange)
- {
- this.commandinfo.boardNo = i + 1;
- this.commandinfo.loopNo = 0;
- this.commandinfo.Status = this.brdinfos[i].Loop0CutFlag ? 0 : 1; //k.s.d 20120102, 1 : 0; -> 0 : 1; with jys(ub).
- this.brdinfos[i].Loop0CutFlagChangeReset();
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- break;
- }
- else if (this.brdinfos[i].Loop1CutFlagChange)
- {
- this.commandinfo.boardNo = i + 1;
- this.commandinfo.loopNo = 1;
- this.commandinfo.Status = this.brdinfos[i].Loop1CutFlag ? 0 : 1;//k.s.d 20120102, 1 : 0; -> 0 : 1; with jys(ub).
- this.brdinfos[i].Loop1CutFlagChangeReset();
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- break;
- }
- // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
- else if (this.brdinfos[i].Loop2CutFlagChange)
- {
- this.commandinfo.boardNo = i + 1;
- this.commandinfo.loopNo = 2;
- this.commandinfo.Status = this.brdinfos[i].Loop2CutFlag ? 0 : 1;
- this.brdinfos[i].Loop2CutFlagChangeReset();
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- break;
- }
- else if (this.brdinfos[i].Loop3CutFlagChange)
- {
- this.commandinfo.boardNo = i + 1;
- this.commandinfo.loopNo = 3;
- this.commandinfo.Status = this.brdinfos[i].Loop3CutFlag ? 0 : 1;
- this.brdinfos[i].Loop3CutFlagChangeReset();
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- break;
- }
- }
- }
- if (!runCommandOK) CompleteProgress();
- break;
- }
- case "R": //중계기
- {
- for (int i = 0; i < this.repinfo.Length; i++)
- {
- if (this.repinfo[i] != null)
- {
- if (this.repinfo[i].CutFlagChange)
- {
- this.commandinfo.repeaterNo = this.repinfo[i].RepeaterNo;
- this.commandinfo.Status = this.repinfo[i].CutFlag ? 0 : 1;//k.s.d 20120102, 1 : 0; -> 0 : 1; with jys(ub).
- this.repinfo[i].CutFlagChangeReset();
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- break;
- }
- }
- }
- if (!runCommandOK) CompleteProgress();
- break;
- }
- case "D": break;
- case "I":
- if (this.commandinfo.CommandData.ToString().Equals("CUTCOMMAND"))
- {
- this.commandinfo.CommandData = "COMPLETE";
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- }
- if (!runCommandOK) CompleteProgress();
- break;
- case "O":
- if (this.commandinfo.CommandData.ToString().Equals("CUTCOMMAND"))
- {
- this.commandinfo.CommandData = "COMPLETE";
- //명령 생성
- runCommandOK = true;
- ui.runCommand(this.commandinfo);
- }
- if (!runCommandOK) CompleteProgress();
- break;
- default: break;
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- //중계기 Unit 에 정보 쓰기--시작
- private void repeater_info_unit_write_progress()
- {
- try
- {
- //중계기정보쓰기 명령
- dCommandResponse d = new dCommandResponse(command_complete);
- this.commandinfo.dEvent = d;
- //다음중계기로 중계기번호를 증가시킨다.
- int repeaterNo = this.commandinfo.repeaterNo + 1;
- if (repeaterNo <= 127)
- {
- progressBar1.Value += 1;
- progressBar1.Refresh();
- int repeaterType = 0;
- bool CutFlag = false;
- bool FireResetFlag = false;
- if (repinfo[repeaterNo - 1] != null)
- {
- if (repinfo[repeaterNo - 1].UseFlag)
- {
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- //repeaterType = repinfo[repeaterNo - 1].RepeaterType == "A" ? 1 : 2;
- // '1' = A : 2X2
- // '2' = B : 4X4
- // '4' = C : 아날로그연감지기
- // '5' = D : 아날로그열감지기
- if (repinfo[repeaterNo - 1].RepeaterType == "A")
- repeaterType = 1;
- else if (repinfo[repeaterNo - 1].RepeaterType == "B")
- repeaterType = 2;
- else if (repinfo[repeaterNo - 1].RepeaterType == "C")
- repeaterType = 4;
- else if (repinfo[repeaterNo - 1].RepeaterType == "D")
- repeaterType = 5;
- CutFlag = repinfo[repeaterNo - 1].CutFlag;
- FireResetFlag = repinfo[repeaterNo - 1].FireResetFlag;
- }
- else
- {
- repeaterType = 0;
- CutFlag = false;
- FireResetFlag = false;
- }
- }
- //중계기설정정보 저장
- this.commandinfo.repeaterNo = repeaterNo;
- //this.commandinfo.setRepeaterInfo(repeaterNo, repeaterType);
- RepeaterData data = new RepeaterData((byte)repeaterNo);
- data.Set_Info_Data(CutFlag, FireResetFlag, false, false, repeaterType);
- this.commandinfo.CommandData = data;
- //명령보냄
- ui.runCommand(this.commandinfo);
- }
- else
- {
- //완료
- CompleteProgress();
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- //중계기 Unit 에 정보 전체 쓰기--시작
- private void repeater_info_unit_all_write_progress()
- {
- try
- {
- //명령 생성 여부
- bool runCommandOK = false;
- //보드존재유무
- bool runBoardIdOK = true;
- while (!runCommandOK)
- {
- //중계기정보쓰기 명령
- dCommandResponse d = new dCommandResponse(command_complete);
- this.commandinfo.dEvent = d;
- //다음중계기로 중계기번호를 증가시킨다.
- int repeaterNo = this.commandinfo.repeaterNo + 1;
- int loopNo = this.commandinfo.loopNo;
- int boardId = this.commandinfo.boardNo;
- if (repeaterNo > 127)
- {
- repeaterNo = 1;
- runBoardIdOK = false;
- while (!runBoardIdOK)
- {
- ++loopNo;
- if (loopNo > 1)
- {
- loopNo = 0;
- ++boardId;
- // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
- int boardID_cnt = 0;
- // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
- if (mdi.ReceiverModel == "IFC3300")
- {
- boardID_cnt = 64;
- }
- else
- {
- boardID_cnt = 16;
- }
-
- // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
- if (boardId > boardID_cnt)
- {
- runBoardIdOK = false;
- //완료
- CompleteProgress();
- return;
- }
- }
- BoardTypeInfo brdinfo = this.configReceiverPoint.Get_RepeaterType(boardId); //통신보드savBoardID의 설정값
- if (brdinfo != null)
- {
- runBoardIdOK = true;
- // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
- if (loopNo == 0)
- {
- this.repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
- }
- else if (loopNo == 1)
- {
- this.repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
- }
- else if (loopNo == 2)
- {
- this.repinfo = brdinfo.Loop2_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
- }
- else if (loopNo == 3)
- {
- this.repinfo = brdinfo.Loop3_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
- }
- }
- }
- }
- progressBar1.Value += 1;
- progressBar1.Refresh();
- //중계기설정정보 저장
- this.commandinfo.repeaterNo = repeaterNo;
- //this.commandinfo.setRepeaterInfo(repeaterNo, repeaterType);
- this.commandinfo.boardNo = boardId;
- this.commandinfo.loopNo = loopNo;
- int repeaterType = 0;
- bool CutFlag = false;
- bool FireResetFlag = false;
- if (this.repinfo[repeaterNo - 1] != null)
- {
- if (this.repinfo[repeaterNo - 1].UseFlag)
- {
- //repeaterType = this.repinfo[repeaterNo - 1].RepeaterType == "A" ? 1 : 2;
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- // '1' = A : 2X2
- // '2' = B : 4X4
- // '4' = C : 아날로그연감지기
- // '5' = D : 아날로그열감지기
- if (repinfo[repeaterNo - 1].RepeaterType == "A")
- repeaterType = 1;
- else if (repinfo[repeaterNo - 1].RepeaterType == "B")
- repeaterType = 2;
- else if (repinfo[repeaterNo - 1].RepeaterType == "C")
- repeaterType = 4;
- else if (repinfo[repeaterNo - 1].RepeaterType == "D")
- repeaterType = 5;
- CutFlag = this.repinfo[repeaterNo - 1].CutFlag;
- FireResetFlag = repinfo[repeaterNo - 1].FireResetFlag;
- }
- else
- {
- repeaterType = 0;
- CutFlag = false;
- FireResetFlag = false;
- }
- }
- runCommandOK = true;
- RepeaterData data = new RepeaterData((byte)repeaterNo);
- data.Set_Info_Data(CutFlag, FireResetFlag, false, false, repeaterType);
- this.commandinfo.CommandData = data;
- //명령보냄
- ui.runCommand(this.commandinfo);
- break;
- }
- //RepeaterData data = new RepeaterData((byte)repeaterNo);
- //data.Set_Info_Data(CutFlag, false, false, false, repeaterType);
- //this.commandinfo.CommandData = data;
- ////명령보냄
- //ui.runCommand(this.commandinfo);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- //명령 쓰기 완료--종료.
- public void command_complete(CmdInfo resInfo)
- {
- try
- {
- if (this.complete) return;
- switch (this.commandinfo.Command)
- {
- //중계기 Unit 에 정보 쓰기
- case prt_cmd_define.write_repeater_info_unit:
- {
- if (this.configReceiverPointAllWrite)
- {
- /***********************************************/
- /* 전체쓰기 */
- /***********************************************/
- String thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} UNIT 정보 쓰기", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo);
- lblDescription.Text = thisLog;
- if (resInfo.ErrResponse)
- {
- ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
- Application.DoEvents();
- }
- else
- {
- ListViewLogAdd(thisLog + ": 완료");
- }
- //다시 진행으로 보내줌
- repeater_info_unit_all_write_progress();
- /***********************************************/
- }
- else
- {
- /***********************************************/
- /* Loop쓰기 */
- /***********************************************/
- String thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} UNIT 정보 쓰기", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo);
- lblDescription.Text = thisLog;
- if (resInfo.ErrResponse)
- {
- ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
- Application.DoEvents();
- }
- else
- {
- ListViewLogAdd(thisLog + ": 완료");
- }
- //다시 진행으로 보내줌
- repeater_info_unit_write_progress();
- /***********************************************/
- }
- break;
- }
- case prt_cmd_define.read_command_status:
- {
- switch (this.commandinfo.CommandType)
- {
- case "DC":
- {
- this.Text = "차단설정 명령중..";
- string actionMsg = resInfo.Status == 0 ? "설정" : "해제";
- String thisLog = "차단설정 명령";
- if (this.commandinfo.ApplyRange.Equals("L")) //Loop16개 차단시
- {
- thisLog = String.Format("통신보드#{0} 계통#{1} 차단{2}명령", resInfo.boardNo, resInfo.loopNo, actionMsg);
- }
- else if (this.commandinfo.ApplyRange.Equals("R")) //중계기 차단시
- {
- thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} 차단{3}명령", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo, actionMsg);
- }
- else if (this.commandinfo.ApplyRange.Equals("I")) //입력회로 차단시
- {
- thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} 입력회로#{3} 차단{4}명령", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo, resInfo.DeviceId, actionMsg);
- }
- else if (this.commandinfo.ApplyRange.Equals("O")) //출력회로 차단시
- {
- thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} 출력회로#{3} 차단{4}명령", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo, resInfo.DeviceId, actionMsg);
- }
- else if (this.commandinfo.ApplyRange.Equals("A")) //연동타입 차단시
- {
- //Device_Type_Name
- actionMsg = resInfo.Status == 1 ? "정지" : "연동";//2010.11.12,k.s.d, display message bug fix( 정지 <-> 연동 )
- DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(resInfo.receiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
- string deviceTypeName = dacDeviceConfig.Device_Type_Name(code_InOutType.Output, string.Format("O{0}", resInfo.SubType));
- thisLog = String.Format("{0} 연동타입 {1}명령", deviceTypeName, actionMsg);
- }
- lblDescription.Text = thisLog;
- if (resInfo.ErrResponse)
- {
- ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
- Application.DoEvents();
- }
- else
- {
- ListViewLogAdd(thisLog + ": 완료");
- }
- //다시 진행으로 보내줌
- if (download_type != 0)// 2010.10.28, k.s.d, only one click device linkage change support .
- {
- CompleteProgress(true, 1000);
- }
- else
- {
- cut_flag_progress();
- }
- break;
- }
- //환경정보변경
- case "CS":
- {
- this.Text = "환경설정 변경중..";
- String thisLog = "알수없음.";
- switch (resInfo.SubType)
- {
- case "A": thisLog = "축적모드 변경"; break;
- case "T": thisLog = "축적시간 변경"; break;
- case "F": thisLog = "화재모드 변경"; break;
- case "S": thisLog = "지구음향모드 변경"; break;//2010.11.12,k.s.d, 지구경종 -> 지구음향
- }
- lblDescription.Text = thisLog;
- if (resInfo.ErrResponse)
- {
- ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
- Application.DoEvents();
- }
- else
- {
- ListViewLogAdd(thisLog + ": 완료");
- }
- //다시 진행으로 보내줌
- config_change_progress();
- break;
- }
- default: break;
- }
- break;
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void CompleteProgress()
- {
- try
- {
- this.complete = true;
- progressBar1.Value = progressBar1.Maximum;
- btnOK.Enabled = true;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- this.Close();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void ListViewLogAdd(String msg)
- {
- try
- {
- int cnt = listView1.Items.Count;
- ListViewItem item = new ListViewItem(Convert.ToString(cnt + 1));
- item.SubItems.Add(msg);
- listView1.Items.Add(item);
- listView1.EnsureVisible(cnt);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnWinClose_Click(object sender, EventArgs e)
- {
- try
- {
- this.Close();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void CompleteProgress(bool closePopup, int time)// 2010.10.28, k.s.d, for self destroy popup.
- {
- try
- {
- this.complete = true;
- progressBar1.Value = progressBar1.Maximum;
- btnOK.Enabled = true;
- if (closePopup == true)
- {
- m_closetime_start = Environment.TickCount;
- m_closetime = time;
- timer_Close_Tick(null, EventArgs.Empty);
- timer_Close.Enabled = true;
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- int m_closetime_start = 0;
- int m_closetime = 0;
- private void timer_Close_Tick(object sender, EventArgs e)// 2010.10.28, k.s.d, for self destroy popup timer.
- {
- try
- {
- //m_closetime;
- if (m_closetime_start + m_closetime < Environment.TickCount)
- {
- this.Cursor = Cursors.Default;
- this.Close();
- }
- }
- catch (Exception ex)
- {
- this.Cursor = Cursors.Default;
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- }
- }
|