frmReceiverConfig.cs 252 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Collections;
  9. using Microsoft.Win32;
  10. using System.Diagnostics;
  11. namespace FPER
  12. {
  13. public partial class frmReceiverConfig : Form
  14. {
  15. Boolean ThisRedundant_Flag = true; //수신기 통신보드이중화
  16. QUERYMode cmd;
  17. //중계기 데이터 읽기 중복을 막기위해
  18. int savBoardID = -1;
  19. int savLoop = -1;
  20. MDIParent mdi = null;
  21. //Tooltip 설정 값...........
  22. IWin32Window window;
  23. //ToolTip tp;
  24. // cyim 2014.5.7 : 수신기설정정보 변경 (하단 주석처리하고 변수는 전역으로 처리한다)
  25. //수신기설정정보 변경여부
  26. //Boolean receiverConfig_Change_Flag = false;
  27. // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  28. private Boolean receiverConfig_Change_Flag = false;
  29. private Boolean ThisReceiverConfig_Change_Flag
  30. {
  31. get
  32. {
  33. // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  34. //return _frmReceiverConfig_Data.receiverConfig_Change_Flag;
  35. return receiverConfig_Change_Flag;
  36. }
  37. set
  38. {
  39. // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  40. //_frmReceiverConfig_Data.receiverConfig_Change_Flag = value;
  41. receiverConfig_Change_Flag = value;
  42. //if (_frmReceiverConfig_Data.receiverConfig_Change_Flag)
  43. if (receiverConfig_Change_Flag)
  44. {
  45. this.lblReceiverConfigChangeFlag.Text = "설정 변경됨! 반드시 모든 데이타 저장 버튼 실행하십시요!";
  46. this.lblReceiverConfigChangeFlag.Visible = true;
  47. }
  48. else
  49. {
  50. this.lblReceiverConfigChangeFlag.Visible = false;
  51. }
  52. }
  53. }
  54. //listview3의 선택 item
  55. ListViewItem IOBoard_selectItem;
  56. QUERYMode IOBoard_cmd;
  57. ListViewItem IOBoardDevice_selectItem;
  58. QUERYMode IOBoardDevice_cmd;
  59. //QUERYMode Keypad_cmd;
  60. public frmReceiverConfig()
  61. {
  62. InitializeComponent();
  63. // cyim 2013.7.10 디자인개선작업 : 수신기설정 -> 초반에는 무조건 수신기버튼을 누른것처럼 보이도록 한다
  64. this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  65. }
  66. public void Form_Init()
  67. {
  68. try
  69. {
  70. }
  71. catch (Exception ex)
  72. {
  73. Util.UErrorMessage(ex, 0, 0);
  74. //MessageBox.Show(ex.Message, Application.ProductName);
  75. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  76. }
  77. }
  78. private void frmTcpConfig_Load(object sender, EventArgs e)
  79. {
  80. // cyim 2013.8.1 : 더블버퍼링 적용
  81. SetStyle(ControlStyles.UserPaint, true);
  82. //this.UpdateStyles();
  83. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  84. //this.UpdateStyles();
  85. SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  86. this.UpdateStyles();
  87. try
  88. {
  89. mdi = (MDIParent)this.MdiParent;
  90. this.mdi.SelectMenuIndex = 2;
  91. this.Cursor = Cursors.WaitCursor;
  92. window = this;
  93. //tp = new ToolTip();
  94. txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
  95. /** 설정(수신기) 시작**/
  96. //VIEW모드로 변경한다.
  97. Util.GroupUIChange(groubReceiver, UIMode.cancel);
  98. //그룹의 데이터를 초기화한다.
  99. GroupReceiverData(null);
  100. //cboUse_Flag 에 item넣기
  101. Util.ComboSetting(cboUse_Flag, Util.useFlagArray(), null);
  102. Receiver_getData();
  103. /** 설정(수신기) 끝**/
  104. /** 설정(통신) 시작**/
  105. //VIEW모드로 변경한다.
  106. Util.GroupUIChange(groupComm1, UIMode.input);
  107. if (ThisRedundant_Flag) Util.GroupUIChange(groupComm2, UIMode.input); else Util.GroupUIChange(groupComm2, UIMode.cancel);
  108. Util.GroupUIChange(groupComm3, UIMode.input);
  109. Util.GroupUIChange(groupComm4, UIMode.input);
  110. Comm_Init();
  111. //통신설정 데이터 불러오기
  112. Comm_getData();
  113. /** 설정(통신) 끝**/
  114. /** 설정(통신보드) 시작**/
  115. Util.ComboSetting(cboBoardBaudRate, Util.baudRateArray(), null);
  116. //Util.ComboSetting(cboLoop0BaudRate, Util.baudRateArray(), null);
  117. //Util.ComboSetting(cboLoop1BaudRate, Util.baudRateArray(), null);
  118. //VIEW모드로 변경한다.
  119. Util.GroupUIChange(groubBoard, UIMode.cancel);
  120. //그룹의 데이터를 초기화한다.
  121. GroupBoardData(null);
  122. Board_getData();
  123. /** 설정(통신보드) 끝**/
  124. /** IO보드 시작**/
  125. Util.ComboSetting(cboIOBoardBaudRate, Util.baudRateArray(), null);
  126. //VIEW모드로 변경한다.
  127. Util.GroupUIChange(panelIOBoard, UIMode.cancel);
  128. //그룹의 데이터를 초기화한다.
  129. IOBoardSelectData(null);
  130. IOBoard_getData();
  131. IOBoardDevice_getData();
  132. /** IO보드 끝**/
  133. ///** KEYPAD 시작**/
  134. //Util.ComboSetting(cboKeypadBaudRate, Util.baudRateArray(), null);
  135. //////VIEW모드로 변경한다.
  136. //Util.GroupUIChange(panelKeypad, UIMode.cancel);
  137. //Keypad_getData();
  138. ///** KEYPAD 끝**/
  139. /** 설정(중계기) 시작**/
  140. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  141. ArrayList ary = dacBoardConfig.Board_List(mdi.myReceiverID, mdi);
  142. Util.ComboSetting(cboBoardList, ary, null);
  143. ////입력회로 설정 Hash저장
  144. //inputHash.Clear();
  145. //DacDeviceConfig dacDeviceConfig = new DacDeviceConfig();
  146. //DataTable dtable = dacDeviceConfig.Device_type_Select("I",null);
  147. //if (dtable.Rows.Count > 0)
  148. //{
  149. // foreach (DataRow dr in dtable.Rows)
  150. // {
  151. // //String cboText = dr["DEVICE_TYPE"].ToString() + "-" + dr["DEVICE_TYPE_NAME"].ToString();
  152. // String cboText = dr["DEVICE_TYPE_NAME"].ToString();
  153. // inputHash.Add(dr["DEVICE_TYPE"].ToString(), cboText);
  154. // }
  155. //}
  156. ////출력회로 설정 Hash저장
  157. //outputHash.Clear();
  158. //DataTable dtable2 = dacDeviceConfig.Device_type_Select("O",null);
  159. //if (dtable2.Rows.Count > 0)
  160. //{
  161. // foreach (DataRow dr2 in dtable2.Rows)
  162. // {
  163. // //String cboText = dr2["DEVICE_TYPE"].ToString() + "-" + dr2["DEVICE_TYPE_NAME"].ToString();
  164. // String cboText = dr2["DEVICE_TYPE_NAME"].ToString();
  165. // outputHash.Add(dr2["DEVICE_TYPE"].ToString(), cboText);
  166. // }
  167. //}
  168. Repeater_getDate();
  169. /** 설정(중계기) 끝**/
  170. this.Cursor = Cursors.Default;
  171. // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  172. // cyim 2014.5.7 : 수신기설정정보 변경
  173. //if (_frmReceiverConfig_Data.receiverConfig_Change_Flag)
  174. if (receiverConfig_Change_Flag)
  175. {
  176. this.lblReceiverConfigChangeFlag.Text = "설정 변경됨! 반드시 모든 데이타 저장 버튼 실행하십시요!";
  177. this.lblReceiverConfigChangeFlag.Visible = true;
  178. }
  179. else
  180. {
  181. this.lblReceiverConfigChangeFlag.Visible = false;
  182. }
  183. }
  184. catch (Exception ex)
  185. {
  186. Util.UErrorMessage(ex, 0, 0);
  187. }
  188. }
  189. private void frmTcpConfig_Activated(object sender, EventArgs e)
  190. {
  191. try
  192. {
  193. this.mdi.SelectMenuIndex = 2;
  194. }
  195. catch (Exception ex)
  196. {
  197. Util.UErrorMessage(ex, 0, 0);
  198. }
  199. }
  200. /******************************************************************************************************/
  201. /* 설정정보 리셋 */
  202. /******************************************************************************************************/
  203. private void frmTcpConfig_Disposed(object sender, EventArgs e)
  204. {
  205. try
  206. {
  207. //설정정보가 변경되었다면 다시 읽어라~~~~~~
  208. if (ThisReceiverConfig_Change_Flag)
  209. {
  210. this.Cursor = Cursors.WaitCursor;
  211. mdi.ui.ReceiverDBRead(); //설정정보 변경
  212. mdi.FireReset_Process(); //데몬 RESET 명령
  213. }
  214. this.mdi.SelectMenuIndex = 0;
  215. }
  216. catch (Exception ex)
  217. {
  218. Util.UErrorMessage(ex, 0, 0);
  219. //throw ex;
  220. //MessageBox.Show(ex.Message, Application.ProductName);
  221. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  222. }
  223. finally
  224. {
  225. this.Cursor = Cursors.Default;
  226. }
  227. }
  228. /******************************************************************************************************/
  229. /******************************************************************************************************/
  230. #region 수신기 데이터 콘트롤
  231. private void btnReceiverAdd_Click(object sender, EventArgs e)
  232. {
  233. try
  234. {
  235. //입력모드로 변경한다.
  236. Util.GroupUIChange(groubReceiver, UIMode.input);
  237. GroupReceiverData(null);
  238. cmd = QUERYMode.insert;
  239. DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  240. txtReceiverID.Text = dacReceiverConfig.ReceiverID_Max().ToString();
  241. txtReceiveName.Focus();
  242. btnReceiverAdd.Enabled = false;
  243. btnReceiverEdit.Enabled = false;
  244. btnReceiverDel.Enabled = false;
  245. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  246. this.panel_Menu.Focus();
  247. // cyim 2014.5.7 : 수신기설정정보 변경
  248. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  249. }
  250. catch (Exception ex)
  251. {
  252. Util.UErrorMessage(ex, 0, 0);
  253. }
  254. }
  255. //GroupBox에 자료 표시하기
  256. private void GroupReceiverData(ListViewItem itm)
  257. {
  258. try
  259. {
  260. if (itm == null)
  261. {
  262. txtReceiverID.Text = "";
  263. txtReceiveName.Text = "";
  264. cboUse_Flag.SelectedIndex = -1;
  265. txtIP_Address.Text = "";
  266. txtEvent_Port_No.Text = "";
  267. txtCommand_Port_No.Text = "";
  268. checkRedundant_Flag.Checked = false;
  269. btnReceiverEdit.Enabled = false;
  270. btnReceiverDel.Enabled = false;
  271. }
  272. else
  273. {
  274. txtReceiverID.Text = itm.Text;
  275. txtReceiveName.Text = itm.SubItems[1].Text;
  276. txtIP_Address.Text = itm.SubItems[2].Text;
  277. txtEvent_Port_No.Text = itm.SubItems[3].Text;
  278. txtCommand_Port_No.Text = itm.SubItems[4].Text;
  279. checkRedundant_Flag.Checked = (itm.SubItems[5].Text == "Y" ? true : false);
  280. cboUse_Flag.SelectedValue = itm.SubItems[6].Text;
  281. btnReceiverEdit.Enabled = true;
  282. btnReceiverDel.Enabled = true;
  283. }
  284. btnReceiverAdd.Enabled = true;
  285. }
  286. catch (Exception ex)
  287. {
  288. Util.UErrorMessage(ex, 0, 0);
  289. }
  290. }
  291. private void btnCancel_Click(object sender, EventArgs e)
  292. {
  293. try
  294. {
  295. //VIEW모드로 변경한다.
  296. Util.GroupUIChange(groubReceiver, UIMode.cancel);
  297. GroupReceiverData(null);
  298. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  299. this.panel_Menu.Focus();
  300. }
  301. catch (Exception ex)
  302. {
  303. Util.UErrorMessage(ex, 0, 0);
  304. }
  305. }
  306. private void btnReceiverEdit_Click(object sender, EventArgs e)
  307. {
  308. try
  309. {
  310. //입력모드로 변경한다.
  311. cmd = QUERYMode.update;
  312. Util.GroupUIChange(groubReceiver, UIMode.input);
  313. txtReceiverID.ReadOnly = true;
  314. btnReceiverAdd.Enabled = false;
  315. btnReceiverEdit.Enabled = false;
  316. btnReceiverDel.Enabled = false;
  317. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  318. this.panel_Menu.Focus();
  319. // cyim 2014.5.7 : 수신기설정정보 변경
  320. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  321. }
  322. catch (Exception ex)
  323. {
  324. Util.UErrorMessage(ex, 0, 0);
  325. }
  326. }
  327. /****
  328. * LISTVIEW에 데이터 불러오기
  329. *
  330. * ****/
  331. private void Receiver_getData()
  332. {
  333. try
  334. {
  335. DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  336. DataTable dt = dacReceiverConfig.Receiver_Select(null, null);
  337. listView1.Items.Clear();
  338. if (dt.Rows.Count > 0)
  339. {
  340. foreach (DataRow dr in dt.Rows)
  341. {
  342. int ReceiverId = int.Parse(Convert.ToString(dr[0]));
  343. if (ReceiverId == mdi.myReceiverID) this.ThisRedundant_Flag = Convert.ToString(dr[5]) == "Y" ? true : false;
  344. ListViewItem item = new ListViewItem(Convert.ToString(dr[0]));
  345. item.SubItems.Add(Convert.ToString(dr[1]));
  346. item.SubItems.Add(Convert.ToString(dr[2]));
  347. item.SubItems.Add(Convert.ToString(dr[3]));
  348. item.SubItems.Add(Convert.ToString(dr[4]));
  349. item.SubItems.Add(Convert.ToString(dr[5]));
  350. item.SubItems.Add(Convert.ToString(dr[6]));
  351. //item.SubItems.Add(""); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 리스트에 '상태' 컬럼은 필요없다
  352. listView1.Items.Add(item);
  353. }
  354. }
  355. }
  356. catch (Exception ex)
  357. {
  358. Util.UErrorMessage(ex, 0, 0);
  359. //MessageBox.Show(ex.Message, Application.ProductName);
  360. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  361. }
  362. }
  363. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  364. {
  365. try
  366. {
  367. ListView lv = (ListView)sender;
  368. if (lv.SelectedItems.Count > 0)
  369. {
  370. ListViewItem itm = lv.SelectedItems[0];
  371. //VIEW모드로 변경한다.
  372. Util.GroupUIChange(groubReceiver, UIMode.cancel);
  373. GroupReceiverData(itm);
  374. }
  375. else
  376. {
  377. //VIEW모드로 변경한다.
  378. Util.GroupUIChange(groubReceiver, UIMode.cancel);
  379. GroupReceiverData(null);
  380. }
  381. }
  382. catch (Exception ex)
  383. {
  384. Util.UErrorMessage(ex, 0, 0);
  385. //MessageBox.Show(ex.Message, Application.ProductName);
  386. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  387. }
  388. }
  389. private void listView1_Click(object sender, EventArgs e)
  390. {
  391. try
  392. {
  393. listView1_SelectedIndexChanged(listView1, System.EventArgs.Empty);
  394. }
  395. catch (Exception ex)
  396. {
  397. Util.UErrorMessage(ex, 0, 0);
  398. }
  399. }
  400. private void btnReceiverDel_Click(object sender, EventArgs e)
  401. {
  402. try
  403. {
  404. cmd = QUERYMode.delete;
  405. String ReceiverID = txtReceiverID.Text.Trim();
  406. String ReceiveName = txtReceiveName.Text.Trim();
  407. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", ReceiveName, ReceiverID);
  408. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  409. {
  410. DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  411. dacReceiverConfig.Receiver_Update(cmd, ReceiverID, null, null, null, null, null, null);
  412. }
  413. //VIEW모드로 변경한다.
  414. Util.GroupUIChange(groubReceiver, UIMode.cancel);
  415. //수신기정보 입력 CLEAR
  416. GroupReceiverData(null);
  417. //데이터 불러오기
  418. Receiver_getData();
  419. //수신기리스트 콤보에 넣기
  420. //ComboReceiverList(mdi.MyReceiverId);
  421. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  422. this.panel_Menu.Focus();
  423. // cyim 2014.5.7 : 수신기설정정보 변경
  424. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  425. }
  426. catch (Exception ex)
  427. {
  428. Util.UErrorMessage(ex, 0, 0);
  429. //MessageBox.Show(ex.Message, Application.ProductName);
  430. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  431. }
  432. }
  433. // 하위 루틴은 실제로 사용안함 (삭제 예정)
  434. private void btnSaveOK_Click(object sender, EventArgs e)
  435. {
  436. try
  437. {
  438. if (cmd == QUERYMode.insert || cmd == QUERYMode.update)
  439. {
  440. Util.ChkTxtBox(txtReceiverID, "수신기ID");
  441. Util.ChkTxtBox(txtReceiveName, "수신기명");
  442. Util.ChkTxtBox(txtIP_Address, "연결 IP");
  443. Util.ChkTxtBox(txtEvent_Port_No, "이벤트 PORT");
  444. Util.ChkTxtBox(txtCommand_Port_No, "명령 PORT");
  445. Util.ChkComboBox(cboUse_Flag, "사용여부");
  446. String ReceiverID = txtReceiverID.Text.Trim();
  447. String ReceiveName = txtReceiveName.Text.Trim();
  448. String Use_Flag = cboUse_Flag.SelectedValue == null ? "" : cboUse_Flag.SelectedValue.ToString();
  449. String Redundant_Flag = (checkRedundant_Flag.Checked ? "Y" : "N");
  450. String IP_Address = txtIP_Address.Text.Trim();
  451. String Event_Port_No = txtEvent_Port_No.Text.Trim();
  452. String Command_Port_No = txtCommand_Port_No.Text.Trim();
  453. this.ThisRedundant_Flag = Redundant_Flag == "Y" ? true : false;
  454. if (ThisRedundant_Flag) Util.GroupUIChange(groupComm2, UIMode.input); else Util.GroupUIChange(groupComm2, UIMode.cancel);
  455. if (!Util.onlyLiteral(ReceiverID)) throw new Exception("수신기ID는 숫자형만 입력해 주세요.");
  456. DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  457. dacReceiverConfig.Receiver_Update(cmd, ReceiverID, ReceiveName, IP_Address, Event_Port_No, Command_Port_No, Redundant_Flag, Use_Flag);
  458. //수신기설정을 할때 기본으로 생성되어야 할 데이터를 저장한다..
  459. if (int.Parse(ReceiverID) == this.mdi.myReceiverID)
  460. {
  461. DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  462. dacIOBoardConfig.Board_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, "IO보드15번(기본)", "Y", "Y", "N", 0, 0, 0, 0, 0);
  463. DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID);
  464. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 1, code_InOutType.Input, "발신기", null, null);
  465. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 2, code_InOutType.Input, "전화", null, null);
  466. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 3, code_InOutType.Input, "교류전원", null, null);
  467. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 4, code_InOutType.Input, "예비전원이상", null, null);
  468. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 5, code_InOutType.Input, "출력전압", null, null);
  469. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 1, code_InOutType.Output, "표시등", null, null);
  470. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 2, code_InOutType.Output, "유도등", null, null);
  471. dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 3, code_InOutType.Output, "전원릴레이", null, null);
  472. DacKeypadConfig dacKeypadConfig = new DacKeypadConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  473. dacKeypadConfig.Keypad_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, "키패드(기본)", "Y", 0, 0, 0);
  474. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 0, code_InOutType.Input, "비상 방송 정지", null, null);
  475. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Input, "지구 경종 정지", null, null);
  476. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Input, "주음향 정지", null, null);
  477. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Input, "화면 좌표 설정", null, null);
  478. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Input, "예비 전원 시험", null, null);
  479. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Input, "설비연동 화면", null, null);
  480. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Input, "화재 복구", null, null);
  481. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Input, "부저 정지", null, null);
  482. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Input, "주음향 정지", null, null);
  483. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Input, "지구 경종 정지", null, null);
  484. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Input, "비상 방송 정지", null, null);
  485. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Input, "화면 좌표 설정", null, null);
  486. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Input, "부저 정지", null, null);
  487. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Input, "설비연동 화면", null, null);
  488. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Input, "화재 복구", null, null);
  489. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 8, code_InOutType.Input, "예비 전원 시험", null, null);
  490. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Output, "화재 LED", null, null);
  491. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Output, "발신기 LED", null, null);
  492. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Output, "교류 전원 LED", null, null);
  493. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Output, "예비 전원 이상 LED", null, null);
  494. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Output, "전화 LED", null, null);
  495. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Output, "통신상태 LED", null, null);
  496. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Output, "축적 LED", null, null);
  497. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 8, code_InOutType.Output, "회로 점검 LED", null, null);
  498. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 9, code_InOutType.Output, "설비 작동 LED", null, null);
  499. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 10, code_InOutType.Output, "비상 방송 정지 LED", null, null);
  500. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 11, code_InOutType.Output, "지구 음향 정지 LED", null, null);
  501. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 12, code_InOutType.Output, "주음향 정지 LED", null, null);
  502. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 13, code_InOutType.Output, "부저정지 LED", null, null);
  503. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 15, code_InOutType.Output, "예비 전원 시험 LED", null, null);
  504. //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 14, code_InOutType.Output, "설비연동화면 LED", null, null);
  505. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 16, code_InOutType.Output, "주음향 부저", null, null);
  506. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 17, code_InOutType.Output, "Fault 부저", null, null);
  507. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 18, code_InOutType.Output, "전화 부저", null, null);
  508. dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 19, code_InOutType.Output, "설비 부저", null, null);
  509. DacBoardConfig dacBoardConfig = new DacBoardConfig(this.mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  510. if (cmd == QUERYMode.insert)
  511. {
  512. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  513. int boardID_init = 0;
  514. int boardID_cnt = 0;
  515. // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
  516. if (mdi.ReceiverModel == "IFC3300")
  517. {
  518. boardID_init = 1;
  519. boardID_cnt = 64;
  520. }
  521. else
  522. {
  523. boardID_init = 1;
  524. boardID_cnt = 16;
  525. }
  526. // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
  527. for (int i = boardID_init; i <= boardID_cnt; i++)
  528. {
  529. // cyim 2016.10.31 : 대용량 수신기용 UI 변경
  530. dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, i, string.Format("통신보드{0}", i)
  531. , "N", "N", "N", "N", "N", 7, 7, 7, 7, 7, 0, 0);
  532. }
  533. }
  534. try
  535. {
  536. //통신연결 설정값을 다시 읽어서 접속한다.
  537. this.mdi.ui.SocketConfigRead();
  538. this.mdi.ui.ServiceStop();
  539. this.mdi.ui.ServiceStart();
  540. }
  541. catch (Exception ex)
  542. {
  543. Util.UErrorMessage(ex, 0, 0);
  544. //MessageBox.Show(ex.Message, Application.ProductName);
  545. }
  546. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  547. this.panel_Menu.Focus();
  548. }
  549. }
  550. //VIEW모드로 변경한다.
  551. Util.GroupUIChange(groubReceiver, UIMode.cancel);
  552. //데이터 불러오기
  553. Receiver_getData();
  554. //수신기리스트 콤보에 넣기
  555. //ComboReceiverList(mdi.myReceiverID);
  556. GroupReceiverData(null);
  557. }
  558. catch (Exception ex)
  559. {
  560. Util.UErrorMessage(ex, 0, 0);
  561. //MessageBox.Show(ex.Message, Application.ProductName);
  562. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  563. }
  564. }
  565. #endregion
  566. /******************************************************************************************************/
  567. /******************************************************************************************************/
  568. #region 통신설정 데이터 콘트롤
  569. private void Comm_Init()
  570. {
  571. //try
  572. {
  573. ArrayList comport1 = Util.ArrayComport();
  574. ArrayList comport2 = Util.ArrayComport();
  575. ArrayList comport3 = Util.ArrayComport();
  576. ArrayList comport4 = Util.ArrayComport();
  577. ArrayList comport5 = Util.ArrayComport(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  578. ArrayList speed1 = Util.ArraySpeed();
  579. ArrayList speed2 = Util.ArraySpeed();
  580. ArrayList speed3 = Util.ArraySpeed();
  581. ArrayList speed4 = Util.ArraySpeed();
  582. ArrayList speed5 = Util.ArraySpeed(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  583. ArrayList databit1 = Util.ArrayDatabit();
  584. ArrayList databit2 = Util.ArrayDatabit();
  585. ArrayList databit3 = Util.ArrayDatabit();
  586. ArrayList databit4 = Util.ArrayDatabit();
  587. ArrayList databit5 = Util.ArrayDatabit(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  588. ArrayList stopbit1 = Util.ArrayStopbit();
  589. ArrayList stopbit2 = Util.ArrayStopbit();
  590. ArrayList stopbit3 = Util.ArrayStopbit();
  591. ArrayList stopbit4 = Util.ArrayStopbit();
  592. ArrayList stopbit5 = Util.ArrayStopbit(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  593. ArrayList parity1 = Util.ArrayParity();
  594. ArrayList parity2 = Util.ArrayParity();
  595. ArrayList parity3 = Util.ArrayParity();
  596. ArrayList parity4 = Util.ArrayParity();
  597. ArrayList parity5 = Util.ArrayParity(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  598. Util.ComboSetting(cboSpeed1, speed1, "115200");
  599. Util.ComboSetting(cboSpeed2, speed2, "115200");
  600. Util.ComboSetting(cboSpeed3, speed3, "115200");
  601. Util.ComboSetting(cboSpeed4, speed4, "115200");
  602. Util.ComboSetting(cboSpeed5, speed5, "115200"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  603. Util.ComboSetting(cboDataBit1, databit1, "7");
  604. Util.ComboSetting(cboDataBit2, databit2, "7");
  605. Util.ComboSetting(cboDataBit3, databit3, "7");
  606. Util.ComboSetting(cboDataBit4, databit4, "7");
  607. Util.ComboSetting(cboDataBit5, databit5, "7"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  608. Util.ComboSetting(cboStopBit1, stopbit1, "1");
  609. Util.ComboSetting(cboStopBit2, stopbit2, "1");
  610. Util.ComboSetting(cboStopBit3, stopbit3, "1");
  611. Util.ComboSetting(cboStopBit4, stopbit4, "1");
  612. Util.ComboSetting(cboStopBit5, stopbit5, "1"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  613. Util.ComboSetting(cboParity1, parity1, "N");
  614. Util.ComboSetting(cboParity2, parity2, "N");
  615. Util.ComboSetting(cboParity3, parity3, "N");
  616. Util.ComboSetting(cboParity4, parity4, "N");
  617. Util.ComboSetting(cboParity5, parity5, "N"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  618. Util.ComboSetting(cboComPort1, comport1, null);
  619. Util.ComboSetting(cboComPort2, comport2, null);
  620. Util.ComboSetting(cboComPort3, comport3, null);
  621. Util.ComboSetting(cboComPort4, comport4, null);
  622. Util.ComboSetting(cboComPort5, comport5, null); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  623. //기본값 설정
  624. int DelayInit = 200;
  625. int TimeOutInit = 3000;
  626. txtCommDelay1.Text = DelayInit.ToString();
  627. txtCommTimeOut1.Text = TimeOutInit.ToString();
  628. //txtIpAddress1.Text = "";
  629. //txtPort1.Text = "";
  630. //txtDelay1.Text = "";
  631. //txtTimeOut1.Text = "";
  632. tabControl1.SelectedIndex = 0;
  633. txtCommDelay2.Text = DelayInit.ToString();
  634. txtCommTimeOut2.Text = TimeOutInit.ToString();
  635. //txtIpAddress2.Text = "";
  636. //txtPort2.Text = "";
  637. //txtDelay2.Text = "";
  638. //txtTimeOut2.Text = "";
  639. txtCommDelay3.Text = DelayInit.ToString();
  640. txtCommTimeOut3.Text = TimeOutInit.ToString();
  641. //txtIpAddress3.Text = "";
  642. //txtPort3.Text = "";
  643. //txtDelay3.Text = "";
  644. //txtTimeOut3.Text = "";
  645. //키패드 기본
  646. txtCommDelay4.Text = "50";
  647. txtCommTimeOut4.Text = "1000";
  648. //txtIpAddress4.Text = "";
  649. //txtPort4.Text = "";
  650. //txtDelay4.Text = "";
  651. //txtTimeOut4.Text = "";
  652. // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  653. txtCommDelay5.Text = DelayInit.ToString();
  654. txtCommTimeOut5.Text = TimeOutInit.ToString();
  655. //사용안함으로 통신설정값을 초기화한다.
  656. CommFlagChage(1, "N", "N");
  657. CommFlagChage(2, "N", "N");
  658. CommFlagChage(3, "N", "N");
  659. CommFlagChage(4, "N", "N");
  660. CommFlagChage(5, "N", "N"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  661. chkCommUseFlag1.Checked = false;
  662. chkCommUseFlag2.Checked = false;
  663. chkCommUseFlag3.Checked = false;
  664. chkCommUseFlag4.Checked = false;
  665. chkCommUseFlag5.Checked = false; // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정
  666. }
  667. //catch (Exception ex)
  668. //{
  669. // Util.UErrorMessage(ex, 0, 0);
  670. // throw ex;
  671. //}
  672. }
  673. /****
  674. *통신설정 데이터 불러오기
  675. *
  676. * ****/
  677. private void Comm_getData()
  678. {
  679. try
  680. {
  681. DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  682. DataTable dt = dacCommConfig.Comm_Select(mdi.myReceiverID, 0, null);
  683. if (dt.Rows.Count > 0)
  684. {
  685. foreach (DataRow dr in dt.Rows)
  686. {
  687. COMMLOOP commloop = (COMMLOOP)Enum.Parse(typeof(COMMLOOP), dr["COMM_LOOP"].ToString());
  688. String typ = dr["COMM_TYPE"].ToString();
  689. if (commloop == COMMLOOP.FrontLoop)
  690. {
  691. chkCommUseFlag1.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;
  692. chkCommUseFlag1.CheckState = dr["USE_FLAG"].ToString() == "Y" ? CheckState.Checked : CheckState.Unchecked; ;
  693. chkLogFlag1.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;
  694. txtCommTimeOut1.Text = dr["COMM_TIMEOUT"].ToString();
  695. txtCommDelay1.Text = dr["COMM_DELAY"].ToString();
  696. //txtTimeOut1.Text = dr["COMM_TIMEOUT"].ToString();
  697. //txtDelay1.Text = dr["COMM_DELAY"].ToString();
  698. chkCommRs485_1.Checked = typ.Equals("R") ? true : false;
  699. if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R
  700. {
  701. cboComPort1.SelectedValue = dr["COMM_PORT"].ToString();
  702. cboSpeed1.SelectedValue = dr["BAUD_RATE"].ToString();
  703. cboDataBit1.SelectedValue = dr["DATA_BITS"].ToString();
  704. cboParity1.SelectedValue = dr["PARITY"].ToString();
  705. cboStopBit1.SelectedValue = dr["STOP_BITS"].ToString();
  706. tabControl1.SelectedIndex = 0;
  707. }
  708. else
  709. {
  710. //txtIpAddress1.Text = dr["IP_ADDRESS"].ToString();
  711. //txtPort1.Text = dr["PORT_NO"].ToString();
  712. tabControl1.SelectedIndex = 1;
  713. }
  714. CommFlagChage(1, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());
  715. }
  716. else if (commloop == COMMLOOP.BackLoop)
  717. {
  718. chkCommUseFlag2.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;
  719. chkLogFlag2.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;
  720. txtCommTimeOut2.Text = dr["COMM_TIMEOUT"].ToString();
  721. txtCommDelay2.Text = dr["COMM_DELAY"].ToString();
  722. //txtTimeOut2.Text = dr["COMM_TIMEOUT"].ToString();
  723. //txtDelay2.Text = dr["COMM_DELAY"].ToString();
  724. chkCommRs485_2.Checked = typ.Equals("R") ? true : false;
  725. if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R
  726. {
  727. cboComPort2.SelectedValue = dr["COMM_PORT"].ToString();
  728. cboSpeed2.SelectedValue = dr["BAUD_RATE"].ToString();
  729. cboDataBit2.SelectedValue = dr["DATA_BITS"].ToString();
  730. cboParity2.SelectedValue = dr["PARITY"].ToString();
  731. cboStopBit2.SelectedValue = dr["STOP_BITS"].ToString();
  732. tabControl2.SelectedIndex = 0;
  733. }
  734. else
  735. {
  736. //txtIpAddress2.Text = dr["IP_ADDRESS"].ToString();
  737. //txtPort2.Text = dr["PORT_NO"].ToString();
  738. tabControl2.SelectedIndex = 1;
  739. }
  740. CommFlagChage(2, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());
  741. }
  742. else if (commloop == COMMLOOP.IO)
  743. {
  744. chkCommUseFlag3.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;
  745. chkLogFlag3.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;
  746. txtCommTimeOut3.Text = dr["COMM_TIMEOUT"].ToString();
  747. txtCommDelay3.Text = dr["COMM_DELAY"].ToString();
  748. //txtTimeOut3.Text = dr["COMM_TIMEOUT"].ToString();
  749. //txtDelay3.Text = dr["COMM_DELAY"].ToString();
  750. chkCommRs485_3.Checked = typ.Equals("R") ? true : false;
  751. if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R
  752. {
  753. cboComPort3.SelectedValue = dr["COMM_PORT"].ToString();
  754. cboSpeed3.SelectedValue = dr["BAUD_RATE"].ToString();
  755. cboDataBit3.SelectedValue = dr["DATA_BITS"].ToString();
  756. cboParity3.SelectedValue = dr["PARITY"].ToString();
  757. cboStopBit3.SelectedValue = dr["STOP_BITS"].ToString();
  758. tabControl3.SelectedIndex = 0;
  759. }
  760. else
  761. {
  762. //txtIpAddress3.Text = dr["IP_ADDRESS"].ToString();
  763. //txtPort3.Text = dr["PORT_NO"].ToString();
  764. tabControl3.SelectedIndex = 1;
  765. }
  766. CommFlagChage(3, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());
  767. }
  768. else if (commloop == COMMLOOP.KEYPAD)
  769. {
  770. chkCommUseFlag4.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;
  771. chkLogFlag4.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;
  772. txtCommTimeOut4.Text = dr["COMM_TIMEOUT"].ToString();
  773. txtCommDelay4.Text = dr["COMM_DELAY"].ToString();
  774. //txtTimeOut4.Text = dr["COMM_TIMEOUT"].ToString();
  775. //txtDelay4.Text = dr["COMM_DELAY"].ToString();
  776. chkCommRs485_4.Checked = typ.Equals("R") ? true : false;
  777. if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R
  778. {
  779. cboComPort4.SelectedValue = dr["COMM_PORT"].ToString();
  780. cboSpeed4.SelectedValue = dr["BAUD_RATE"].ToString();
  781. cboDataBit4.SelectedValue = dr["DATA_BITS"].ToString();
  782. cboParity4.SelectedValue = dr["PARITY"].ToString();
  783. cboStopBit4.SelectedValue = dr["STOP_BITS"].ToString();
  784. tabControl4.SelectedIndex = 0;
  785. }
  786. else
  787. {
  788. //txtIpAddress4.Text = dr["IP_ADDRESS"].ToString();
  789. //txtPort4.Text = dr["PORT_NO"].ToString();
  790. tabControl4.SelectedIndex = 1;
  791. }
  792. CommFlagChage(4, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());
  793. }
  794. // cyim 2013.7.10 디자인개선작업 : 수신기설정
  795. else if (commloop == COMMLOOP.BroadCast)
  796. {
  797. chkCommUseFlag5.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;
  798. chkLogFlag5.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;
  799. txtCommTimeOut5.Text = dr["COMM_TIMEOUT"].ToString();
  800. txtCommDelay5.Text = dr["COMM_DELAY"].ToString();
  801. //txtTimeOut4.Text = dr["COMM_TIMEOUT"].ToString();
  802. //txtDelay4.Text = dr["COMM_DELAY"].ToString();
  803. chkCommRs485_5.Checked = typ.Equals("R") ? true : false;
  804. if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R
  805. {
  806. cboComPort5.SelectedValue = dr["COMM_PORT"].ToString();
  807. cboSpeed5.SelectedValue = dr["BAUD_RATE"].ToString();
  808. cboDataBit5.SelectedValue = dr["DATA_BITS"].ToString();
  809. cboParity5.SelectedValue = dr["PARITY"].ToString();
  810. cboStopBit5.SelectedValue = dr["STOP_BITS"].ToString();
  811. tabControl5.SelectedIndex = 0;
  812. }
  813. else
  814. {
  815. //txtIpAddress4.Text = dr["IP_ADDRESS"].ToString();
  816. //txtPort4.Text = dr["PORT_NO"].ToString();
  817. tabControl5.SelectedIndex = 1;
  818. }
  819. CommFlagChage(5, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());
  820. }
  821. }
  822. }
  823. }
  824. catch (Exception ex)
  825. {
  826. Util.UErrorMessage(ex, 0, 0);
  827. //MessageBox.Show(ex.Message, Application.ProductName);
  828. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  829. }
  830. }
  831. private void btnCommOK1_Click(object sender, EventArgs e)
  832. {
  833. try
  834. {
  835. if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  836. {
  837. cmd = QUERYMode.InsertAndUpdate;
  838. Util.ChkComboBox(cboComPort1, "포트");
  839. Util.ChkComboBox(cboDataBit1, "데이터비트");
  840. Util.ChkComboBox(cboStopBit1, "정지비트");
  841. Util.ChkComboBox(cboSpeed1, "최대속도");
  842. Util.ChkComboBox(cboParity1, "패리티");
  843. Util.ChkTxtBox(txtCommDelay1, "Delay");
  844. Util.ChkTxtBox(txtCommTimeOut1, "Time Out");
  845. String ComPort = cboComPort1.SelectedValue.ToString();
  846. String DataBit = cboDataBit1.SelectedValue.ToString();
  847. String StopBit = cboStopBit1.SelectedValue.ToString();
  848. String Speed = cboSpeed1.SelectedValue.ToString();
  849. String Parity = cboParity1.SelectedValue.ToString();
  850. String CommTimeOut = txtCommTimeOut1.Text.Trim();
  851. String Delay = txtCommDelay1.Text.Trim();
  852. String UseFlag = chkCommUseFlag1.Checked ? "Y" : "N";
  853. String LogFlag = chkLogFlag1.Checked ? "Y" : "N";
  854. if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  855. if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  856. string typ = chkCommRs485_1.Checked ? "R" : "C";
  857. DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  858. dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.FrontLoop, "FRONT LOOP", COMMLOOP.FrontLoop, typ
  859. , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);
  860. //수신기설정정보 변경
  861. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  862. MessageBox.Show("FRONT LOOP 통신설정값을 저장하였습니다.", Application.ProductName);
  863. //VIEW모드로 변경한다.
  864. //Util.GroupUIChange(groupComm1, UIMode.cancel);
  865. //데이터 불러오기
  866. //Comm_getData();
  867. //수신기리스트 콤보에 넣기
  868. //ComboReceiverList(mdi.myReceiverID);
  869. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  870. this.panel_Menu.Focus();
  871. // cyim 2014.5.7 : 수신기설정정보 변경
  872. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  873. }
  874. }
  875. catch (Exception ex)
  876. {
  877. Util.UErrorMessage(ex, 0, 0);
  878. //MessageBox.Show(ex.Message, Application.ProductName);
  879. }
  880. }
  881. private void btnCommOK2_Click(object sender, EventArgs e)
  882. {
  883. try
  884. {
  885. if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  886. {
  887. cmd = QUERYMode.InsertAndUpdate;
  888. Util.ChkComboBox(cboComPort2, "포트");
  889. Util.ChkComboBox(cboDataBit2, "데이터비트");
  890. Util.ChkComboBox(cboStopBit2, "정지비트");
  891. Util.ChkComboBox(cboSpeed2, "최대속도");
  892. Util.ChkComboBox(cboParity2, "패리티");
  893. Util.ChkTxtBox(txtCommDelay2, "Delay");
  894. Util.ChkTxtBox(txtCommTimeOut2, "Time Out");
  895. String ComPort = cboComPort2.SelectedValue.ToString();
  896. String DataBit = cboDataBit2.SelectedValue.ToString();
  897. String StopBit = cboStopBit2.SelectedValue.ToString();
  898. String Speed = cboSpeed2.SelectedValue.ToString();
  899. String Parity = cboParity2.SelectedValue.ToString();
  900. String CommTimeOut = txtCommTimeOut2.Text.Trim();
  901. String Delay = txtCommDelay2.Text.Trim();
  902. String UseFlag = chkCommUseFlag2.Checked ? "Y" : "N";
  903. String LogFlag = chkLogFlag2.Checked ? "Y" : "N";
  904. string typ = chkCommRs485_2.Checked ? "R" : "C";
  905. if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  906. if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  907. DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  908. dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BackLoop, "BACK LOOP", COMMLOOP.BackLoop, typ
  909. , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);
  910. //수신기설정정보 변경
  911. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  912. MessageBox.Show("BACK LOOP 통신설정값을 저장하였습니다.", Application.ProductName);
  913. //VIEW모드로 변경한다.
  914. //Util.GroupUIChange(groupComm2, UIMode.cancel);
  915. //데이터 불러오기
  916. //Comm_getData();
  917. //수신기리스트 콤보에 넣기
  918. //ComboReceiverList(mdi.myReceiverID);
  919. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  920. this.panel_Menu.Focus();
  921. // cyim 2014.5.7 : 수신기설정정보 변경
  922. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  923. }
  924. }
  925. catch (Exception ex)
  926. {
  927. Util.UErrorMessage(ex, 0, 0);
  928. //MessageBox.Show(ex.Message, Application.ProductName);
  929. }
  930. }
  931. private void btnCommOK3_Click(object sender, EventArgs e)
  932. {
  933. try
  934. {
  935. if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  936. {
  937. cmd = QUERYMode.InsertAndUpdate;
  938. Util.ChkComboBox(cboComPort3, "포트");
  939. Util.ChkComboBox(cboDataBit3, "데이터비트");
  940. Util.ChkComboBox(cboStopBit3, "정지비트");
  941. Util.ChkComboBox(cboSpeed3, "최대속도");
  942. Util.ChkComboBox(cboParity3, "패리티");
  943. Util.ChkTxtBox(txtCommDelay3, "Delay");
  944. Util.ChkTxtBox(txtCommTimeOut3, "Time Out");
  945. String ComPort = cboComPort3.SelectedValue.ToString();
  946. String DataBit = cboDataBit3.SelectedValue.ToString();
  947. String StopBit = cboStopBit3.SelectedValue.ToString();
  948. String Speed = cboSpeed3.SelectedValue.ToString();
  949. String Parity = cboParity3.SelectedValue.ToString();
  950. String CommTimeOut = txtCommTimeOut3.Text.Trim();
  951. String Delay = txtCommDelay3.Text.Trim();
  952. String UseFlag = chkCommUseFlag3.Checked ? "Y" : "N";
  953. String LogFlag = chkLogFlag3.Checked ? "Y" : "N";
  954. string typ = chkCommRs485_3.Checked ? "R" : "C";
  955. if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  956. if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  957. DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  958. dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.IO, "IO BOARD", COMMLOOP.IO, typ
  959. , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);
  960. //수신기설정정보 변경
  961. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  962. MessageBox.Show("IO BOARD 통신설정값을 저장하였습니다.", Application.ProductName);
  963. //VIEW모드로 변경한다.
  964. //Util.GroupUIChange(groupComm2, UIMode.cancel);
  965. //데이터 불러오기
  966. //Comm_getData();
  967. //수신기리스트 콤보에 넣기
  968. //ComboReceiverList(mdi.myReceiverID);
  969. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  970. this.panel_Menu.Focus();
  971. // cyim 2014.5.7 : 수신기설정정보 변경
  972. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  973. }
  974. }
  975. catch (Exception ex)
  976. {
  977. Util.UErrorMessage(ex, 0, 0);
  978. //MessageBox.Show(ex.Message, Application.ProductName);
  979. }
  980. }
  981. private void btnCommOK4_Click(object sender, EventArgs e)
  982. {
  983. try
  984. {
  985. if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  986. {
  987. cmd = QUERYMode.InsertAndUpdate;
  988. Util.ChkComboBox(cboComPort4, "포트");
  989. Util.ChkComboBox(cboDataBit4, "데이터비트");
  990. Util.ChkComboBox(cboStopBit4, "정지비트");
  991. Util.ChkComboBox(cboSpeed4, "최대속도");
  992. Util.ChkComboBox(cboParity4, "패리티");
  993. Util.ChkTxtBox(txtCommDelay4, "Delay");
  994. Util.ChkTxtBox(txtCommTimeOut4, "Time Out");
  995. String ComPort = cboComPort4.SelectedValue.ToString();
  996. String DataBit = cboDataBit4.SelectedValue.ToString();
  997. String StopBit = cboStopBit4.SelectedValue.ToString();
  998. String Speed = cboSpeed4.SelectedValue.ToString();
  999. String Parity = cboParity4.SelectedValue.ToString();
  1000. String CommTimeOut = txtCommTimeOut4.Text.Trim();
  1001. String Delay = txtCommDelay4.Text.Trim();
  1002. String UseFlag = chkCommUseFlag4.Checked ? "Y" : "N";
  1003. String LogFlag = chkLogFlag4.Checked ? "Y" : "N";
  1004. string typ = chkCommRs485_4.Checked ? "R" : "C";
  1005. if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  1006. if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  1007. DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1008. dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.KEYPAD, "KEYPAD", COMMLOOP.KEYPAD, typ
  1009. , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);
  1010. //수신기설정정보 변경
  1011. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1012. MessageBox.Show("KEYPAD 통신설정값을 저장하였습니다.", Application.ProductName);
  1013. //VIEW모드로 변경한다.
  1014. //Util.GroupUIChange(groupComm2, UIMode.cancel);
  1015. //데이터 불러오기
  1016. //Comm_getData();
  1017. //수신기리스트 콤보에 넣기
  1018. //ComboReceiverList(mdi.myReceiverID);
  1019. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  1020. this.panel_Menu.Focus();
  1021. // cyim 2014.5.7 : 수신기설정정보 변경
  1022. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1023. }
  1024. }
  1025. catch (Exception ex)
  1026. {
  1027. Util.UErrorMessage(ex, 0, 0);
  1028. //MessageBox.Show(ex.Message, Application.ProductName);
  1029. }
  1030. }
  1031. // EMERGENCY - 확인 버튼
  1032. private void btnCommOK5_Click(object sender, EventArgs e)
  1033. {
  1034. try
  1035. {
  1036. if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  1037. {
  1038. cmd = QUERYMode.InsertAndUpdate;
  1039. Util.ChkComboBox(cboComPort5, "포트");
  1040. Util.ChkComboBox(cboDataBit5, "데이터비트");
  1041. Util.ChkComboBox(cboStopBit5, "정지비트");
  1042. Util.ChkComboBox(cboSpeed5, "최대속도");
  1043. Util.ChkComboBox(cboParity5, "패리티");
  1044. Util.ChkTxtBox(txtCommDelay5, "Delay");
  1045. Util.ChkTxtBox(txtCommTimeOut5, "Time Out");
  1046. String ComPort = cboComPort5.SelectedValue.ToString();
  1047. String DataBit = cboDataBit5.SelectedValue.ToString();
  1048. String StopBit = cboStopBit5.SelectedValue.ToString();
  1049. String Speed = cboSpeed5.SelectedValue.ToString();
  1050. String Parity = cboParity5.SelectedValue.ToString();
  1051. String CommTimeOut = txtCommTimeOut5.Text.Trim();
  1052. String Delay = txtCommDelay5.Text.Trim();
  1053. String UseFlag = chkCommUseFlag5.Checked ? "Y" : "N";
  1054. String LogFlag = chkLogFlag5.Checked ? "Y" : "N";
  1055. string typ = chkCommRs485_5.Checked ? "R" : "C";
  1056. if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  1057. if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  1058. DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1059. dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BroadCast, "BroadCast", COMMLOOP.BroadCast, typ
  1060. , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);
  1061. //수신기설정정보 변경
  1062. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1063. MessageBox.Show("비상방송 통신설정값을 저장하였습니다.", Application.ProductName);
  1064. //VIEW모드로 변경한다.
  1065. //Util.GroupUIChange(groupComm2, UIMode.cancel);
  1066. //데이터 불러오기
  1067. //Comm_getData();
  1068. //수신기리스트 콤보에 넣기
  1069. //ComboReceiverList(mdi.myReceiverID);
  1070. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  1071. this.panel_Menu.Focus();
  1072. // cyim 2014.5.7 : 수신기설정정보 변경
  1073. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1074. }
  1075. }
  1076. catch (Exception ex)
  1077. {
  1078. Util.UErrorMessage(ex, 0, 0);
  1079. //MessageBox.Show(ex.Message, Application.ProductName);
  1080. }
  1081. }
  1082. private void CommFlagChage(int Comm_ID, String LogFlag, String UseFlag)
  1083. {
  1084. try
  1085. {
  1086. UIMode mode = UseFlag == "Y" ? UIMode.input : UIMode.cancel;
  1087. GroupBox group = (GroupBox)Util.FineControl(tabPage_CommSet, "groupComm" + Comm_ID.ToString());
  1088. TabControl tab = (TabControl)Util.FineControl(group, "tabControl" + Comm_ID.ToString());
  1089. if (tab != null)
  1090. Util.GroupUIChange(tab, mode);
  1091. }
  1092. catch (Exception ex)
  1093. {
  1094. Util.UErrorMessage(ex, 0, 0);
  1095. }
  1096. }
  1097. private void chkCommUseFlag_CheckedChanged(object sender, EventArgs e)
  1098. {
  1099. try
  1100. {
  1101. CheckBox chk = (CheckBox)sender;
  1102. String ObjName = chk.Name;
  1103. int commId = int.Parse(ObjName.Replace("chkCommUseFlag", ""));
  1104. String UseFlag = chk.Checked ? "Y" : "N";
  1105. GroupBox group = (GroupBox)Util.FineControl(tabPage_CommSet, "groupComm" + commId.ToString());
  1106. CheckBox chk2 = (CheckBox)Util.FineControl(group, "chkLogFlag" + commId.ToString());
  1107. String LogFlag = chk2.Checked ? "Y" : "N";
  1108. CommFlagChage(commId, LogFlag, UseFlag);
  1109. DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1110. COMMLOOP commloop = (COMMLOOP)Enum.Parse(typeof(COMMLOOP), commId.ToString());
  1111. dacCommConfig.Comm_FlagUpdate(QUERYMode.InsertAndUpdate, mdi.myReceiverID, commloop, UseFlag, LogFlag);
  1112. // cyim 2014.5.7 : 수신기설정정보 변경
  1113. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1114. }
  1115. catch (Exception ex)
  1116. {
  1117. Util.UErrorMessage(ex, 0, 0);
  1118. //MessageBox.Show(ex.Message, Application.ProductName);
  1119. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1120. }
  1121. }
  1122. //private void btnLanOK1_Click(object sender, EventArgs e)
  1123. //{
  1124. // try
  1125. // {
  1126. // cmd = QUERYMode.InsertAndUpdate;
  1127. // //Util.ChkTxtBox(txtIpAddress1, "IP");
  1128. // //Util.ChkTxtBox(txtPort1, "PORT");
  1129. // //Util.ChkTxtBox(txtDelay1, "Delay");
  1130. // //Util.ChkTxtBox(txtTimeOut1, "Time Out");
  1131. // //String IpAddress = txtIpAddress1.Text.Trim();
  1132. // //String Port = txtPort1.Text.Trim();
  1133. // //String Delay = txtDelay1.Text.Trim();
  1134. // //String TimeOut = txtTimeOut1.Text.Trim();
  1135. // String UseFlag = chkCommUseFlag1.Checked ? "Y" : "N";
  1136. // String LogFlag = chkLogFlag1.Checked ? "Y" : "N";
  1137. // //if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");
  1138. // //if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  1139. // //if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  1140. // DacCommConfig dacCommConfig = new DacCommConfig();
  1141. // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.FrontLoop, "FRONT LOOP", COMMLOOP.FrontLoop, "L"
  1142. // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);
  1143. // //수신기설정정보 변경
  1144. // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1145. // MessageBox.Show("FRONT LOOP 통신설정값을 저장하였습니다.", Application.ProductName);
  1146. // //VIEW모드로 변경한다.
  1147. // //Util.GroupUIChange(groupComm1, UIMode.cancel);
  1148. // //데이터 불러오기
  1149. // //Comm_getData();
  1150. // }
  1151. // catch (Exception ex)
  1152. // {
  1153. // Util.UErrorMessage(ex,0,0);
  1154. // //MessageBox.Show(ex.Message, Application.ProductName);
  1155. // }
  1156. //}
  1157. //private void btnLanOK2_Click(object sender, EventArgs e)
  1158. //{
  1159. // try
  1160. // {
  1161. // cmd = QUERYMode.InsertAndUpdate;
  1162. // Util.ChkTxtBox(txtIpAddress2, "IP");
  1163. // Util.ChkTxtBox(txtPort2, "PORT");
  1164. // Util.ChkTxtBox(txtDelay2, "Delay");
  1165. // Util.ChkTxtBox(txtTimeOut2, "Time Out");
  1166. // String IpAddress = txtIpAddress2.Text.Trim();
  1167. // String Port = txtPort2.Text.Trim();
  1168. // String Delay = txtDelay2.Text.Trim();
  1169. // String TimeOut = txtTimeOut2.Text.Trim();
  1170. // String UseFlag = chkCommUseFlag2.Checked ? "Y" : "N";
  1171. // String LogFlag = chkLogFlag2.Checked ? "Y" : "N";
  1172. // if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");
  1173. // if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  1174. // if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  1175. // DacCommConfig dacCommConfig = new DacCommConfig();
  1176. // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BackLoop, "BACK LOOP", COMMLOOP.BackLoop, "L"
  1177. // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);
  1178. // //수신기설정정보 변경
  1179. // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1180. // MessageBox.Show("BACK LOOP 통신설정값을 저장하였습니다.", Application.ProductName);
  1181. // //VIEW모드로 변경한다.
  1182. // //Util.GroupUIChange(groupComm2, UIMode.cancel);
  1183. // //데이터 불러오기
  1184. // //Comm_getData();
  1185. // }
  1186. // catch (Exception ex)
  1187. // {
  1188. // Util.UErrorMessage(ex,0,0);
  1189. // //MessageBox.Show(ex.Message, Application.ProductName);
  1190. // }
  1191. //}
  1192. //private void btnLanOK3_Click(object sender, EventArgs e)
  1193. //{
  1194. // try
  1195. // {
  1196. // cmd = QUERYMode.InsertAndUpdate;
  1197. // Util.ChkTxtBox(txtIpAddress3, "IP");
  1198. // Util.ChkTxtBox(txtPort3, "PORT");
  1199. // Util.ChkTxtBox(txtDelay3, "Delay");
  1200. // Util.ChkTxtBox(txtTimeOut3, "Time Out");
  1201. // String IpAddress = txtIpAddress3.Text.Trim();
  1202. // String Port = txtPort3.Text.Trim();
  1203. // String Delay = txtDelay3.Text.Trim();
  1204. // String TimeOut = txtTimeOut3.Text.Trim();
  1205. // String UseFlag = chkCommUseFlag3.Checked ? "Y" : "N";
  1206. // String LogFlag = chkLogFlag3.Checked ? "Y" : "N";
  1207. // if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");
  1208. // if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  1209. // if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  1210. // DacCommConfig dacCommConfig = new DacCommConfig();
  1211. // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.IO, "IO BOARD", COMMLOOP.IO, "L"
  1212. // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);
  1213. // //수신기설정정보 변경
  1214. // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1215. // MessageBox.Show("IO BOARD 통신설정값을 저장하였습니다.", Application.ProductName);
  1216. // //VIEW모드로 변경한다.
  1217. // //Util.GroupUIChange(groupComm3, UIMode.cancel);
  1218. // //데이터 불러오기
  1219. // //Comm_getData();
  1220. // }
  1221. // catch (Exception ex)
  1222. // {
  1223. // Util.UErrorMessage(ex,0,0);
  1224. // //MessageBox.Show(ex.Message, Application.ProductName);
  1225. // }
  1226. //}
  1227. //private void btnLanOK4_Click(object sender, EventArgs e)
  1228. //{
  1229. // try
  1230. // {
  1231. // cmd = QUERYMode.InsertAndUpdate;
  1232. // Util.ChkTxtBox(txtIpAddress4, "IP");
  1233. // Util.ChkTxtBox(txtPort4, "PORT");
  1234. // Util.ChkTxtBox(txtDelay4, "Delay");
  1235. // Util.ChkTxtBox(txtTimeOut4, "Time Out");
  1236. // String IpAddress = txtIpAddress4.Text.Trim();
  1237. // String Port = txtPort4.Text.Trim();
  1238. // String Delay = txtDelay4.Text.Trim();
  1239. // String TimeOut = txtTimeOut4.Text.Trim();
  1240. // String UseFlag = chkCommUseFlag4.Checked ? "Y" : "N";
  1241. // String LogFlag = chkLogFlag4.Checked ? "Y" : "N";
  1242. // if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");
  1243. // if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");
  1244. // if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");
  1245. // DacCommConfig dacCommConfig = new DacCommConfig();
  1246. // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.KEYPAD, "KEYPAD", COMMLOOP.KEYPAD, "L"
  1247. // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);
  1248. // //수신기설정정보 변경
  1249. // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1250. // MessageBox.Show("KEYPAD 통신설정값을 저장하였습니다.", Application.ProductName);
  1251. // //VIEW모드로 변경한다.
  1252. // //Util.GroupUIChange(groupComm4, UIMode.cancel);
  1253. // //데이터 불러오기
  1254. // //Comm_getData();
  1255. // }
  1256. // catch (Exception ex)
  1257. // {
  1258. // Util.UErrorMessage(ex,0,0);
  1259. // //MessageBox.Show(ex.Message, Application.ProductName);
  1260. // }
  1261. //}
  1262. #endregion
  1263. /******************************************************************************************************/
  1264. /******************************************************************************************************/
  1265. #region 통신보드 데이터 콘트롤
  1266. /****
  1267. * 통신보드 데이터 불러오기
  1268. *
  1269. * ****/
  1270. List<CTBoard> LTBoard = new List<CTBoard>();
  1271. private void LoadBoardData()
  1272. {
  1273. try
  1274. {
  1275. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1276. DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, 0, null);
  1277. this.LTBoard.Clear();
  1278. if (dt.Rows.Count > 0)
  1279. {
  1280. foreach (DataRow dr in dt.Rows)
  1281. {
  1282. CTBoard board = new CTBoard();
  1283. board.boardID = Convert.ToInt32(dr["BOARD_ID"].ToString());
  1284. board.name = dr["BOARD_NAME"].ToString();
  1285. board.use = ((dr["USE_FLAG"].ToString() == "Y") ? true : false);
  1286. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  1287. board.loop0Use = ((dr["LOOP0_USE_FLAG"].ToString() == "Y") ? true : false);
  1288. board.loop1Use = ((dr["LOOP1_USE_FLAG"].ToString() == "Y") ? true : false);
  1289. board.loop2Use = ((Util.NullToStr(dr["LOOP2_USE_FLAG"]).ToString() == "Y") ? true : false);
  1290. board.loop3Use = ((Util.NullToStr(dr["LOOP3_USE_FLAG"]).ToString() == "Y") ? true : false);
  1291. this.LTBoard.Add(board);
  1292. }
  1293. }
  1294. }
  1295. catch (Exception ex)
  1296. {
  1297. Util.UErrorMessage(ex, 0, 0);
  1298. }
  1299. }
  1300. // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기
  1301. private DataTable LoadAnalogDetecterLevel(int ReceiverID, int CommBoard, int Loop, int RepeaterID)
  1302. {
  1303. // 전체 중계기 쓰기하는 경우에, DB 의 아날로그 감지기의 정보를 보드별,
  1304. try
  1305. {
  1306. // 전체
  1307. DacUIProcess dacUIProcess_TB_ANALOG_DEVICE = new DacUIProcess(ReceiverID);
  1308. String SQL = "";
  1309. SQL += " SELECT REPEATER_ID,FAULT_VALUE,PREFIRE_VALUE,FIRED_VALUE,FIREN_VALUE";
  1310. SQL += " FROM TB_ANALOG_DEVICE_2 ";
  1311. if (RepeaterID != 0)
  1312. SQL += string.Format(" WHERE RECEIVER_ID='{0}' AND COMM_ID='{1}' AND BOARD_ID='{2}' AND LOOP_NO='{3}' AND REPEATER_ID='{4}'", ReceiverID, "1", CommBoard, Loop, RepeaterID);
  1313. else
  1314. SQL += string.Format(" WHERE RECEIVER_ID='{0}' AND COMM_ID='{1}' AND BOARD_ID='{2}' AND LOOP_NO='{3}' ", ReceiverID, "1", CommBoard, Loop);
  1315. // cyim 2016.06.15 : 아날로그 감지기 출력 포인트 고려 : 레벨값은 입력포인트만 고려한다
  1316. // 출력포인트가 있을경우에는 레벨값 조회시 중계기 아이디가 중복되어 버린다
  1317. SQL += " AND INOUT_TYPE ='I' ";
  1318. DataSet dao_TB_ANALOG_DEVICE = dacUIProcess_TB_ANALOG_DEVICE.Select(SQL);
  1319. DataTable dt_TB_ANALOG_DEVICE = dao_TB_ANALOG_DEVICE.Tables[0];
  1320. return dt_TB_ANALOG_DEVICE;
  1321. }
  1322. catch (Exception ex)
  1323. {
  1324. Util.UErrorMessage(ex, 0, 0);
  1325. return null;
  1326. }
  1327. }
  1328. private void Board_getData()
  1329. {
  1330. try
  1331. {
  1332. //for (int i = 1; i <= 16; i++)
  1333. //{
  1334. // checkPanelLoad(i, false, false, false);
  1335. //}
  1336. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1337. DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, 0, null);
  1338. //if (dt.Rows.Count > 0)
  1339. //{
  1340. // foreach (DataRow dr in dt.Rows)
  1341. // {
  1342. // int BoardId = int.Parse(Convert.ToString(dr[0]));
  1343. // Boolean Loop0UseFlag = Convert.ToString(dr["LOOP0_USE_FLAG"]) == "Y" ? true : false;
  1344. // Boolean Loop1UseFlag = Convert.ToString(dr["LOOP1_USE_FLAG"]) == "Y" ? true : false;
  1345. // Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;
  1346. // //checkPanelLoad(BoardId, UseFlag, Loop0UseFlag , Loop1UseFlag);
  1347. // }
  1348. //}
  1349. listView_CommBoard.Items.Clear();
  1350. if (dt.Rows.Count > 0)
  1351. {
  1352. String sUseFlag;
  1353. foreach (DataRow dr in dt.Rows)
  1354. {
  1355. int ReceiverId = int.Parse(Convert.ToString(dr[0]));
  1356. if (ReceiverId == mdi.myReceiverID) this.ThisRedundant_Flag = Convert.ToString(dr[5]) == "Y" ? true : false;
  1357. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  1358. int i;
  1359. if (mdi.ReceiverModel == "IFC3300")
  1360. i = 0;
  1361. else
  1362. i = 15;
  1363. // cyim 2016.10.24 : 통신보드 15번 -> 0번카드로 대체
  1364. // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신보드 정보중에 15번 보드는 표시 하지 않도록한다
  1365. if (dr["BOARD_ID"].ToString() != i.ToString())
  1366. {
  1367. ListViewItem item = new ListViewItem(dr["BOARD_ID"].ToString());
  1368. //String version = dr["MAIN_VERSION"].ToString();
  1369. //if (!version.Equals("")) version += "." + dr["SUB_VERSION"].ToString();
  1370. //item.SubItems.Add(version);
  1371. //item.SubItems.Add(" ");
  1372. //item.SubItems.Add(Util.baudCodeToRate(dr["BAUD_RATE"].ToString()));
  1373. sUseFlag = (dr["USE_FLAG"].ToString());
  1374. item.SubItems.Add(sUseFlag);
  1375. if (sUseFlag == "Y")
  1376. {
  1377. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  1378. item.SubItems.Add(dr["LOOP0_USE_FLAG"].ToString());
  1379. item.SubItems.Add(dr["LOOP1_USE_FLAG"].ToString());
  1380. item.SubItems.Add(Util.NullToStr(dr["LOOP2_USE_FLAG"]).ToString());
  1381. item.SubItems.Add(Util.NullToStr(dr["LOOP3_USE_FLAG"]).ToString());
  1382. }
  1383. else
  1384. {
  1385. item.SubItems.Add("-");
  1386. item.SubItems.Add("-");
  1387. item.SubItems.Add("-");
  1388. item.SubItems.Add("-");
  1389. }
  1390. //item.SubItems.Add(Util.baudCodeToRate(dr["LOOP0_BAUD_RATE"].ToString()));
  1391. //item.SubItems.Add(Util.baudCodeToRate(dr["LOOP1_BAUD_RATE"].ToString()));
  1392. listView_CommBoard.Items.Add(item);
  1393. }
  1394. }
  1395. }
  1396. }
  1397. catch (Exception ex)
  1398. {
  1399. Util.UErrorMessage(ex, 0, 0);
  1400. }
  1401. }
  1402. delegate void devent(CheckBox c, System.EventArgs e);
  1403. //GroupBox에 자료 표시하기
  1404. private void GroupBoardData(ListViewItem itm)
  1405. {
  1406. try
  1407. {
  1408. if (itm == null)
  1409. {
  1410. txtBoardID.Text = "";
  1411. cboBoardBaudRate.SelectedIndex = -1;
  1412. //txtMainVersion.Text = "";
  1413. //txtSubVersion.Text = "";
  1414. //txtCommTerm.Text = "";
  1415. chkBoardUseFlag.Checked = false;
  1416. chkLoop0UseFlag.Checked = false;
  1417. chkLoop1UseFlag.Checked = false;
  1418. chkLoop2UseFlag.Checked = false;
  1419. chkLoop3UseFlag.Checked = false;
  1420. //cboLoop0BaudRate.SelectedIndex = -1;
  1421. //cboLoop1BaudRate.SelectedIndex = -1;
  1422. btnBoardEdit.Enabled = false;
  1423. btnBoardDel.Enabled = false;
  1424. }
  1425. else
  1426. {
  1427. txtBoardID.Text = itm.Text;
  1428. //String sVersion = itm.SubItems[1].Text;
  1429. //if (sVersion.IndexOf(".") != -1)
  1430. //{
  1431. // txtMainVersion.Text = sVersion.Substring(0, sVersion.IndexOf("."));
  1432. // txtSubVersion.Text = sVersion.Substring(sVersion.IndexOf(".") + 1);
  1433. //}
  1434. //else
  1435. //{
  1436. // txtMainVersion.Text = sVersion;
  1437. //}
  1438. //txtCommTerm.Text = itm.SubItems[1].Text;
  1439. //String baudrate = Util.baudRateToCode(itm.SubItems[2].Text);
  1440. //if (baudrate != null) cboBoardBaudRate.SelectedValue = baudrate;
  1441. //else cboBoardBaudRate.SelectedIndex = -1;
  1442. chkBoardUseFlag.Checked = (itm.SubItems[1].Text == "Y" ? true : false);
  1443. chkLoop0UseFlag.Checked = (itm.SubItems[2].Text == "Y" ? true : false);
  1444. chkLoop1UseFlag.Checked = (itm.SubItems[3].Text == "Y" ? true : false);
  1445. chkLoop2UseFlag.Checked = (itm.SubItems[4].Text == "Y" ? true : false);
  1446. chkLoop3UseFlag.Checked = (itm.SubItems[5].Text == "Y" ? true : false);
  1447. //String Loop0baudrate = Util.baudRateToCode(itm.SubItems[6].Text);
  1448. //if (Loop0baudrate != null) cboLoop0BaudRate.SelectedValue = Loop0baudrate;
  1449. //else cboLoop0BaudRate.SelectedIndex = -1;
  1450. //String Loop1baudrate = Util.baudRateToCode(itm.SubItems[7].Text);
  1451. //if (Loop1baudrate != null) cboLoop1BaudRate.SelectedValue = Loop1baudrate;
  1452. //else cboLoop1BaudRate.SelectedIndex = -1;
  1453. //cboLoop0BaudRate.SelectedValue = Util.baudRateToCode(itm.SubItems[7].Text);
  1454. //cboLoop1BaudRate.SelectedValue = Util.baudRateToCode(itm.SubItems[8].Text);
  1455. btnBoardEdit.Enabled = true;
  1456. btnBoardDel.Enabled = true;
  1457. }
  1458. btnBoardAdd.Enabled = true;
  1459. }
  1460. catch (Exception ex)
  1461. {
  1462. Util.UErrorMessage(ex, 0, 0);
  1463. }
  1464. }
  1465. //통신보드 입력값 완료 버튼
  1466. private void btnBoardOK_Click(object sender, EventArgs e)
  1467. {
  1468. try
  1469. {
  1470. if (cmd == QUERYMode.insert || cmd == QUERYMode.update)
  1471. {
  1472. Util.ChkTxtBox(txtBoardID, "통신보드ID");
  1473. if (!Util.onlyLiteral(txtBoardID.Text.Trim())) throw new Exception("통신보드ID는 숫자형만 입력해 주세요.");
  1474. if (chkBoardUseFlag.Checked)
  1475. {
  1476. //Util.ChkComboBox(cboBoardBaudRate, "통신보드 Baud Rate");
  1477. //Util.ChkTxtBox(txtCommTerm, "송수신간격");
  1478. //Util.ChkTxtBox(txtMainVersion, "메인버젼");
  1479. //if (!Util.onlyLiteral(txtMainVersion.Text.Trim())) throw new Exception("메인버젼은 숫자형만 입력해 주세요.");
  1480. //Util.ChkTxtBox(txtSubVersion, "서브버젼");
  1481. }
  1482. //if (chkLoop0UseFlag.Checked)
  1483. //{
  1484. // Util.ChkComboBox(cboLoop0BaudRate, "Loop0 Baud Rate");
  1485. //}
  1486. //if (chkLoop1UseFlag.Checked)
  1487. //{
  1488. // Util.ChkComboBox(cboLoop1BaudRate, "Loop1 Baud Rate");
  1489. //}
  1490. //if (txtSubVersion.Text.Length < 1) txtSubVersion.Text = "0";
  1491. // cyim 2016.10.31 : 대용량 수신기용 UI 변경
  1492. int BoardID = int.Parse(txtBoardID.Text.Trim());
  1493. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  1494. int i;
  1495. if (mdi.ReceiverModel == "IFC3300")
  1496. i = 64;
  1497. else
  1498. i = 16;
  1499. if (BoardID > i)
  1500. {
  1501. MessageBox.Show("통신보드(중계반) 아이디는 64를 초과할 수 없습니다.", Application.ProductName);
  1502. return;
  1503. }
  1504. String BoardUseFlag = (chkBoardUseFlag.Checked ? "Y" : "N");
  1505. String Loop0UseFlag;
  1506. String Loop1UseFlag;
  1507. String Loop2UseFlag;
  1508. String Loop3UseFlag;
  1509. if (BoardUseFlag == "N")
  1510. {
  1511. Loop0UseFlag = "N";
  1512. Loop1UseFlag = "N";
  1513. Loop2UseFlag = "N";
  1514. Loop3UseFlag = "N";
  1515. }
  1516. else
  1517. {
  1518. Loop0UseFlag = (chkLoop0UseFlag.Checked ? "Y" : "N");
  1519. Loop1UseFlag = (chkLoop1UseFlag.Checked ? "Y" : "N");
  1520. Loop2UseFlag = (chkLoop2UseFlag.Checked ? "Y" : "N");
  1521. Loop3UseFlag = (chkLoop3UseFlag.Checked ? "Y" : "N");
  1522. }
  1523. //int BoardBaudRate = int.Parse(cboBoardBaudRate.SelectedValue == null ? "0" : cboBoardBaudRate.SelectedValue.ToString());
  1524. //int Loop0BaudRate = int.Parse(cboLoop0BaudRate.SelectedValue == null ? "0" : cboLoop0BaudRate.SelectedValue.ToString());
  1525. //int Loop1BaudRate = int.Parse(cboLoop1BaudRate.SelectedValue == null ? "0" : cboLoop1BaudRate.SelectedValue.ToString());
  1526. //수신기설정정보 변경
  1527. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1528. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1529. //dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, "통신보드" + BoardID
  1530. // , BoardUseFlag, Loop0UseFlag, Loop1UseFlag, BoardBaudRate, Loop0BaudRate, Loop1BaudRate, CommTerm, 0, 0);
  1531. dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, "통신보드" + BoardID
  1532. , BoardUseFlag, Loop0UseFlag, Loop1UseFlag, Loop2UseFlag, Loop3UseFlag, 0, 0, 0, 0, 0, 0, 0);
  1533. //중계기설정의 통신보드 콤보를 재설정
  1534. //DacBoardConfig dacBoardConfig = new DacBoardConfig();
  1535. ArrayList ary = dacBoardConfig.Board_List(mdi.myReceiverID, mdi);
  1536. Util.ComboSetting(cboBoardList, ary, null);
  1537. //통신보드설정쓰기
  1538. //CmdInfo uiCmd = new CmdInfo(prt_cmd_define.write_tbd_state, mdi.myReceiverID, 0, BoardID, 0);
  1539. }
  1540. //VIEW모드로 변경한다.
  1541. Util.GroupUIChange(groubBoard, UIMode.cancel);
  1542. //데이터 불러오기
  1543. Board_getData();
  1544. //수신기리스트 콤보에 넣기
  1545. //ComboBoardList(mdi.MyBoardID);
  1546. GroupBoardData(null);
  1547. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  1548. this.panel_Menu.Focus();
  1549. }
  1550. catch (Exception ex)
  1551. {
  1552. Util.UErrorMessage(ex, 0, 0);
  1553. //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);
  1554. }
  1555. }
  1556. //통신보드 입력값 취소 버튼
  1557. private void btnBoardCancel_Click(object sender, EventArgs e)
  1558. {
  1559. try
  1560. {
  1561. //VIEW모드로 변경한다.
  1562. Util.GroupUIChange(groubBoard, UIMode.cancel);
  1563. GroupBoardData(null);
  1564. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  1565. this.panel_Menu.Focus();
  1566. }
  1567. catch (Exception ex)
  1568. {
  1569. Util.UErrorMessage(ex, 0, 0);
  1570. }
  1571. }
  1572. //통신보드 추가 버튼
  1573. private void btnBoardAdd_Click(object sender, EventArgs e)
  1574. {
  1575. try
  1576. {
  1577. //추가버튼을 누르면 기본설정값을 넣어준다...
  1578. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1579. int brdNo = dacBoardConfig.BoardID_Max(mdi.myReceiverID);
  1580. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  1581. int i;
  1582. if (mdi.ReceiverModel == "IFC3300")
  1583. i = 64;
  1584. else
  1585. i = 15;
  1586. // cyim 2016.10.24 : 통신보드 15번 -> 0번카드로 대체 (중계반 아이디는 최대 64번까지 있다)
  1587. // cyim 2013.7.10 디자인개선작업 : 수신기설정
  1588. string Comment = string.Format("통신보드ID는 {0}을 초과할 수 없습니다. 그래도 계속 진행하시겠습니까?", i);
  1589. if (brdNo > i && MessageBox.Show(Comment, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.No)
  1590. {
  1591. return;
  1592. }
  1593. //입력모드로 변경한다.
  1594. Util.GroupUIChange(groubBoard, UIMode.input);
  1595. GroupBoardData(null);
  1596. cmd = QUERYMode.insert;
  1597. txtBoardID.Text = brdNo.ToString();
  1598. cboBoardBaudRate.SelectedValue = "7";
  1599. //txtMainVersion.Text = "0";
  1600. //txtSubVersion.Text = "0";
  1601. //txtCommTerm.Text = "200";
  1602. chkBoardUseFlag.Checked = true;
  1603. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  1604. chkLoop0UseFlag.Checked = true;
  1605. chkLoop1UseFlag.Checked = true;
  1606. chkLoop2UseFlag.Checked = true;
  1607. chkLoop3UseFlag.Checked = true;
  1608. //cboLoop0BaudRate.SelectedValue = "7";
  1609. //cboLoop1BaudRate.SelectedValue = "7";
  1610. txtBoardID.Focus();
  1611. btnBoardAdd.Enabled = false;
  1612. btnBoardEdit.Enabled = false;
  1613. btnBoardDel.Enabled = false;
  1614. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  1615. this.panel_Menu.Focus();
  1616. // cyim 2014.5.7 : 수신기설정정보 변경
  1617. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1618. }
  1619. catch (Exception ex)
  1620. {
  1621. Util.UErrorMessage(ex, 0, 0);
  1622. }
  1623. }
  1624. //통신보드 수정 버튼
  1625. private void btnBoardEdit_Click(object sender, EventArgs e)
  1626. {
  1627. try
  1628. {
  1629. //입력모드로 변경한다.
  1630. cmd = QUERYMode.update;
  1631. Util.GroupUIChange(groubBoard, UIMode.input);
  1632. txtBoardID.ReadOnly = true;
  1633. btnBoardAdd.Enabled = false;
  1634. btnBoardEdit.Enabled = false;
  1635. btnBoardDel.Enabled = false;
  1636. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  1637. this.panel_Menu.Focus();
  1638. // cyim 2014.5.7 : 수신기설정정보 변경
  1639. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1640. }
  1641. catch (Exception ex)
  1642. {
  1643. Util.UErrorMessage(ex, 0, 0);
  1644. }
  1645. }
  1646. //통신보드 삭제 버튼
  1647. private void btnBoardDel_Click(object sender, EventArgs e)
  1648. {
  1649. try
  1650. {
  1651. cmd = QUERYMode.delete;
  1652. int BoardID = int.Parse(txtBoardID.Text.Trim());
  1653. String msg = string.Format("통신보드 {0}을/를 삭제하시겠습니까?", BoardID);
  1654. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  1655. {
  1656. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1657. dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, null, null, null, null, null, null, 0, 0, 0, 0, 0, 0, 0); // cyim 2016.10.31 : 대용량 수신기용 UI 변경
  1658. }
  1659. //VIEW모드로 변경한다.
  1660. Util.GroupUIChange(groubBoard, UIMode.cancel);
  1661. //수신기정보 입력 CLEAR
  1662. GroupBoardData(null);
  1663. //데이터 불러오기
  1664. Board_getData();
  1665. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  1666. this.panel_Menu.Focus();
  1667. // cyim 2014.5.7 : 수신기설정정보 변경
  1668. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1669. }
  1670. catch (Exception ex)
  1671. {
  1672. Util.UErrorMessage(ex, 0, 0);
  1673. //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);
  1674. }
  1675. }
  1676. //통신보드 리스트 선택 변경시
  1677. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  1678. {
  1679. try
  1680. {
  1681. ListView lv = (ListView)sender;
  1682. if (lv.SelectedItems.Count > 0)
  1683. {
  1684. ListViewItem itm = lv.SelectedItems[0];
  1685. //VIEW모드로 변경한다.
  1686. Util.GroupUIChange(groubBoard, UIMode.cancel);
  1687. GroupBoardData(itm);
  1688. }
  1689. else
  1690. {
  1691. //VIEW모드로 변경한다.
  1692. Util.GroupUIChange(groubBoard, UIMode.cancel);
  1693. GroupBoardData(null);
  1694. }
  1695. }
  1696. catch (Exception ex)
  1697. {
  1698. Util.UErrorMessage(ex, 0, 0);
  1699. //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);
  1700. }
  1701. }
  1702. //통신보드 리스트 클릭시
  1703. private void listView2_Click(object sender, EventArgs e)
  1704. {
  1705. listView2_SelectedIndexChanged(listView_CommBoard, System.EventArgs.Empty);
  1706. }
  1707. #endregion
  1708. /******************************************************************************************************/
  1709. /******************************************************************************************************/
  1710. #region IO보드 데이터 콘트롤
  1711. private void mskIOBoardDeviceID_TextChanged(object sender, EventArgs e)
  1712. {
  1713. try
  1714. {
  1715. int caretPosition;
  1716. caretPosition = mskIOBoardDeviceID.SelectionStart;
  1717. mskIOBoardDeviceID.Text = mskIOBoardDeviceID.Text.ToUpper();
  1718. mskIOBoardDeviceID.Select(caretPosition, 0);
  1719. }
  1720. catch (Exception ex)
  1721. {
  1722. Util.UErrorMessage(ex, 0, 0);
  1723. }
  1724. }
  1725. //IO보드 데이터 표시
  1726. private void IOBoardSelectData(ListViewItem itm)
  1727. {
  1728. try
  1729. {
  1730. IOBoard_selectItem = itm;
  1731. if (itm == null)
  1732. {
  1733. txtIOBoardID.Text = "";
  1734. txtIOBoardName.Text = "";
  1735. cboIOBoardBaudRate.SelectedIndex = -1;
  1736. //txtIOBoardMainVersion.Text = "";
  1737. //txtIOBoardSubVersion.Text = "";
  1738. txtIOBoardCommTerm.Text = "";
  1739. if (IOBoard_cmd == QUERYMode.insert)
  1740. {
  1741. txtIOBoardID.ReadOnly = false;
  1742. txtIOBoardID.BackColor = Color.White;
  1743. txtIOBoardName.ReadOnly = false;
  1744. btnIOBoardOK.Enabled = true;
  1745. }
  1746. else
  1747. {
  1748. txtIOBoardID.ReadOnly = true;
  1749. txtIOBoardID.BackColor = SystemColors.Control;
  1750. btnIOBoardAdd.Enabled = true;
  1751. btnIOBoardDel.Enabled = false;
  1752. btnIOBoardOK.Enabled = false;
  1753. }
  1754. btnIOBoardDeviceAdd.Enabled = false;
  1755. }
  1756. else
  1757. {
  1758. txtIOBoardID.Text = itm.Text;
  1759. txtIOBoardID.BackColor = SystemColors.Control;
  1760. txtIOBoardName.Text = Util.NullToStr(itm.SubItems[1].Text);
  1761. if (!itm.SubItems[2].Text.Equals(""))
  1762. cboIOBoardBaudRate.SelectedValue = Util.baudRateToCode(Util.NullToStr(itm.SubItems[2].Text));
  1763. //String Version = Util.NullToStr(itm.SubItems[3].Text);
  1764. //if (Version.IndexOf(".") > -1)
  1765. //{
  1766. // txtIOBoardMainVersion.Text = Version.Substring(0, Version.IndexOf("."));
  1767. // txtIOBoardSubVersion.Text = Version.Substring(Version.IndexOf(".") + 1);
  1768. //}
  1769. //else
  1770. //{
  1771. // txtIOBoardMainVersion.Text = Version;
  1772. // txtIOBoardSubVersion.Text = "";
  1773. //}
  1774. txtIOBoardCommTerm.Text = itm.SubItems[3].Text;
  1775. txtIOBoardID.ReadOnly = true;
  1776. btnIOBoardAdd.Enabled = true;
  1777. btnIOBoardDel.Enabled = true;
  1778. btnIOBoardOK.Enabled = true;
  1779. btnIOBoardDeviceAdd.Enabled = true;
  1780. }
  1781. IOBoardDeviceSelectData(null);
  1782. }
  1783. catch (Exception ex)
  1784. {
  1785. Util.UErrorMessage(ex, 0, 0);
  1786. }
  1787. }
  1788. /*******************************************************
  1789. * [IO보드] LISTVIEW에 데이터 불러오기
  1790. ******************************************************/
  1791. private void IOBoard_getData()
  1792. {
  1793. try
  1794. {
  1795. IOBoardSelectData(null);
  1796. DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1797. DataTable dt = dacIOBoardConfig.Board_Select(mdi.myReceiverID, 0, "Y");
  1798. listView3.Items.Clear();
  1799. if (dt.Rows.Count > 0)
  1800. {
  1801. foreach (DataRow dr in dt.Rows)
  1802. {
  1803. ListViewItem item = new ListViewItem(Convert.ToString(dr["BOARD_ID"]));
  1804. item.SubItems.Add(dr["BOARD_NAME"].ToString());
  1805. item.SubItems.Add(Util.baudCodeToRate(dr["BAUD_RATE"].ToString()));
  1806. //String version = dr["MAIN_VERSION"].ToString();
  1807. //if (!version.Equals("")) version += "." + dr["SUB_VERSION"].ToString();
  1808. //item.SubItems.Add(version);
  1809. item.SubItems.Add(" ");
  1810. listView3.Items.Add(item);
  1811. }
  1812. }
  1813. }
  1814. catch (Exception ex)
  1815. {
  1816. Util.UErrorMessage(ex, 0, 0);
  1817. //MessageBox.Show(ex.Message, Application.ProductName);
  1818. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1819. }
  1820. }
  1821. private void btnIOBoardAdd_Click(object sender, EventArgs e)
  1822. {
  1823. try
  1824. {
  1825. //입력모드로 변경한다.
  1826. IOBoard_cmd = QUERYMode.insert;
  1827. Util.GroupUIChange(panelIOBoard, UIMode.input);
  1828. IOBoardSelectData(null);
  1829. cboIOBoardBaudRate.SelectedValue = "7";
  1830. txtIOBoardCommTerm.Text = "200";
  1831. DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1832. txtIOBoardID.Text = dacIOBoardConfig.BoardID_Max(mdi).ToString();
  1833. txtIOBoardName.Focus();
  1834. btnIOBoardAdd.Enabled = false;
  1835. btnIOBoardDel.Enabled = false;
  1836. btnIOBoardCancel.Visible = true;
  1837. btnIOBoardOK.Enabled = true;
  1838. // cyim 2014.5.7 : 수신기설정정보 변경
  1839. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1840. }
  1841. catch (Exception ex)
  1842. {
  1843. Util.UErrorMessage(ex, 0, 0);
  1844. }
  1845. }
  1846. private void btnIOBoardOK_Click(object sender, EventArgs e)
  1847. {
  1848. try
  1849. {
  1850. if (IOBoard_cmd == QUERYMode.insert || IOBoard_cmd == QUERYMode.update)
  1851. {
  1852. Util.ChkTxtBox(txtIOBoardID, "IO보드ID");
  1853. Util.ChkTxtBox(txtIOBoardName, "IO보드명");
  1854. Util.ChkComboBox(cboIOBoardBaudRate, "Baud Rate");
  1855. //Util.ChkTxtBox(txtIOBoardMainVersion, "Version");
  1856. Util.ChkTxtBox(txtIOBoardCommTerm, "송수신간격");
  1857. //Util.ChkOnlyLiteralTextBox(txtIOBoardMainVersion, "Main Version");
  1858. //Util.ChkOnlyLiteralTextBox(txtIOBoardSubVersion, "Sub Version");
  1859. Util.ChkOnlyLiteralTextBox(txtIOBoardCommTerm, "송수신간격");
  1860. int BoardID = Util.StrToInt(txtIOBoardID.Text, -1);
  1861. String BoardName = txtIOBoardName.Text.Trim();
  1862. int BaudRate = Util.StrToInt(cboIOBoardBaudRate.SelectedValue, -1);
  1863. //int mainVer = Util.StrToInt(txtIOBoardMainVersion.Text, -1);
  1864. //int subVer = Util.StrToInt(txtIOBoardSubVersion.Text, 0);
  1865. //int CommTerm = Util.StrToInt(txtIOBoardCommTerm.Text, -1);
  1866. DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1867. dacIOBoardConfig.Board_Update(IOBoard_cmd, mdi.myReceiverID, BoardID, BoardName, "Y", "Y", "N", BaudRate, 0, 0, 0, 0);
  1868. //dacReceiverConfig.Receiver_Update(cmd, ReceiverID, ReceiveName, IP_Address, Event_Port_No, Command_Port_No, Redundant_Flag, Use_Flag);
  1869. }
  1870. IOBoard_cmd = QUERYMode.select;
  1871. //VIEW모드로 변경한다.
  1872. Util.GroupUIChange(panelIOBoard, UIMode.cancel);
  1873. //데이터 불러오기
  1874. IOBoard_getData();
  1875. IOBoardDevice_getData();
  1876. IOBoardSelectData(null);
  1877. btnIOBoardCancel.Visible = false;
  1878. // cyim 2014.5.7 : 수신기설정정보 변경
  1879. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1880. }
  1881. catch (Exception ex)
  1882. {
  1883. Util.UErrorMessage(ex, 0, 0);
  1884. //MessageBox.Show(ex.Message, Application.ProductName);
  1885. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1886. }
  1887. }
  1888. private void btnIOBoardCancel_Click(object sender, EventArgs e)
  1889. {
  1890. try
  1891. {
  1892. //VIEW모드로 변경한다.
  1893. IOBoard_cmd = QUERYMode.select;
  1894. Util.GroupUIChange(panelIOBoard, UIMode.cancel);
  1895. IOBoardSelectData(null);
  1896. btnIOBoardCancel.Visible = false;
  1897. }
  1898. catch (Exception ex)
  1899. {
  1900. Util.UErrorMessage(ex, 0, 0);
  1901. }
  1902. }
  1903. private void listView3_SelectedIndexChanged(object sender, EventArgs e)
  1904. {
  1905. try
  1906. {
  1907. ListView lv = (ListView)sender;
  1908. if (lv.SelectedItems.Count > 0)
  1909. {
  1910. ListViewItem itm = lv.SelectedItems[0];
  1911. IOBoard_cmd = QUERYMode.update;
  1912. //VIEW모드로 변경한다.[IO보드]
  1913. Util.GroupUIChange(panelIOBoard, UIMode.input);
  1914. IOBoardSelectData(itm);
  1915. IOBoardDevice_getData();
  1916. }
  1917. else
  1918. {
  1919. IOBoard_cmd = QUERYMode.select;
  1920. //VIEW모드로 변경한다.
  1921. Util.GroupUIChange(panelIOBoard, UIMode.cancel);
  1922. IOBoardSelectData(null);
  1923. }
  1924. }
  1925. catch (Exception ex)
  1926. {
  1927. Util.UErrorMessage(ex, 0, 0);
  1928. //MessageBox.Show(ex.Message, Application.ProductName);
  1929. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1930. }
  1931. }
  1932. private void btnIOBoardDel_Click(object sender, EventArgs e)
  1933. {
  1934. try
  1935. {
  1936. IOBoard_cmd = QUERYMode.delete;
  1937. int BoardID = Util.StrToInt(txtIOBoardID.Text, -1);
  1938. String BoardName = txtIOBoardName.Text.Trim();
  1939. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", BoardName, BoardID);
  1940. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  1941. {
  1942. DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1943. dacIOBoardConfig.Board_Update(IOBoard_cmd, mdi.myReceiverID, BoardID, BoardName, null, null, null, 0, 0, 0, 0, 0);
  1944. }
  1945. //VIEW모드로 변경한다.
  1946. IOBoard_cmd = QUERYMode.select;
  1947. Util.GroupUIChange(panelIOBoard, UIMode.cancel);
  1948. //입력 CLEAR
  1949. IOBoardSelectData(null);
  1950. //데이터 불러오기
  1951. IOBoard_getData();
  1952. IOBoardDevice_getData();
  1953. // cyim 2014.5.7 : 수신기설정정보 변경
  1954. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  1955. }
  1956. catch (Exception ex)
  1957. {
  1958. Util.UErrorMessage(ex, 0, 0);
  1959. //MessageBox.Show(ex.Message, Application.ProductName);
  1960. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1961. }
  1962. }
  1963. /*******************************************************
  1964. * [IO보드 회로정보] LISTVIEW에 데이터 불러오기
  1965. ******************************************************/
  1966. private void IOBoardDevice_getData()
  1967. {
  1968. try
  1969. {
  1970. IOBoardDeviceSelectData(null);
  1971. int board_id = Util.StrToInt(txtIOBoardID.Text, 0);
  1972. DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1973. DataTable dt = dacIODeviceConfig.Device_Select(mdi.myReceiverID, board_id, 0, null);
  1974. listView4.Items.Clear();
  1975. if (dt.Rows.Count > 0)
  1976. {
  1977. foreach (DataRow dr in dt.Rows)
  1978. {
  1979. String dev_id = dr["DEVICE_ID"].ToString();
  1980. String dev_id_s = String.Format("I-{0}-{1:00}-{2:00}", dr["INOUT_TYPE"].ToString(), int.Parse(dr["BOARD_ID"].ToString()), int.Parse(dr["DEVICE_ID"].ToString()));
  1981. ListViewItem item = new ListViewItem(dev_id_s);
  1982. item.SubItems.Add(string.Format("{0}-{1}", dr["DEVICE_TYPE"].ToString(), dr["DEVICE_TYPE_NAME"].ToString()));
  1983. item.SubItems.Add(string.Format("{0}-{1}", dr["POSITION_CODE"].ToString(), dr["POSITION_NAME"].ToString()));
  1984. item.SubItems.Add(dr["DEVICE_NAME"].ToString());
  1985. listView4.Items.Add(item);
  1986. }
  1987. }
  1988. }
  1989. catch (Exception ex)
  1990. {
  1991. Util.UErrorMessage(ex, 0, 0);
  1992. //MessageBox.Show(ex.Message, Application.ProductName);
  1993. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1994. }
  1995. }
  1996. private void btnIODeviceOpen_Click(object sender, EventArgs e)
  1997. {
  1998. try
  1999. {
  2000. if (IOBoard_selectItem != null)
  2001. {
  2002. String dev_id_s = mskIOBoardDeviceID.Text;
  2003. String dev_s = "";
  2004. String dev_io = "I";
  2005. if (dev_id_s.Length > 8)
  2006. {
  2007. dev_s = dev_id_s.Substring(7, 2).Trim();
  2008. dev_io = dev_id_s.Substring(2, 1).Trim();
  2009. }
  2010. InputIDVo vo = new InputIDVo();
  2011. vo.ReceiverID = mdi.myReceiverID;
  2012. vo.CommID = 3;
  2013. vo.BoardID = Util.StrToInt(txtIOBoardID.Text, 0);
  2014. vo.InoutType = dev_io;
  2015. vo.LoopNo = 0;
  2016. vo.RepeaterID = 0;
  2017. vo.DeviceID = Util.StrToInt(dev_s, 1);
  2018. IWin32Window window = this;
  2019. frmModalIdInputIO frm = new frmModalIdInputIO();
  2020. frm.InputVo = vo;
  2021. frm.ShowDialog(window);
  2022. vo = frm.InputVo;
  2023. //입력한 코드가 있다면
  2024. if (vo.InputOK)
  2025. {
  2026. //I-A-12-##
  2027. mskIOBoardDeviceID.Text = String.Format("I{0}{1:00}{2:00}", vo.InoutType, vo.BoardID, vo.DeviceID);
  2028. }
  2029. }
  2030. else
  2031. {
  2032. MessageBox.Show("먼저 IO보드를 선택하여 주십시요.", Application.ProductName);
  2033. }
  2034. }
  2035. catch (Exception ex)
  2036. {
  2037. Util.UErrorMessage(ex, 0, 0);
  2038. }
  2039. }
  2040. //IO보드 회로 데이터 표시
  2041. private void IOBoardDeviceSelectData(ListViewItem itm)
  2042. {
  2043. try
  2044. {
  2045. IOBoardDevice_selectItem = itm;
  2046. if (itm == null)
  2047. {
  2048. mskIOBoardDeviceID.Text = "";
  2049. txtIOBoardDeviceTypeCode.Text = "";
  2050. txtIOBoardDeviceTypeName.Text = "";
  2051. txtIOBoardDeviceMemo.Text = "";
  2052. txtIOBoardPositionCode.Text = "";
  2053. txtIOBoardPositionName.Text = "";
  2054. if (IOBoardDevice_cmd == QUERYMode.insert)
  2055. {
  2056. mskIOBoardDeviceID.ReadOnly = false;
  2057. mskIOBoardDeviceID.BackColor = Color.White;
  2058. btnIOBoardDeviceOK.Enabled = true;
  2059. btnDeviceTypeOpen.Enabled = true;
  2060. btnIODeviceOpen.Enabled = true;
  2061. btnIOBoardPositionOpen.Enabled = true;
  2062. }
  2063. else
  2064. {
  2065. mskIOBoardDeviceID.ReadOnly = true;
  2066. mskIOBoardDeviceID.BackColor = SystemColors.Control;
  2067. //btnIOBoardDeviceAdd.Enabled = true;
  2068. btnIOBoardDeviceDel.Enabled = false;
  2069. btnIOBoardDeviceOK.Enabled = false;
  2070. btnDeviceTypeOpen.Enabled = false;
  2071. btnIOBoardPositionOpen.Enabled = false;
  2072. btnIODeviceOpen.Enabled = false;
  2073. }
  2074. }
  2075. else
  2076. {
  2077. String dev_id_s = itm.Text;
  2078. dev_id_s = dev_id_s.Replace("-", "");
  2079. mskIOBoardDeviceID.Text = dev_id_s;
  2080. mskIOBoardDeviceID.BackColor = SystemColors.Control;
  2081. string devType = itm.SubItems[1].Text;
  2082. int pos = devType.IndexOf("-");
  2083. if (pos != -1)
  2084. {
  2085. txtIOBoardDeviceTypeCode.Text = devType.Substring(0, pos);
  2086. txtIOBoardDeviceTypeName.Text = devType.Substring(pos + 1);
  2087. }
  2088. string positionCode = itm.SubItems[2].Text;
  2089. int pos2 = positionCode.IndexOf("-");
  2090. if (pos2 != -1 && positionCode.Length > 1)
  2091. {
  2092. txtIOBoardPositionCode.Text = positionCode.Substring(0, pos);
  2093. txtIOBoardPositionName.Text = positionCode.Substring(pos + 1);
  2094. }
  2095. txtIOBoardDeviceMemo.Text = itm.SubItems[3].Text;
  2096. mskIOBoardDeviceID.ReadOnly = true;
  2097. //btnIOBoardDeviceAdd.Enabled = true;
  2098. btnIOBoardDeviceDel.Enabled = true;
  2099. btnIOBoardDeviceOK.Enabled = true;
  2100. btnDeviceTypeOpen.Enabled = true;
  2101. btnIOBoardPositionOpen.Enabled = true;
  2102. btnIODeviceOpen.Enabled = true;
  2103. }
  2104. }
  2105. catch (Exception ex)
  2106. {
  2107. Util.UErrorMessage(ex, 0, 0);
  2108. }
  2109. }
  2110. private void btnDeviceTypeOpen_Click(object sender, EventArgs e)
  2111. {
  2112. try
  2113. {
  2114. String dev_id_s = mskIOBoardDeviceID.Text;
  2115. String dev_io = null;
  2116. //I-A-12-##
  2117. if (dev_id_s.Length > 8)
  2118. {
  2119. dev_io = dev_id_s.Substring(2, 1).Trim();
  2120. }
  2121. //코드를 찾는 모달창을 연다..
  2122. frmModalDeviceType frm = new frmModalDeviceType(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2123. SearchCodeVo vo = new SearchCodeVo(dev_io);
  2124. vo.Code = txtIOBoardDeviceTypeCode.Text;
  2125. vo.CodeName = txtIOBoardDeviceTypeName.Text;
  2126. frm.SearchCode = vo;
  2127. frm.ShowDialog();
  2128. vo = frm.SearchCode;
  2129. //선택한 코드가 있다면
  2130. if (vo.SearchOK)
  2131. {
  2132. //선택한 코드값을 dataGridView2에 표시
  2133. txtIOBoardDeviceTypeCode.Text = vo.Code;
  2134. txtIOBoardDeviceTypeName.Text = vo.CodeName;
  2135. }
  2136. }
  2137. catch (Exception ex)
  2138. {
  2139. Util.UErrorMessage(ex, 0, 0);
  2140. }
  2141. }
  2142. private void btnIOBoardDeviceAdd_Click(object sender, EventArgs e)
  2143. {
  2144. try
  2145. {
  2146. //입력모드로 변경한다.
  2147. IOBoardDevice_cmd = QUERYMode.insert;
  2148. Util.GroupControlChange(panelIOBoardDevice, UIMode.input);
  2149. IOBoardDeviceSelectData(null);
  2150. mskIOBoardDeviceID.Focus();
  2151. btnIOBoardDeviceAdd.Enabled = false;
  2152. btnIOBoardDeviceDel.Enabled = false;
  2153. btnIOBoardDeviceCancel.Visible = true;
  2154. btnIOBoardDeviceOK.Enabled = true;
  2155. // cyim 2014.5.7 : 수신기설정정보 변경
  2156. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  2157. }
  2158. catch (Exception ex)
  2159. {
  2160. Util.UErrorMessage(ex, 0, 0);
  2161. }
  2162. }
  2163. private void btnIOBoardDeviceCancel_Click(object sender, EventArgs e)
  2164. {
  2165. try
  2166. {
  2167. //VIEW모드로 변경한다.
  2168. IOBoardDevice_cmd = QUERYMode.select;
  2169. Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);
  2170. IOBoardDeviceSelectData(null);
  2171. btnIOBoardDeviceCancel.Visible = false;
  2172. btnIOBoardDeviceAdd.Enabled = true;
  2173. }
  2174. catch (Exception ex)
  2175. {
  2176. Util.UErrorMessage(ex, 0, 0);
  2177. }
  2178. }
  2179. private void btnIOBoardDeviceOK_Click(object sender, EventArgs e)
  2180. {
  2181. try
  2182. {
  2183. if (IOBoardDevice_cmd == QUERYMode.insert || IOBoardDevice_cmd == QUERYMode.update)
  2184. {
  2185. Util.ChkTxtBox(mskIOBoardDeviceID, "회로번호");
  2186. //Util.ChkTxtBox(txtIOBoardDeviceTypeCode, "연동타입코드");
  2187. String dev_id_s = mskIOBoardDeviceID.Text;
  2188. String dev_id = "";
  2189. String dev_board_id = "";
  2190. String dev_io = "I";
  2191. String dev_type = txtIOBoardDeviceTypeCode.Text;
  2192. String dev_name = txtIOBoardDeviceMemo.Text;
  2193. String position_code = txtIOBoardPositionCode.Text;
  2194. //I-A-12-##
  2195. if (dev_id_s.Length > 8)
  2196. {
  2197. dev_id = dev_id_s.Substring(7, 2).Trim();
  2198. dev_io = dev_id_s.Substring(2, 1).Trim();
  2199. dev_board_id = dev_id_s.Substring(4, 2).Trim();
  2200. }
  2201. else
  2202. {
  2203. throw new Exception("회로번호를 올바르게 입력하세요.");
  2204. }
  2205. if (int.Parse(txtIOBoardID.Text) != int.Parse(dev_board_id))
  2206. {
  2207. throw new Exception(String.Format("등록하는 회로의 보드ID[{0}]와 회로번호의 보드ID[{1}]가 일치하지 않습니다."
  2208. , txtIOBoardID.Text, int.Parse(dev_board_id)));
  2209. }
  2210. if (!Util.onlyLiteral(dev_id))
  2211. throw new Exception("회로번호를 올바르게 입력하세요.");
  2212. DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2213. dacIODeviceConfig.Device_Update(IOBoardDevice_cmd, mdi.myReceiverID, Util.StrToInt(dev_board_id, 1)
  2214. , Util.StrToInt(dev_id, 1), dev_io, dev_name, dev_type, position_code);
  2215. }
  2216. IOBoardDevice_cmd = QUERYMode.select;
  2217. //VIEW모드로 변경한다.
  2218. Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);
  2219. //데이터 불러오기
  2220. IOBoardDevice_getData();
  2221. IOBoardDeviceSelectData(null);
  2222. btnIOBoardDeviceCancel.Visible = false;
  2223. // cyim 2014.5.7 : 수신기설정정보 변경
  2224. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  2225. }
  2226. catch (Exception ex)
  2227. {
  2228. Util.UErrorMessage(ex, 0, 0);
  2229. //MessageBox.Show(ex.Message, Application.ProductName);
  2230. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  2231. }
  2232. }
  2233. private void listView4_SelectedIndexChanged(object sender, EventArgs e)
  2234. {
  2235. try
  2236. {
  2237. ListView lv = (ListView)sender;
  2238. if (lv.SelectedItems.Count > 0)
  2239. {
  2240. ListViewItem itm = lv.SelectedItems[0];
  2241. IOBoardDevice_cmd = QUERYMode.update;
  2242. //VIEW모드로 변경한다.[IO보드]
  2243. Util.GroupControlChange(panelIOBoardDevice, UIMode.input);
  2244. IOBoardDeviceSelectData(itm);
  2245. }
  2246. else
  2247. {
  2248. IOBoardDevice_cmd = QUERYMode.select;
  2249. //VIEW모드로 변경한다.
  2250. Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);
  2251. IOBoardDeviceSelectData(null);
  2252. }
  2253. }
  2254. catch (Exception ex)
  2255. {
  2256. Util.UErrorMessage(ex, 0, 0);
  2257. //MessageBox.Show(ex.Message, Application.ProductName);
  2258. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  2259. }
  2260. }
  2261. private void txtIOBoardDeviceTypeCode_TextChanged(object sender, EventArgs e)
  2262. {
  2263. try
  2264. {
  2265. Util.ToUpper(txtIOBoardDeviceTypeCode);
  2266. String TypeValue = txtIOBoardDeviceTypeCode.Text.Trim();
  2267. if (TypeValue.Length == 2)
  2268. {
  2269. String IOType = TypeValue.Substring(0, 1);
  2270. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2271. String type_name = dacDeviceConfig.Device_Type_Name(IOType, TypeValue);
  2272. txtIOBoardDeviceTypeName.Text = type_name;
  2273. }
  2274. else
  2275. {
  2276. txtIOBoardDeviceTypeName.Text = "";
  2277. }
  2278. }
  2279. catch (Exception ex)
  2280. {
  2281. Util.UErrorMessage(ex, 0, 0);
  2282. }
  2283. }
  2284. private void txtIOBoardPositionCode_TextChanged(object sender, EventArgs e)
  2285. {
  2286. try
  2287. {
  2288. Util.ToUpper(txtIOBoardPositionCode);
  2289. String positionCode = txtIOBoardPositionCode.Text.Trim();
  2290. if (positionCode.Length == 2)
  2291. {
  2292. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2293. String positionName = dacDeviceConfig.Device_Position_Name(positionCode);
  2294. txtIOBoardPositionName.Text = positionName;
  2295. }
  2296. else
  2297. {
  2298. txtIOBoardPositionName.Text = "";
  2299. }
  2300. }
  2301. catch (Exception ex)
  2302. {
  2303. Util.UErrorMessage(ex, 0, 0);
  2304. }
  2305. }
  2306. private void btnIOBoardDeviceDel_Click(object sender, EventArgs e)
  2307. {
  2308. try
  2309. {
  2310. String dev_id_s = mskIOBoardDeviceID.Text;
  2311. String dev_id = "";
  2312. String dev_board_id = "";
  2313. String dev_io = "I";
  2314. String dev_type = txtIOBoardDeviceTypeCode.Text;
  2315. String dev_name = txtIOBoardDeviceMemo.Text;
  2316. //I-A-12-## : I(구분)-I,O(회로구분)-##(보드ID)-##(회로ID)
  2317. if (dev_id_s.Length > 8)
  2318. {
  2319. dev_id = dev_id_s.Substring(7, 2).Trim();
  2320. dev_io = dev_id_s.Substring(2, 1).Trim();
  2321. dev_board_id = dev_id_s.Substring(4, 2).Trim();
  2322. }
  2323. else
  2324. {
  2325. throw new Exception("회로번호가 올바르지 않습니다.");
  2326. }
  2327. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", dev_name, dev_id_s);
  2328. IOBoardDevice_cmd = QUERYMode.delete;
  2329. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  2330. {
  2331. DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2332. dacIODeviceConfig.Device_Update(IOBoardDevice_cmd, mdi.myReceiverID, int.Parse(dev_board_id), int.Parse(dev_id), dev_io, null, null, null);
  2333. }
  2334. //VIEW모드로 변경한다.
  2335. IOBoardDevice_cmd = QUERYMode.select;
  2336. Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);
  2337. //입력 CLEAR
  2338. IOBoardDeviceSelectData(null);
  2339. //데이터 불러오기
  2340. IOBoardDevice_getData();
  2341. // cyim 2014.5.7 : 수신기설정정보 변경
  2342. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  2343. }
  2344. catch (Exception ex)
  2345. {
  2346. Util.UErrorMessage(ex, 0, 0);
  2347. //MessageBox.Show(ex.Message, Application.ProductName);
  2348. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  2349. }
  2350. }
  2351. private void btnIOBoardPositionOpen_Click(object sender, EventArgs e)
  2352. {
  2353. try
  2354. {
  2355. String dev_id_s = mskIOBoardDeviceID.Text;
  2356. String dev_io = null;
  2357. //I-A-12-##
  2358. if (dev_id_s.Length > 8)
  2359. {
  2360. dev_io = dev_id_s.Substring(2, 1).Trim();
  2361. }
  2362. //코드를 찾는 모달창을 연다..
  2363. frmModalPositionCode frm = new frmModalPositionCode();
  2364. SearchCodeVo vo = new SearchCodeVo(null);
  2365. vo.Code = txtIOBoardPositionCode.Text;
  2366. vo.CodeName = txtIOBoardPositionName.Text;
  2367. frm.setMdiParent(this.mdi);
  2368. frm.SearchCode = vo;
  2369. frm.ShowDialog();
  2370. vo = frm.SearchCode;
  2371. //선택한 코드가 있다면
  2372. if (vo.SearchOK)
  2373. {
  2374. //선택한 코드값을 dataGridView2에 표시
  2375. txtIOBoardPositionCode.Text = vo.Code;
  2376. txtIOBoardPositionName.Text = vo.CodeName;
  2377. }
  2378. }
  2379. catch (Exception ex)
  2380. {
  2381. Util.UErrorMessage(ex, 0, 0);
  2382. }
  2383. }
  2384. #endregion
  2385. /******************************************************************************************************/
  2386. /******************************************************************************************************/
  2387. //#region 키패드 데이터 콘트롤
  2388. //private void btnKeypadEdit_Click(object sender, EventArgs e)
  2389. //{
  2390. // //입력모드로 변경한다.
  2391. // Keypad_cmd = QUERYMode.InsertAndUpdate;
  2392. // Util.GroupUIChange(panelKeypad, UIMode.input);
  2393. // btnKeypadEdit.Enabled = false;
  2394. // btnKeypadOK.Enabled = true;
  2395. // btnKeypadCancel.Enabled = true;
  2396. //}
  2397. //private void btnKeypadCancel_Click(object sender, EventArgs e)
  2398. //{
  2399. // //입력모드로 변경한다.
  2400. // Keypad_cmd = QUERYMode.select;
  2401. // Util.GroupUIChange(panelKeypad, UIMode.cancel);
  2402. // btnKeypadEdit.Enabled = true;
  2403. // btnKeypadOK.Enabled = false;
  2404. // btnKeypadCancel.Enabled = false;
  2405. //}
  2406. //private void btnKeypadOK_Click(object sender, EventArgs e)
  2407. //{
  2408. // if (Keypad_cmd == QUERYMode.InsertAndUpdate)
  2409. // {
  2410. // Util.ChkTxtBox(txtKeypadID, "키패드ID");
  2411. // Util.ChkTxtBox(txtKeypadName, "키패드명");
  2412. // Util.ChkComboBox(cboKeypadBaudRate, "Baud Rate");
  2413. // Util.ChkTxtBox(txtKeypadMainVersion, "Version");
  2414. // Util.ChkTxtBox(txtKeypadCommTerm, "송수신간격");
  2415. // Util.ChkOnlyLiteralTextBox(txtKeypadMainVersion, "Main Version");
  2416. // Util.ChkOnlyLiteralTextBox(txtKeypadSubVersion, "Sub Version");
  2417. // Util.ChkOnlyLiteralTextBox(txtKeypadCommTerm, "송수신간격");
  2418. // int KeypadID = Util.StrToInt(txtKeypadID.Text, 1);
  2419. // String KeypadName = txtKeypadName.Text.Trim();
  2420. // int BaudRate = Util.StrToInt(cboKeypadBaudRate.SelectedValue.ToString(), -1);
  2421. // int mainVer = Util.StrToInt(txtKeypadMainVersion.Text, -1);
  2422. // int subVer = Util.StrToInt(txtKeypadSubVersion.Text, 0);
  2423. // int CommTerm = Util.StrToInt(txtKeypadCommTerm.Text, -1);
  2424. // DacKeypadConfig dacKeypadConfig = new DacKeypadConfig();
  2425. // dacKeypadConfig.Keypad_Update(Keypad_cmd, mdi.myReceiverID, KeypadName, "Y", BaudRate, CommTerm, mainVer, subVer);
  2426. // }
  2427. // Keypad_cmd = QUERYMode.select;
  2428. // //VIEW모드로 변경한다.
  2429. // Util.GroupUIChange(panelKeypad, UIMode.cancel);
  2430. // //데이터 불러오기
  2431. // Keypad_getData();
  2432. // btnKeypadEdit.Enabled = true;
  2433. // btnKeypadOK.Enabled = false;
  2434. // btnKeypadCancel.Enabled = false;
  2435. //}
  2436. //private void Keypad_getData()
  2437. //{
  2438. // try
  2439. // {
  2440. // DacKeypadConfig dacKeypadConfig = new DacKeypadConfig();
  2441. // DataTable dt = dacKeypadConfig.Keypad_Select(mdi.myReceiverID, "Y");
  2442. // if (dt.Rows.Count > 0)
  2443. // {
  2444. // foreach (DataRow dr in dt.Rows)
  2445. // {
  2446. // txtKeypadID.Text = dr["BOARD_ID"].ToString();
  2447. // txtKeypadName.Text = dr["BOARD_NAME"].ToString();
  2448. // txtKeypadMainVersion.Text = dr["MAIN_VERSION"].ToString();
  2449. // txtKeypadSubVersion.Text = dr["SUB_VERSION"].ToString();
  2450. // cboKeypadBaudRate.SelectedValue = dr["BAUD_RATE"].ToString();
  2451. // txtKeypadCommTerm.Text = dr["COMM_TERM"].ToString();
  2452. // }
  2453. // }
  2454. // }
  2455. // catch (Exception ex)
  2456. // {
  2457. //MessageBox.Show(ex.Message, Application.ProductName);
  2458. // MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);
  2459. // }
  2460. //}
  2461. //#endregion
  2462. public void ReceiverConfigWriteAll()
  2463. {
  2464. try
  2465. {
  2466. if (MessageBox.Show("[전체]수신기에 전체 중계기 정보 쓰기를 수행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  2467. {
  2468. timer.Enabled = true;
  2469. timer.Interval = 1000;
  2470. timer.Tick += new EventHandler(time_tick);
  2471. timer.Start();
  2472. this.panel1.Enabled = false;
  2473. mdi.panel8.Enabled = false;
  2474. btnReceiverConfigWriteAll.Enabled = false;
  2475. panel_Menu.Enabled = false;
  2476. this.Cursor = Cursors.WaitCursor;
  2477. // cyim 2015.2.10 수신기설정-전체중계기 쓰기 실행
  2478. mdi.CommandLog(MappingStatus.Log, string.Format("수신기설정-전체중계기 쓰기"));
  2479. //2010.12.05, k.s.d, repeater information unit write -> don't use.
  2480. ///******************************************/
  2481. ///* 중계기 쓰기 Progress 표시 */
  2482. ///******************************************/
  2483. //frmProgress frm = new frmProgress();
  2484. ////중계기 설정 데이터를 CmdInfo에 넣어준다..
  2485. //CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_info_unit, mdi.myReceiverID);
  2486. //cmd.boardNo = 0; //전체 보드ID
  2487. ////ReceiverTypeInfo Receiverinfo = this.mdi.ui.MyReceiverTypeInfo; //수신기설정
  2488. ////cmd.CommandData = Receiverinfo; //화면에 설정된 데이터를 쓰기데이터로 이용한다.
  2489. //frm.Commandinfo = cmd;
  2490. //frm.ui = this.mdi.ui;
  2491. //frm.ShowDialog();
  2492. ///******************************************/
  2493. ////lblReceiverConfigChangeFlag.ForeColor;
  2494. //2010.12.05, k.s.d, repeater information block write.
  2495. btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);
  2496. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false;
  2497. // cyim 2017.01.12 : 등록된 통신보드 및 중계반 계통만 전체중계기쓰기 시도하자
  2498. InfoWriteBoardNo = 0;
  2499. InfoWriteLoopNo = 0;
  2500. if (formBoardDataDownload == null || formBoardDataDownload.Created != true)
  2501. {
  2502. formBoardDataDownload = new FormBoardDataDownload(this);
  2503. //formBoardDataDownload.MdiParent = this.mdi;
  2504. }
  2505. progress = -1;
  2506. this.downloadResult = true;
  2507. this.LoadBoardData();
  2508. formBoardDataDownload.SetBoardData(this.LTBoard, mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  2509. formBoardDataDownload.SetMessage("통신보드 데이터 다운로드");
  2510. formBoardDataDownload.Show();
  2511. formBoardDataDownload.Location = new Point(400, 200);
  2512. // 간헐적으로 화면이 갱신이 되지 않는다
  2513. formBoardDataDownload.Update();
  2514. System.Threading.Thread.Sleep(1000);
  2515. // LCH 2018.02.27 : 수정됨
  2516. // 클리어
  2517. ArrayList_ComInfo.Clear();
  2518. ArrayList_ComLevelInfo.Clear();
  2519. Hashtable_ComLevelInfo_Data.Clear();
  2520. level_num = 0;
  2521. DoWriteRepeaterInfoAll();
  2522. this.Cursor = Cursors.Default;
  2523. }
  2524. }
  2525. catch (Exception ex)
  2526. {
  2527. Util.UErrorMessage(ex, 0, 0);
  2528. this.Cursor = Cursors.Default;
  2529. }
  2530. }
  2531. private int time = 0;
  2532. public Timer timer = new System.Windows.Forms.Timer();
  2533. private void time_tick(object sender, EventArgs e)
  2534. {
  2535. time++;
  2536. if (time > 60 * 5)
  2537. {
  2538. time = 0;
  2539. timer.Enabled = false;
  2540. panel_Menu.Enabled = true;
  2541. btnReceiverConfigWriteAll.Enabled = true;
  2542. mdi.panel8.Enabled = true;
  2543. this.panel1.Enabled = true;
  2544. this.formBoardDataDownload.button1.Text = "확인";
  2545. this.formBoardDataDownload.button1.Visible = true;
  2546. MessageBox.Show("시간이 초과되었습니다(5분).", Application.ProductName);
  2547. return;
  2548. }
  2549. }
  2550. private void btnReceiverConfigWriteAll_Click(object sender, EventArgs e)
  2551. {
  2552. // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상
  2553. this.panel_Menu.Focus();
  2554. this.ReceiverConfigWriteAll();
  2555. }
  2556. // cyim 2017.01.12 : 등록된 통신보드 및 중계반 계통만 전체중계기쓰기 시도하자
  2557. // 소스 분석결과 이는 응답이 오면 다시 호출되는 재귀함수이다. 문제는 등록되지 않는 중계기까지 접근하니 비효율적인 함수이다
  2558. // 하단의 중복된 코드들은 그대로 둔다... -_-;..재귀함수에다가 GetResponseWriteRepeaterInfoBlock(null); 도 그대로 일단 두도록 한다
  2559. //2010.12.05, k.s.d, repeater information block write.
  2560. int InfoWriteBoardNo = 0;
  2561. int InfoWriteLoopNo = 0;
  2562. int progress = 0;
  2563. FormBoardDataDownload formBoardDataDownload = null;
  2564. bool downloadResult = true;
  2565. // LCH 2018.02.27 : 수정됨
  2566. ArrayList ArrayList_ComInfo = new ArrayList(); // DB에 사용으로 되어 있는 통신보드,채널 정보 저장
  2567. ArrayList ArrayList_ComLevelInfo = new ArrayList(); // DB에 사용으로 되어 있는 통신보드,채널 정보 중에 실질적으로 레벨 정보를 전송할 통신보드,채널 정보 저장
  2568. Hashtable Hashtable_ComLevelInfo_Data = new Hashtable(); // key : Loop:Board,Data : CmdInfo // 레벨 전송 데이터 저장
  2569. private void DoWriteRepeaterInfoAll()
  2570. {
  2571. try
  2572. {
  2573. this.progress++;
  2574. if (mdi.ReceiverModel == "IFC3300")
  2575. {
  2576. double tempcnt = this.progress;
  2577. tempcnt = Math.Round((tempcnt / (65 * 4)) * 100);
  2578. this.formBoardDataDownload.SetProgress(Convert.ToInt32(tempcnt));
  2579. }
  2580. else
  2581. {
  2582. double tempcnt = this.progress;
  2583. tempcnt = Math.Round((tempcnt / (17 * 4)) * 100);
  2584. this.formBoardDataDownload.SetProgress(Convert.ToInt32(tempcnt));
  2585. }
  2586. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  2587. int boardID_cnt = 0;
  2588. // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
  2589. if (mdi.ReceiverModel == "IFC3300")
  2590. {
  2591. boardID_cnt = 65;
  2592. }
  2593. else
  2594. {
  2595. boardID_cnt = 16;
  2596. }
  2597. // 단, 3300 이하 모델에서는 보드아이디 0 을 허용하지 않는다
  2598. if (mdi.ReceiverModel != "IFC3300" && InfoWriteBoardNo == 0)
  2599. InfoWriteBoardNo = 1; // cyim 2017.01.19 : IFC3300 이하 모델에서 1번보드 부터 전체중계기 쓰기한다
  2600. // 등록중인 보드 아이디인지 체크
  2601. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID);
  2602. string sql = string.Format("select * from TB_BOARD where RECEIVER_ID='{0}' and BOARD_ID='{1}' and USE_FLAG='Y' and LOOP{2}_USE_FLAG='Y'",
  2603. mdi.myReceiverID, InfoWriteBoardNo, InfoWriteLoopNo);
  2604. DataSet data = dacBoardConfig.Select(sql);
  2605. if (data.Tables[0].Rows != null && data.Tables[0].Rows.Count > 0)
  2606. {
  2607. // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
  2608. if (InfoWriteBoardNo < boardID_cnt)
  2609. {
  2610. if (DoWriteRepeaterInfoBlock(InfoWriteLoopNo, InfoWriteBoardNo) == false)
  2611. {
  2612. Count_Edit();
  2613. GetResponseWriteRepeaterInfoBlock(null);
  2614. }
  2615. else
  2616. Count_Edit();
  2617. }
  2618. else // 초과하면
  2619. {
  2620. Count_Edit();
  2621. GetResponseWriteRepeaterInfoBlock(null);
  2622. }
  2623. }
  2624. else
  2625. {
  2626. Count_Edit();
  2627. GetResponseWriteRepeaterInfoBlock(null);
  2628. }
  2629. }
  2630. catch (Exception ex)
  2631. {
  2632. Util.UErrorMessage(ex, 0, 0);
  2633. }
  2634. }
  2635. private void Count_Edit()
  2636. {
  2637. //System.Threading.Thread.Sleep(300);
  2638. // IFC3300 모델은 초기값이 0으로 들어오면 된다
  2639. if (mdi.ReceiverModel == "IFC3300")
  2640. {
  2641. if (InfoWriteLoopNo == 3)
  2642. {
  2643. InfoWriteLoopNo = 0;
  2644. InfoWriteBoardNo++;
  2645. }
  2646. else if (InfoWriteLoopNo == 2)
  2647. InfoWriteLoopNo = 3;
  2648. else if (InfoWriteLoopNo == 1)
  2649. InfoWriteLoopNo = 2;
  2650. else
  2651. InfoWriteLoopNo = 1;
  2652. }
  2653. else
  2654. {
  2655. if (InfoWriteLoopNo == 1)
  2656. {
  2657. InfoWriteLoopNo = 0;
  2658. InfoWriteBoardNo++;
  2659. }
  2660. else
  2661. {
  2662. InfoWriteLoopNo = 1;
  2663. }
  2664. }
  2665. }
  2666. private bool DoWriteRepeaterInfoBlock(int LoopNo, int BoardNo)
  2667. {
  2668. //Util.UDebugMessage("+DoWriteRepeaterInfoBlock", 0, 0);
  2669. bool bret = false;
  2670. try
  2671. {
  2672. if (ISBoardAndLoop(BoardNo, LoopNo)) // cyim
  2673. {
  2674. // LCH 2018.02.27 : 수정됨
  2675. // DB에 사용으로 되어 있는 통신보드,채널 정보 저장
  2676. ArrayList_ComInfo.Add(InfoWriteLoopNo.ToString() + ";" + InfoWriteBoardNo.ToString());
  2677. CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_repeater_info_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null);
  2678. dCommandResponse deleg = new dCommandResponse(GetResponseWriteRepeaterInfoBlock);
  2679. commandinfo.dEvent = deleg;
  2680. RepeaterDataAll RepaterDataAll = new RepeaterDataAll();
  2681. RepeaterDeviceTypeInfo[] RepeaterInfo = new RepeaterDeviceTypeInfo[127];
  2682. for (int i = 0; i < 127; i++)
  2683. {
  2684. RepeaterInfo[i] = new RepeaterDeviceTypeInfo(i + 1);
  2685. }
  2686. DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2687. DataTable dt = dacRepeaterConfig.Repeater_Select(mdi.myReceiverID, BoardNo, LoopNo, 0, null);
  2688. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2689. if (dt.Rows.Count > 0)
  2690. {
  2691. foreach (DataRow dr in dt.Rows)
  2692. {
  2693. Boolean FireResetFlag = false;
  2694. String RepeaterID = Convert.ToString(dr["REPEATER_ID"]);
  2695. int iRepeaterID = int.Parse(RepeaterID);
  2696. if (iRepeaterID == 128)
  2697. break;
  2698. String RepeaterType = Convert.ToString(dr["REPEATER_TYPE"]);
  2699. Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;
  2700. Boolean CutFlag = Convert.ToString(dr["CUT_FLAG"]) == "Y" ? true : false;
  2701. Boolean sFireResetFlag = false;
  2702. if (UseFlag && !FireResetFlag)
  2703. {
  2704. FireResetFlag = sFireResetFlag;
  2705. }
  2706. // cyim 2015.6.8 아날로그 감지기 연동 추가
  2707. // '1' = A : 2X2
  2708. // '2' = B : 4X4
  2709. // '4' = C : 아날로그연감지기
  2710. // '5' = D : 아날로그열감지기
  2711. String repeaterType = "";
  2712. if (RepeaterType.Equals("1"))
  2713. repeaterType = "A";
  2714. else if (RepeaterType.Equals("2"))
  2715. repeaterType = "B";
  2716. else if (RepeaterType.Equals("4"))
  2717. repeaterType = "C";
  2718. else if (RepeaterType.Equals("5"))
  2719. repeaterType = "D";
  2720. if (!repeaterType.Equals(""))
  2721. {
  2722. RepeaterInfo[iRepeaterID - 1].CutFlag = CutFlag;
  2723. RepeaterInfo[iRepeaterID - 1].UseFlag = true;
  2724. RepeaterInfo[iRepeaterID - 1].RepeaterType = repeaterType;
  2725. RepeaterInfo[iRepeaterID - 1].FireResetFlag = sFireResetFlag;
  2726. }
  2727. else
  2728. {
  2729. RepeaterInfo[iRepeaterID - 1].UseFlag = false;
  2730. }
  2731. }
  2732. }
  2733. for (int i = 0; i < 127; i++)
  2734. {
  2735. int RepeaterSet = 0;
  2736. if (RepeaterInfo[i].UseFlag)
  2737. {
  2738. if (RepeaterInfo[i].RepeaterType == "A")
  2739. RepeaterSet = 1;
  2740. else if (RepeaterInfo[i].RepeaterType == "B")
  2741. RepeaterSet = 2;
  2742. else if (RepeaterInfo[i].RepeaterType == "C")
  2743. RepeaterSet = 4;
  2744. else if (RepeaterInfo[i].RepeaterType == "D")
  2745. RepeaterSet = 5;
  2746. }
  2747. RepaterDataAll.Data[i].Set_Info_Data(RepeaterInfo[i].CutFlag, RepeaterInfo[i].FireResetFlag, false, false, RepeaterSet);
  2748. }
  2749. commandinfo.CommandData = RepaterDataAll;
  2750. this.mdi.ui.runCommand(commandinfo);
  2751. bret = true;
  2752. }
  2753. }
  2754. catch (Exception ex)
  2755. {
  2756. Util.UErrorMessage(ex, 0, 0);
  2757. }
  2758. //Util.UDebugMessage("-DoWriteRepeaterInfoBlock", 0, 0);
  2759. return bret;
  2760. }
  2761. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  2762. private bool ISBoardAndLoop(int BoardNo, int LoopNo)
  2763. {
  2764. bool bret = false;
  2765. try
  2766. {
  2767. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  2768. DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, BoardNo, null);
  2769. Boolean UseFlag = false;
  2770. Boolean Loop0UseFlag = false;
  2771. Boolean Loop1UseFlag = false;
  2772. Boolean Loop2UseFlag = false;
  2773. Boolean Loop3UseFlag = false;
  2774. if (dt.Rows.Count > 0)
  2775. {
  2776. foreach (DataRow dr in dt.Rows)
  2777. {
  2778. int BoardId = int.Parse(Convert.ToString(dr[0]));
  2779. if (BoardId == BoardNo)
  2780. {
  2781. Loop0UseFlag = Convert.ToString(dr["LOOP0_USE_FLAG"]) == "Y" ? true : false;
  2782. Loop1UseFlag = Convert.ToString(dr["LOOP1_USE_FLAG"]) == "Y" ? true : false;
  2783. Loop2UseFlag = Convert.ToString(Util.NullToStr(dr["LOOP2_USE_FLAG"])) == "Y" ? true : false;
  2784. Loop3UseFlag = Convert.ToString(Util.NullToStr(dr["LOOP3_USE_FLAG"])) == "Y" ? true : false;
  2785. UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;
  2786. }
  2787. }
  2788. }
  2789. if (UseFlag)
  2790. {
  2791. if (LoopNo == 0)
  2792. {
  2793. bret = Loop0UseFlag;
  2794. }
  2795. else if (LoopNo == 1)
  2796. {
  2797. bret = Loop1UseFlag;
  2798. }
  2799. else if (LoopNo == 2)
  2800. {
  2801. bret = Loop2UseFlag;
  2802. }
  2803. else if (LoopNo == 3)
  2804. {
  2805. bret = Loop3UseFlag;
  2806. }
  2807. }
  2808. else
  2809. {
  2810. bret = false;
  2811. }
  2812. }
  2813. catch (Exception ex)
  2814. {
  2815. Util.UErrorMessage(ex, 0, 0);
  2816. }
  2817. return bret;
  2818. }
  2819. public void GetResponseWriteRepeaterInfoBlock(CmdInfo resInfo)
  2820. {
  2821. try
  2822. {
  2823. if (resInfo != null)
  2824. {
  2825. //general_ack = 0x81, //응답-정상
  2826. //general_nack = 0x80, //응답-실패
  2827. switch (resInfo.ResCommand)
  2828. {
  2829. case prt_res_define.general_ack:
  2830. {
  2831. this.formBoardDataDownload.SetBoardDataDownloadResult(resInfo.boardNo, resInfo.loopNo, 1, mdi);
  2832. // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기
  2833. // 코드 분석 결과 대용량 수신기의 경우 아날로그 감지기 레벨을 일괄적으로 통신으로 보내야되는데
  2834. // 기존의 통신보드 및 중계기 셋팅하는 코드 다음에 다시 사이클이 돌아가는 것보다 실제로 통신이 성공한 통신보드에 한해서
  2835. // 레벨값을 일괄적으로 쓰는 것이 옳다고 판단한다
  2836. // 테스트를 위해 잠시 삭제
  2837. //DoWriteAnalogDetecterLevelBlock(resInfo.boardNo, resInfo.loopNo);
  2838. break;
  2839. }
  2840. case prt_res_define.general_nack:
  2841. {
  2842. this.formBoardDataDownload.SetBoardDataDownloadResult(resInfo.boardNo, resInfo.loopNo, 0, mdi);
  2843. this.downloadResult = false;
  2844. break;
  2845. }
  2846. case 0:
  2847. {
  2848. if (this.formBoardDataDownload != null && this.formBoardDataDownload.Created)
  2849. {
  2850. this.formBoardDataDownload.Close();
  2851. this.formBoardDataDownload = null;
  2852. }
  2853. timer.Enabled = false;
  2854. panel_Menu.Enabled = true;
  2855. btnReceiverConfigWriteAll.Enabled = true;
  2856. mdi.panel8.Enabled = true;
  2857. this.panel1.Enabled = true;
  2858. MessageBox.Show("통신데몬과 연결이 되어야합니다.", Application.ProductName);
  2859. return;
  2860. }
  2861. }
  2862. }
  2863. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  2864. int boardID_cnt = 0;
  2865. // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
  2866. if (mdi.ReceiverModel == "IFC3300")
  2867. {
  2868. boardID_cnt = 64;//64
  2869. }
  2870. else
  2871. {
  2872. boardID_cnt = 16;
  2873. }
  2874. // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
  2875. if (InfoWriteBoardNo > boardID_cnt)
  2876. {
  2877. // LCH 2018.02.27 : 수정됨
  2878. if (ArrayList_ComInfo.Count != 0) // 전송할 정보 있음
  2879. {
  2880. // 레벨값 전송
  2881. DoWriteAnalogDetecterLevelBlock(ArrayList_ComInfo);
  2882. }
  2883. else // 전송할 정보 없음
  2884. {
  2885. //FormBoardDataDownload.SetMessage("설정정보가 변경되어 데몬을 Reset하였습니다.");
  2886. //mdi.ui.ReceiverDBRead();
  2887. //mdi.FireReset_Process();
  2888. this.Cursor = Cursors.Default;
  2889. if (this.downloadResult)
  2890. {
  2891. this.formBoardDataDownload.SetSucess();
  2892. }
  2893. else
  2894. {
  2895. this.formBoardDataDownload.SetFalse();
  2896. }
  2897. }
  2898. }
  2899. else
  2900. {
  2901. DoWriteRepeaterInfoAll();
  2902. }
  2903. }
  2904. catch (Exception ex)
  2905. {
  2906. this.Cursor = Cursors.Default;
  2907. Util.UErrorMessage(ex, 0, 0);
  2908. }
  2909. }
  2910. // LCH 2018.02.27 : 수정됨
  2911. // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기
  2912. //private bool DoWriteAnalogDetecterLevelBlock(int LoopNo, int BoardNo)
  2913. private bool DoWriteAnalogDetecterLevelBlock(ArrayList ArrayList_ComInfo)
  2914. {
  2915. bool bret = false;
  2916. try
  2917. {
  2918. for (int i = 0; i < ArrayList_ComInfo.Count; i++)
  2919. {
  2920. string[] temp = ((string)ArrayList_ComInfo[i]).Split(';');
  2921. int LoopNo = Int32.Parse(temp[0]);
  2922. int BoardNo = Int32.Parse(temp[1]);
  2923. int boardID_cnt1;
  2924. if (mdi.ReceiverModel == "IFC3300")
  2925. {
  2926. boardID_cnt1 = 64;//64
  2927. }
  2928. else
  2929. {
  2930. boardID_cnt1 = 16;
  2931. }
  2932. //20200626
  2933. //보드 64이내 아날로그 감지기 레벨 쓰기 작동을 안해 수정(조건문 제거)
  2934. if (BoardNo <= boardID_cnt1)
  2935. {
  2936. CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_analogdetecter_level_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null);
  2937. // 응답처리는 하지않음. 차후 삭제 예정
  2938. dCommandResponse deleg = new dCommandResponse(GetResponseWriteAnalogDetecterLevelBlock);
  2939. commandinfo.dEvent = deleg;
  2940. RepeaterDataAll RepaterDataAll = new RepeaterDataAll();
  2941. // 데이타베이스에는 아날로그 감지기 레벨값만 들어있는 테이블이 따로 존재한다
  2942. DataTable dt = LoadAnalogDetecterLevel(mdi.myReceiverID, BoardNo, LoopNo, 0); // 아이디가 0 이면 해당 계통 전체를 검색
  2943. if (dt.Rows.Count > 0)
  2944. {
  2945. foreach (DataRow dr in dt.Rows)
  2946. {
  2947. String RepeaterID = Convert.ToString(dr["REPEATER_ID"]);
  2948. int iRepeaterID = int.Parse(RepeaterID);
  2949. RepaterDataAll.Data[iRepeaterID - 1].Set_Level_AnalogDetecter(
  2950. Convert.ToByte(dr["FAULT_VALUE"]),
  2951. Convert.ToByte(dr["PREFIRE_VALUE"]),
  2952. Convert.ToByte(dr["FIREN_VALUE"]),
  2953. Convert.ToByte(dr["FIRED_VALUE"])
  2954. );
  2955. }
  2956. // 단 해당하는 Loop 에 아날로그 감지기가 없으면 패킷 전송을 할 이유가 없다
  2957. commandinfo.CommandData = RepaterDataAll;
  2958. // 실질적으로 레벨 정보를 전송한 통신보드,채널 정보 저장
  2959. ArrayList_ComLevelInfo.Add(LoopNo.ToString() + ";" + BoardNo.ToString());
  2960. Hashtable_ComLevelInfo_Data.Add(LoopNo.ToString() + ";" + BoardNo.ToString(), commandinfo);
  2961. }
  2962. }
  2963. }
  2964. // 3300일때만 레벨을 전송한다
  2965. if (mdi.ReceiverModel == "IFC3300")
  2966. {
  2967. // 레벨을 전송 할 수 있는지 확인
  2968. if (ArrayList_ComLevelInfo.Count != 0)
  2969. {
  2970. // 첫번째만 출발
  2971. this.mdi.ui.runCommand((CmdInfo)Hashtable_ComLevelInfo_Data[(string)ArrayList_ComLevelInfo[0]]);
  2972. bret = true;
  2973. }
  2974. else // 전송할 레벨이 없다
  2975. {
  2976. this.formBoardDataDownload.SetFinish();
  2977. }
  2978. }
  2979. else
  2980. {
  2981. this.formBoardDataDownload.SetFinish();
  2982. }
  2983. }
  2984. catch (Exception ex)
  2985. {
  2986. Util.UErrorMessage(ex, 0, 0);
  2987. }
  2988. //Util.UDebugMessage("-DoWriteRepeaterInfoBlock", 0, 0);
  2989. return bret;
  2990. }
  2991. // LCH 2018.02.27 : 수정됨
  2992. int level_num = 0;
  2993. public void GetResponseWriteAnalogDetecterLevelBlock(CmdInfo resInfo)
  2994. {
  2995. try
  2996. {
  2997. if (resInfo != null)
  2998. {
  2999. //general_ack = 0xA2, //응답-정상
  3000. //general_nack = 0x80, //응답-실패
  3001. switch (resInfo.ResCommand)
  3002. {
  3003. case prt_res_define.write_analogdetecter_level_all:
  3004. {
  3005. //RCVData_ACK ResponseData = (RCVData_ACK)resInfo.ResponseData;
  3006. //GeneralBaseInfo baseInfo = (GeneralBaseInfo)ResponseData.Baseinfo;
  3007. //int boardNo = baseInfo.UnitID_u;
  3008. //int loopNo = baseInfo.UnitID_d;
  3009. //20200626 내용 수정 - RCVData_ACK 형변환에서 오류 발생
  3010. RCVData_WriteAnalogDetecterLevel2 ResponseData = (RCVData_WriteAnalogDetecterLevel2)resInfo.ResponseData;
  3011. int boardNo = ResponseData.Board_id;
  3012. int loopNo = ResponseData.Loop_no;
  3013. this.formBoardDataDownload.SetBoardDataDownloadResult(boardNo, loopNo, 1, mdi);
  3014. System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + boardNo.ToString() + " " + loopNo.ToString() + " 1" + "\r\n");
  3015. break;
  3016. }
  3017. case prt_res_define.general_nack:
  3018. {
  3019. RCVData_NACK ResponseData = (RCVData_NACK)resInfo.ErrResponseData;
  3020. GeneralBaseInfo baseInfo = (GeneralBaseInfo)ResponseData.Baseinfo;
  3021. int boardNo = baseInfo.UnitID_u;
  3022. int loopNo = baseInfo.UnitID_d;
  3023. this.formBoardDataDownload.SetBoardDataDownloadResult(boardNo, loopNo, 0, mdi);
  3024. System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + boardNo.ToString() + " " + loopNo.ToString() + " 0" + "\r\n");
  3025. break;
  3026. }
  3027. }
  3028. }
  3029. level_num++;
  3030. System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + level_num + "\r\n");
  3031. // 완료 버튼을 보이게 한다 lch 20180101
  3032. if (level_num == ArrayList_ComLevelInfo.Count)
  3033. {
  3034. this.formBoardDataDownload.SetFinish();
  3035. }
  3036. else
  3037. {
  3038. // 다음 패킷 출발
  3039. this.mdi.ui.runCommand((CmdInfo)Hashtable_ComLevelInfo_Data[(string)ArrayList_ComLevelInfo[level_num]]);
  3040. }
  3041. }
  3042. catch (Exception ex)
  3043. {
  3044. this.Cursor = Cursors.Default;
  3045. Util.UErrorMessage(ex, 0, 0);
  3046. }
  3047. }
  3048. public void ResetDemon()
  3049. {
  3050. //mdi.ui.ReceiverDBRead();
  3051. //mdi.FireReset_Process();
  3052. //
  3053. // cyim 2013.6.27 : 수신기 설정 -> 중계기 쓰기 버튼 이후 데몬 초기화 되지 않는 문제 (상위주석처리)
  3054. //
  3055. mdi.FireReset_Process();
  3056. mdi.socketUI.ReceiverDemonReset();
  3057. }
  3058. private void frmReceiverConfig_FormClosing(object sender, FormClosingEventArgs e)
  3059. {
  3060. if (this.formBoardDataDownload != null && this.formBoardDataDownload.Created)
  3061. {
  3062. this.formBoardDataDownload.Close();
  3063. this.formBoardDataDownload = null;
  3064. }
  3065. }
  3066. //
  3067. // cyim 2013.7.10 디자인개선작업 : 수신기설정
  3068. //
  3069. // 수신기 버튼
  3070. private void button_Menu_Receiver_Click(object sender, EventArgs e)
  3071. {
  3072. button_Menu_Color_Init();
  3073. this.tabControl_Main.SelectTab(0);
  3074. this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  3075. this.panel_Menu.Focus();
  3076. }
  3077. // 통신설정 버튼
  3078. private void button_Menu_CommSet_Click(object sender, EventArgs e)
  3079. {
  3080. // cyim 2014.5.7 : 통신설정메뉴 다시 불러오기
  3081. // 통신 설정의 경우 탭을 선택하면 무조건 데이타베이스에 있는 값을 읽어온다
  3082. Comm_getData();
  3083. button_Menu_Color_Init();
  3084. this.tabControl_Main.SelectTab(1);
  3085. this.button_Menu_CommSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  3086. this.panel_Menu.Focus();
  3087. }
  3088. // cyim 2016.12.13 : 수신기설정에서 IFC3300 의 경우에만 통신보드의 LOOP 0~3 으로 보여지도록 한다
  3089. private bool Check_List_ColumnText(string ColumnText)
  3090. {
  3091. for (int i = 0; i < this.listView_CommBoard.Columns.Count; i++)
  3092. {
  3093. ColumnHeader col_hr = (ColumnHeader)listView_CommBoard.Columns[i];
  3094. if (col_hr.Text == ColumnText)
  3095. {
  3096. return true;
  3097. }
  3098. }
  3099. return false;
  3100. }
  3101. private void CheckDel_List_ColumnText(string ColumnText)
  3102. {
  3103. ColumnHeader remove_col_hr = null;
  3104. for (int i = 0; i < this.listView_CommBoard.Columns.Count; i++)
  3105. {
  3106. ColumnHeader col_hr = (ColumnHeader)listView_CommBoard.Columns[i];
  3107. if (col_hr.Text == ColumnText)
  3108. {
  3109. listView_CommBoard.Columns.Remove(col_hr);
  3110. remove_col_hr = col_hr;
  3111. }
  3112. }
  3113. if (remove_col_hr != null)
  3114. listView_CommBoard.Columns.Remove(remove_col_hr);
  3115. }
  3116. // 통신보드 버튼
  3117. private void button_Menu_CommBoard_Click(object sender, EventArgs e)
  3118. {
  3119. // 통신보드 UI 컨셉이 변경될수 있다
  3120. if (mdi.ReceiverModel == "IFC3300")
  3121. {
  3122. this.chkLoop2UseFlag.Visible = true;
  3123. this.chkLoop3UseFlag.Visible = true;
  3124. if (Check_List_ColumnText("Loop2 사용여부") == false)
  3125. this.listView_CommBoard.Columns.Add("columnHeader_2", "Loop2 사용여부", 170, HorizontalAlignment.Center, 0);
  3126. if (Check_List_ColumnText("Loop3 사용여부") == false)
  3127. this.listView_CommBoard.Columns.Add("columnHeader_3", "Loop3 사용여부", 170, HorizontalAlignment.Center, 0);
  3128. this.listView_CommBoard.Update();
  3129. }
  3130. else
  3131. {
  3132. this.chkLoop2UseFlag.Visible = false;
  3133. this.chkLoop3UseFlag.Visible = false;
  3134. if (Check_List_ColumnText("Loop2 사용여부") == true)
  3135. CheckDel_List_ColumnText("Loop2 사용여부");
  3136. if (Check_List_ColumnText("Loop3 사용여부") == true)
  3137. CheckDel_List_ColumnText("Loop3 사용여부");
  3138. this.listView_CommBoard.Update();
  3139. }
  3140. button_Menu_Color_Init();
  3141. this.tabControl_Main.SelectTab(2);
  3142. this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  3143. this.panel_Menu.Focus();
  3144. }
  3145. // IO보드 버튼
  3146. private void button_Menu_IOBoard_Click(object sender, EventArgs e)
  3147. {
  3148. button_Menu_Color_Init();
  3149. this.tabControl_Main.SelectTab(3);
  3150. this.button_Menu_IOBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  3151. this.panel_Menu.Focus();
  3152. }
  3153. // 중계기 버튼
  3154. private void button_Menu_Repeater_Click(object sender, EventArgs e)
  3155. {
  3156. button_Menu_Color_Init();
  3157. this.tabControl_Main.SelectTab(4);
  3158. this.button_Menu_Repeater.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  3159. this.panel_Menu.Focus();
  3160. }
  3161. // 버튼 색상 초기화
  3162. private void button_Menu_Color_Init()
  3163. {
  3164. this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  3165. this.button_Menu_CommSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  3166. this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  3167. this.button_Menu_IOBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  3168. this.button_Menu_Repeater.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  3169. }
  3170. /******************************************************************************************************/
  3171. #region 중계기 및 회로 설정
  3172. //중계기및 회로 설정정보
  3173. RepeaterDeviceTypeInfo[] REP = new RepeaterDeviceTypeInfo[127];
  3174. private void cboBoardList_SelectedIndexChanged(object sender, EventArgs e)
  3175. {
  3176. try
  3177. {
  3178. if (cboBoardList.SelectedValue != null)
  3179. {
  3180. String BoardId = cboBoardList.SelectedValue.ToString();
  3181. //cboLoopList
  3182. DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  3183. ArrayList ary = dacBoardConfig.Loop_List(mdi.myReceiverID, int.Parse(BoardId));
  3184. Util.ComboSetting(cboLoopList, ary, null);
  3185. }
  3186. else
  3187. {
  3188. Util.ComboSetting(cboLoopList, null, null);
  3189. }
  3190. Repeater_getDate();
  3191. }
  3192. catch (Exception ex)
  3193. {
  3194. Util.UErrorMessage(ex, 0, 0);
  3195. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  3196. }
  3197. }
  3198. private void Repeater_init()
  3199. {
  3200. try
  3201. {
  3202. //dataGridView1,dataGridView2
  3203. try
  3204. {
  3205. this.dataGridView_Repeater_Main.Columns.Clear();
  3206. }
  3207. catch (Exception ex)
  3208. {
  3209. Util.UErrorMessage(ex, 0, 0);
  3210. }
  3211. /************************************************************************/
  3212. /* dataGridView1 헤더 설정 */
  3213. /************************************************************************/
  3214. DataGridViewCellStyle sty = new DataGridViewCellStyle();
  3215. sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3216. for (int col = 0; col < 10; col++)
  3217. {
  3218. dataGridView_Repeater_Main.Columns.Add(new DataGridViewTextBoxColumn());
  3219. dataGridView_Repeater_Main.Columns[col].ReadOnly = true;
  3220. dataGridView_Repeater_Main.Columns[col].Resizable = DataGridViewTriState.False;
  3221. dataGridView_Repeater_Main.Columns[col].Width = 70;
  3222. dataGridView_Repeater_Main.Columns[col].DefaultCellStyle = sty;
  3223. }
  3224. /************************************************************************/
  3225. /************************************************************************/
  3226. /* dataGridView1 Row 생성.. 총 127개 Cell */
  3227. /************************************************************************/
  3228. this.dataGridView_Repeater_Main.Rows.Clear();
  3229. DataGridViewRowCollection rows = this.dataGridView_Repeater_Main.Rows;
  3230. for (int row = 0; row <= 12; row++)
  3231. {
  3232. String[] rowData = new String[10];
  3233. for (int col = 1; col <= 10; col++)
  3234. {
  3235. int no = row * 10 + col;
  3236. if (no <= 127)
  3237. {
  3238. rowData[col - 1] = String.Format("{0:000}", no);
  3239. REP[no - 1] = new RepeaterDeviceTypeInfo(no); //중계기및 회로 설정정보
  3240. }
  3241. }
  3242. rows.Add(rowData);
  3243. }
  3244. /************************************************************************/
  3245. //중계기 설정내용 표시
  3246. RepeaterStatus("");
  3247. chkSelectAll.Text = "전체선택";
  3248. chkSelectAll.Checked = false;
  3249. }
  3250. catch (Exception ex)
  3251. {
  3252. Util.UErrorMessage(ex, 0, 0);
  3253. throw ex;
  3254. }
  3255. }
  3256. private void Device_Init(String Type)
  3257. {
  3258. try
  3259. {
  3260. this.dataGridView_Repeater_Sub.Columns.Clear();
  3261. mskDeviceID.Text = "";
  3262. txtDeviceTypeCode.Text = "";
  3263. txtDeviceTypeName.Text = "";
  3264. txtPositionCode.Text = "";
  3265. txtPositionName.Text = "";
  3266. txtDeviceMemo.Text = "";
  3267. }
  3268. catch (Exception ex)
  3269. {
  3270. Util.UErrorMessage(ex, 0, 0);
  3271. }
  3272. try
  3273. {
  3274. if (Type == null) return;
  3275. /************************************************************************/
  3276. /* dataGridView2 헤더 설정 */
  3277. /************************************************************************/
  3278. // 사용
  3279. DataGridViewCellStyle sty2 = new DataGridViewCellStyle();
  3280. sty2.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3281. sty2.BackColor = System.Drawing.Color.White;
  3282. sty2.Font = new System.Drawing.Font("굴림", 12);
  3283. // 비사용
  3284. DataGridViewCellStyle styGray = new DataGridViewCellStyle();
  3285. styGray.Alignment = DataGridViewContentAlignment.MiddleLeft;
  3286. styGray.BackColor = System.Drawing.Color.LightGray;
  3287. styGray.SelectionBackColor = System.Drawing.Color.Gray;
  3288. styGray.Font = new System.Drawing.Font("굴림", 12);
  3289. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3290. // 아래의 타입 전부 허용
  3291. // '1' = A : 2X2
  3292. // '2' = B : 4X4
  3293. // '4' = C : 아날로그연감지기
  3294. // '5' = D : 아날로그열감지기
  3295. for (int i = 0; i < 8; i++)
  3296. {
  3297. dataGridView_Repeater_Sub.Columns.Add(new DataGridViewTextBoxColumn());
  3298. ((DataGridViewTextBoxColumn)dataGridView_Repeater_Sub.Columns[i]).MaxInputLength = 2;
  3299. dataGridView_Repeater_Sub.Columns[i].ReadOnly = true;
  3300. dataGridView_Repeater_Sub.Columns[i].Resizable = DataGridViewTriState.False;
  3301. dataGridView_Repeater_Sub.Columns[i].Width = 70;
  3302. if (Type.Equals("A") && (i == 2 || i == 3 || i == 6 || i == 7))
  3303. dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = styGray;
  3304. else if ((Type.Equals("C") || Type.Equals("D")) && (i == 1 || i == 2 || i == 3 || i == 5 || i == 6 || i == 7))
  3305. dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = styGray;
  3306. else
  3307. dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = sty2;
  3308. dataGridView_Repeater_Sub.Columns[i].HeaderText = i < 4 ? "I" : "O";
  3309. dataGridView_Repeater_Sub.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  3310. }
  3311. // 하단 문구 초기화
  3312. mskDeviceID.Text = "";
  3313. txtDeviceTypeCode.Text = "";
  3314. txtDeviceTypeName.Text = "";
  3315. txtPositionCode.Text = "";
  3316. txtPositionName.Text = "";
  3317. txtDeviceMemo.Text = "";
  3318. }
  3319. catch (Exception ex)
  3320. {
  3321. Util.UErrorMessage(ex, 0, 0);
  3322. }
  3323. }
  3324. //선택값이 틀릴때마다 해당중계기 설정내용 radio에 표시
  3325. private void dataGridView1_SelectionChanged(object sender, EventArgs e)
  3326. {
  3327. try
  3328. {
  3329. if (dataGridView_Repeater_Main.SelectedCells.Count > 1)
  3330. {
  3331. lblRepeaterID.Text = "";
  3332. String RepeaterTypeSaved = "";
  3333. Boolean RepeaterUse = true;
  3334. //Boolean outFlag = true;
  3335. foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells)
  3336. {
  3337. if (cell.Value != null)
  3338. {
  3339. String value = cell.Value.ToString();
  3340. if (value.Length > 3)
  3341. {
  3342. String RepeaterType = value.Substring(0, 1);
  3343. if (RepeaterTypeSaved.Equals("")) RepeaterTypeSaved = RepeaterType;
  3344. else if (!RepeaterTypeSaved.Equals(RepeaterType)) RepeaterTypeSaved = "Un Incorrect";
  3345. //if (cell.Style.BackColor == System.Drawing.Color.Silver && outFlag) outFlag = true; else outFlag = false;
  3346. }
  3347. else
  3348. {
  3349. RepeaterTypeSaved = "Un Incorrect";
  3350. RepeaterUse = false;
  3351. }
  3352. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3353. if (RepeaterUse && !(RepeaterTypeSaved.Equals("A") || RepeaterTypeSaved.Equals("B") || RepeaterTypeSaved.Equals("C") || RepeaterTypeSaved.Equals("D")))
  3354. RepeaterTypeSaved = "USED";
  3355. RepeaterTypeRadio(RepeaterTypeSaved);
  3356. }
  3357. }
  3358. }
  3359. else
  3360. {
  3361. try
  3362. {
  3363. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  3364. object value = cell.Value;
  3365. if (value == null) RepeaterStatus("");
  3366. else
  3367. {
  3368. //Boolean outFlag = false;
  3369. //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true;
  3370. RepeaterStatus(value.ToString());
  3371. //RepeaterTypeRadio(value.ToString(), outFlag);
  3372. }
  3373. }
  3374. catch (Exception ex)
  3375. {
  3376. Util.UErrorMessage(ex, 0, 0);
  3377. }
  3378. }
  3379. }
  3380. catch (Exception ex)
  3381. {
  3382. Util.UErrorMessage(ex, 0, 0);
  3383. }
  3384. }
  3385. //cell값으로 중계기 설정을 Radio버튼에 표시
  3386. private void RepeaterStatus(String CellText)
  3387. {
  3388. try
  3389. {
  3390. String RepeaterID = CellText;
  3391. String RepeaterType = "";
  3392. if (CellText.Length > 3)
  3393. {
  3394. RepeaterType = CellText.Substring(0, 1);
  3395. RepeaterID = CellText.Substring(1, 3);
  3396. }
  3397. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3398. lblRepeaterID.Text = RepeaterID;
  3399. switch (RepeaterType)
  3400. {
  3401. case "A":
  3402. case "B":
  3403. lblRepeaterName.Text = "중계기";
  3404. break;
  3405. case "C":
  3406. lblRepeaterName.Text = "연감지기";
  3407. break;
  3408. case "D":
  3409. lblRepeaterName.Text = "열감지기";
  3410. break;
  3411. }
  3412. RepeaterTypeRadio(RepeaterType);
  3413. }
  3414. catch (Exception ex)
  3415. {
  3416. Util.UErrorMessage(ex, 0, 0);
  3417. }
  3418. }
  3419. //셀의 타입으로 중계기 설정을 Radio버튼에 표시
  3420. private void RepeaterTypeRadio(String tp)
  3421. {
  3422. try
  3423. {
  3424. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3425. if (tp.Equals("A"))
  3426. {
  3427. rdoRepeaterType_A.Checked = true;
  3428. rdoRepeaterType_B.Checked = false;
  3429. rdoRepeaterType_C.Checked = false;
  3430. rdoRepeaterType_D.Checked = false;
  3431. chkRepeaterUse.Checked = true;
  3432. rdoRepeaterType1_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty);
  3433. }
  3434. else if (tp.Equals("B"))
  3435. {
  3436. rdoRepeaterType_A.Checked = false;
  3437. rdoRepeaterType_B.Checked = true;
  3438. rdoRepeaterType_C.Checked = false;
  3439. rdoRepeaterType_D.Checked = false;
  3440. chkRepeaterUse.Checked = true;
  3441. rdoRepeaterType2_CheckedChanged(rdoRepeaterType_B, System.EventArgs.Empty);
  3442. }
  3443. else if (tp.Equals("C"))
  3444. {
  3445. rdoRepeaterType_A.Checked = false;
  3446. rdoRepeaterType_B.Checked = false;
  3447. rdoRepeaterType_C.Checked = true;
  3448. rdoRepeaterType_D.Checked = false;
  3449. chkRepeaterUse.Checked = true;
  3450. rdoRepeaterType3_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty);
  3451. }
  3452. else if (tp.Equals("D"))
  3453. {
  3454. rdoRepeaterType_A.Checked = false;
  3455. rdoRepeaterType_B.Checked = false;
  3456. rdoRepeaterType_C.Checked = false;
  3457. rdoRepeaterType_D.Checked = true;
  3458. chkRepeaterUse.Checked = true;
  3459. rdoRepeaterType4_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty);
  3460. }
  3461. else if (tp.Equals("USED"))
  3462. {
  3463. rdoRepeaterType_A.Checked = false;
  3464. rdoRepeaterType_B.Checked = false;
  3465. rdoRepeaterType_C.Checked = false;
  3466. rdoRepeaterType_D.Checked = false;
  3467. chkRepeaterUse.Checked = true;
  3468. }
  3469. else
  3470. {
  3471. rdoRepeaterType_A.Checked = false;
  3472. rdoRepeaterType_B.Checked = false;
  3473. rdoRepeaterType_C.Checked = false;
  3474. rdoRepeaterType_D.Checked = false;
  3475. chkRepeaterUse.Checked = false;
  3476. DeviceStatus(null);
  3477. }
  3478. }
  3479. catch (Exception ex)
  3480. {
  3481. Util.UErrorMessage(ex, 0, 0);
  3482. }
  3483. }
  3484. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3485. // '1' = A : 2X2
  3486. // '2' = B : 4X4
  3487. // '4' = C : 아날로그연감지기
  3488. // '5' = D : 아날로그열감지기
  3489. private void rdoRepeaterType1_Click(object sender, EventArgs e)
  3490. {
  3491. try
  3492. {
  3493. if (rdoRepeaterType_A.Checked)
  3494. rdoRepeaterTypeChange("A");
  3495. }
  3496. catch (Exception ex)
  3497. {
  3498. Util.UErrorMessage(ex, 0, 0);
  3499. }
  3500. }
  3501. private void rdoRepeaterType2_Click(object sender, EventArgs e)
  3502. {
  3503. try
  3504. {
  3505. if (rdoRepeaterType_B.Checked)
  3506. rdoRepeaterTypeChange("B");
  3507. }
  3508. catch (Exception ex)
  3509. {
  3510. Util.UErrorMessage(ex, 0, 0);
  3511. }
  3512. }
  3513. private void rdoRepeaterType3_Click(object sender, EventArgs e)
  3514. {
  3515. try
  3516. {
  3517. if (rdoRepeaterType_C.Checked)
  3518. rdoRepeaterTypeChange("C");
  3519. }
  3520. catch (Exception ex)
  3521. {
  3522. Util.UErrorMessage(ex, 0, 0);
  3523. }
  3524. }
  3525. private void rdoRepeaterType4_Click(object sender, EventArgs e)
  3526. {
  3527. try
  3528. {
  3529. if (rdoRepeaterType_D.Checked)
  3530. rdoRepeaterTypeChange("D");
  3531. }
  3532. catch (Exception ex)
  3533. {
  3534. Util.UErrorMessage(ex, 0, 0);
  3535. }
  3536. }
  3537. //회로타입 표시
  3538. private void rdoRepeaterTypeChange(String RepeaterType)
  3539. {
  3540. try
  3541. {
  3542. DataGridViewCellStyle sty = new DataGridViewCellStyle();
  3543. sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3544. sty.BackColor = System.Drawing.Color.Aqua;
  3545. foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells)
  3546. {
  3547. if (cell.Value != null)
  3548. {
  3549. String value = cell.Value.ToString();
  3550. String RepeaterID = value;
  3551. if (value.Length > 3)
  3552. {
  3553. RepeaterID = value.Substring(1, 3);
  3554. }
  3555. cell.Value = RepeaterType + RepeaterID;
  3556. cell.Style = sty;
  3557. REP[int.Parse(RepeaterID) - 1].RepeaterType = RepeaterType;
  3558. REP[int.Parse(RepeaterID) - 1].UseFlag = true;
  3559. REP[int.Parse(RepeaterID) - 1].CutFlag = false;
  3560. }
  3561. }
  3562. //사용회로로 표시
  3563. chkRepeaterUse.Checked = true;
  3564. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨.
  3565. }
  3566. catch (Exception ex)
  3567. {
  3568. Util.UErrorMessage(ex, 0, 0);
  3569. }
  3570. }
  3571. private void chkRepeaterUse_Click(object sender, EventArgs e)
  3572. {
  3573. try
  3574. {
  3575. //사용-->비사용으로
  3576. if (chkRepeaterUse.Checked)
  3577. {
  3578. DataGridViewCellStyle sty = new DataGridViewCellStyle();
  3579. sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3580. sty.BackColor = System.Drawing.Color.White;
  3581. foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells)
  3582. {
  3583. if (cell.Value != null)
  3584. {
  3585. String value = cell.Value.ToString();
  3586. String RepeaterID = value;
  3587. if (value.Length > 3)
  3588. {
  3589. RepeaterID = value.Substring(1, 3);
  3590. REP[int.Parse(RepeaterID) - 1].UseFlag = false;
  3591. REP[int.Parse(RepeaterID) - 1].RepeaterType = "";
  3592. }
  3593. cell.Value = RepeaterID;
  3594. cell.Style = sty;
  3595. }
  3596. }
  3597. //비사용회로로 표시
  3598. chkRepeaterUse.Checked = false;
  3599. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨.
  3600. }
  3601. }
  3602. catch (Exception ex)
  3603. {
  3604. Util.UErrorMessage(ex, 0, 0);
  3605. }
  3606. }
  3607. //dataGridView2에 중계기 회로설정 화면생성
  3608. private void DeviceStatus(RepeaterDeviceTypeInfo dt)
  3609. {
  3610. try
  3611. {
  3612. if (dt == null)
  3613. {
  3614. Device_Init(null);
  3615. return;
  3616. }
  3617. Device_Init(dt.RepeaterType);
  3618. this.dataGridView_Repeater_Sub.Rows.Clear();
  3619. if (dt != null)
  3620. {
  3621. DataGridViewCellStyle sty_in = new DataGridViewCellStyle();
  3622. sty_in.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3623. sty_in.BackColor = System.Drawing.Color.Gold;
  3624. DataGridViewCellStyle sty_out = new DataGridViewCellStyle();
  3625. sty_out.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3626. sty_out.BackColor = System.Drawing.Color.MintCream;
  3627. if (dt.RepeaterType.Equals("A"))
  3628. {
  3629. string[] row1 = new string[] { "1", "2", "", "", "1", "2", "", "" };
  3630. this.dataGridView_Repeater_Sub.Rows.Add(row1);
  3631. DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;
  3632. //입력설정값
  3633. for (int i = 0; i < 2; i++)
  3634. rows2[0].Cells[i].Style = sty_in;
  3635. //출력설정값
  3636. for (int i = 0; i < 2; i++)
  3637. rows2[0].Cells[i + 4].Style = sty_out; // 인덱스 오류 수정
  3638. rows2[0].Height = 40;
  3639. }
  3640. else if (dt.RepeaterType.Equals("B"))
  3641. {
  3642. string[] row2 = new string[] { "1", "2", "3", "4", "1", "2", "3", "4" };
  3643. this.dataGridView_Repeater_Sub.Rows.Add(row2);
  3644. DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;
  3645. //입력설정값
  3646. for (int i = 0; i < 4; i++)
  3647. rows2[0].Cells[i].Style = sty_in;
  3648. //출력설정값
  3649. for (int i = 0; i < 4; i++)
  3650. rows2[0].Cells[i + 4].Style = sty_out;
  3651. rows2[0].Height = 40;
  3652. }
  3653. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3654. else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
  3655. {
  3656. string[] row1 = new string[] { "1", "", "", "", "1", "", "", "" };
  3657. this.dataGridView_Repeater_Sub.Rows.Add(row1);
  3658. DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;
  3659. //입력설정값
  3660. for (int i = 0; i < 1; i++)
  3661. rows2[0].Cells[i].Style = sty_in;
  3662. //출력설정값
  3663. for (int i = 0; i < 1; i++)
  3664. rows2[0].Cells[i + 4].Style = sty_out;
  3665. rows2[0].Height = 40;
  3666. }
  3667. }
  3668. }
  3669. catch (Exception ex)
  3670. {
  3671. Util.UErrorMessage(ex, 0, 0);
  3672. }
  3673. }
  3674. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3675. // '1' = A : 2X2
  3676. // '2' = B : 4X4
  3677. // '4' = C : 아날로그연감지기
  3678. // '5' = D : 아날로그열감지기
  3679. private void rdoRepeaterType1_CheckedChanged(object sender, EventArgs e)
  3680. {
  3681. try
  3682. {
  3683. if (rdoRepeaterType_A.Checked)
  3684. {
  3685. if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)
  3686. {
  3687. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  3688. if (cell.Value != null)
  3689. {
  3690. String value = cell.Value.ToString();
  3691. String RepeaterID = value;
  3692. if (value.Length > 3)
  3693. {
  3694. RepeaterID = value.Substring(1, 3);
  3695. }
  3696. //Boolean outFlag = false;
  3697. //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true;
  3698. //해당 중계기의 회로표시
  3699. RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  3700. dev.RepeaterType = "A";
  3701. DeviceStatus(dev);
  3702. }
  3703. }
  3704. else
  3705. {
  3706. DeviceStatus(null);
  3707. }
  3708. }
  3709. else
  3710. {
  3711. DeviceStatus(null);
  3712. }
  3713. }
  3714. catch (Exception ex)
  3715. {
  3716. Util.UErrorMessage(ex, 0, 0);
  3717. }
  3718. }
  3719. //중계기가 1개만 선택되었을때 회로 표시(4*4 회로)
  3720. private void rdoRepeaterType2_CheckedChanged(object sender, EventArgs e)
  3721. {
  3722. try
  3723. {
  3724. if (rdoRepeaterType_B.Checked)
  3725. {
  3726. if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)
  3727. {
  3728. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  3729. if (cell.Value != null)
  3730. {
  3731. String value = cell.Value.ToString();
  3732. String RepeaterID = value;
  3733. if (value.Length > 3)
  3734. {
  3735. RepeaterID = value.Substring(1, 3);
  3736. }
  3737. //Boolean outFlag = false;
  3738. //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true;
  3739. //해당 중계기의 회로표시
  3740. RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  3741. dev.RepeaterType = "B";
  3742. DeviceStatus(dev);
  3743. }
  3744. }
  3745. else
  3746. {
  3747. DeviceStatus(null);
  3748. }
  3749. }
  3750. else
  3751. {
  3752. DeviceStatus(null);
  3753. }
  3754. }
  3755. catch (Exception ex)
  3756. {
  3757. Util.UErrorMessage(ex, 0, 0);
  3758. }
  3759. }
  3760. private void rdoRepeaterType3_CheckedChanged(object sender, EventArgs e)
  3761. {
  3762. try
  3763. {
  3764. if (rdoRepeaterType_C.Checked)
  3765. {
  3766. if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)
  3767. {
  3768. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  3769. if (cell.Value != null)
  3770. {
  3771. String value = cell.Value.ToString();
  3772. String RepeaterID = value;
  3773. if (value.Length > 3)
  3774. {
  3775. RepeaterID = value.Substring(1, 3);
  3776. }
  3777. //해당 중계기의 회로표시
  3778. RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  3779. dev.RepeaterType = "C";
  3780. DeviceStatus(dev);
  3781. }
  3782. }
  3783. else
  3784. {
  3785. DeviceStatus(null);
  3786. }
  3787. }
  3788. else
  3789. {
  3790. DeviceStatus(null);
  3791. }
  3792. }
  3793. catch (Exception ex)
  3794. {
  3795. Util.UErrorMessage(ex, 0, 0);
  3796. }
  3797. }
  3798. private void rdoRepeaterType4_CheckedChanged(object sender, EventArgs e)
  3799. {
  3800. try
  3801. {
  3802. if (rdoRepeaterType_D.Checked)
  3803. {
  3804. if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)
  3805. {
  3806. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  3807. if (cell.Value != null)
  3808. {
  3809. String value = cell.Value.ToString();
  3810. String RepeaterID = value;
  3811. if (value.Length > 3)
  3812. {
  3813. RepeaterID = value.Substring(1, 3);
  3814. }
  3815. //해당 중계기의 회로표시
  3816. RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  3817. dev.RepeaterType = "D";
  3818. DeviceStatus(dev);
  3819. }
  3820. }
  3821. else
  3822. {
  3823. DeviceStatus(null);
  3824. }
  3825. }
  3826. else
  3827. {
  3828. DeviceStatus(null);
  3829. }
  3830. }
  3831. catch (Exception ex)
  3832. {
  3833. Util.UErrorMessage(ex, 0, 0);
  3834. }
  3835. }
  3836. //중계기 DB에서 자료가져오기
  3837. private void Repeater_getDate()
  3838. {
  3839. try
  3840. {
  3841. if (cboBoardList.Items.Count < 1 || cboLoopList.Items.Count < 1)
  3842. {
  3843. this.dataGridView_Repeater_Main.Columns.Clear();
  3844. //중계기 설정내용 표시
  3845. RepeaterStatus("");
  3846. savBoardID = -1;
  3847. savLoop = -1;
  3848. return;
  3849. }
  3850. if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) { Repeater_init(); return; }
  3851. String BoardID = cboBoardList.SelectedItem.ToString();
  3852. String Loop = cboLoopList.SelectedItem.ToString();
  3853. if (int.Parse(BoardID) == savBoardID && int.Parse(Loop) == savLoop) return;
  3854. savBoardID = int.Parse(BoardID);
  3855. savLoop = int.Parse(Loop);
  3856. Repeater_init();
  3857. DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  3858. DataTable dt = dacRepeaterConfig.Repeater_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), 0, null);
  3859. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  3860. Boolean FireResetFlag = false;
  3861. if (dt.Rows.Count > 0)
  3862. {
  3863. foreach (DataRow dr in dt.Rows)
  3864. {
  3865. //중계기설정값
  3866. String RepeaterID = Convert.ToString(dr["REPEATER_ID"]);
  3867. // '1' = A : 2X2
  3868. // '2' = B : 4X4
  3869. // '4' = C : 아날로그연감지기
  3870. // '5' = D : 아날로그열감지기
  3871. String RepeaterType = Convert.ToString(dr["REPEATER_TYPE"]);
  3872. Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;
  3873. Boolean CutFlag = Convert.ToString(dr["CUT_FLAG"]) == "Y" ? true : false;
  3874. //사용중인 중계기의 비화재보호 FALG를 읽는다.
  3875. Boolean sFireResetFlag = false;
  3876. if (UseFlag && !FireResetFlag) FireResetFlag = sFireResetFlag;
  3877. String repeaterType = "";
  3878. if (RepeaterType.Equals("1")) repeaterType = "A";
  3879. else if (RepeaterType.Equals("2")) repeaterType = "B";
  3880. else if (RepeaterType.Equals("4")) repeaterType = "C";
  3881. else if (RepeaterType.Equals("5")) repeaterType = "D";
  3882. RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  3883. if (!repeaterType.Equals(""))
  3884. {
  3885. dev.UseFlag = true;
  3886. dev.RepeaterType = repeaterType;
  3887. dev.CutFlag = CutFlag;
  3888. dev.FireResetFlag = sFireResetFlag;
  3889. }
  3890. else dev.UseFlag = false;
  3891. //회로설정값
  3892. //String[] InType = new String[4];
  3893. //String[] InTypeName = new String[4];
  3894. //String[] OutType = new String[4];
  3895. //String[] OutTypeName = new String[4];
  3896. DeviceTypeInfo[] inDeviceTypeInfo;
  3897. DeviceTypeInfo[] outDeviceTypeInfo;
  3898. if (repeaterType.Equals("A"))
  3899. {
  3900. inDeviceTypeInfo = new DeviceTypeInfo[2] { new DeviceTypeInfo(1), new DeviceTypeInfo(2) };
  3901. outDeviceTypeInfo = new DeviceTypeInfo[2] { new DeviceTypeInfo(1), new DeviceTypeInfo(2) };
  3902. DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null);
  3903. foreach (DataRow dr2 in dt2.Rows)
  3904. {
  3905. int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString());
  3906. String InoutType = dr2["INOUT_TYPE"].ToString();
  3907. if (InoutType.Equals(code_GroupIO.Input))
  3908. {
  3909. inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);
  3910. inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();
  3911. inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();
  3912. inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;
  3913. inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();
  3914. }
  3915. else
  3916. {
  3917. outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);
  3918. outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();
  3919. outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();
  3920. outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;
  3921. outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();
  3922. }
  3923. }
  3924. dev.inDeviceTypeInfos = inDeviceTypeInfo;
  3925. dev.outDeviceTypeInfos = outDeviceTypeInfo;
  3926. }
  3927. else if (repeaterType.Equals("B"))
  3928. {
  3929. inDeviceTypeInfo = new DeviceTypeInfo[4];
  3930. outDeviceTypeInfo = new DeviceTypeInfo[4];
  3931. DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null);
  3932. foreach (DataRow dr2 in dt2.Rows)
  3933. {
  3934. int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString());
  3935. String InoutType = dr2["INOUT_TYPE"].ToString();
  3936. if (InoutType.Equals(code_GroupIO.Input))
  3937. {
  3938. inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);
  3939. inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();
  3940. inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();
  3941. inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;
  3942. inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();
  3943. }
  3944. else
  3945. {
  3946. outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);
  3947. outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();
  3948. outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();
  3949. outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;
  3950. outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();
  3951. }
  3952. }
  3953. dev.inDeviceTypeInfos = inDeviceTypeInfo;
  3954. dev.outDeviceTypeInfos = outDeviceTypeInfo;
  3955. }
  3956. // cyim 2015.6.8 아날로그 감지기 연동 추가
  3957. else if (repeaterType.Equals("C") || repeaterType.Equals("D"))
  3958. {
  3959. inDeviceTypeInfo = new DeviceTypeInfo[1] { new DeviceTypeInfo(1) };
  3960. outDeviceTypeInfo = new DeviceTypeInfo[1] { new DeviceTypeInfo(1) };
  3961. DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null);
  3962. foreach (DataRow dr2 in dt2.Rows)
  3963. {
  3964. int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString());
  3965. String InoutType = dr2["INOUT_TYPE"].ToString();
  3966. if (InoutType.Equals(code_GroupIO.Input))
  3967. {
  3968. inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);
  3969. inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();
  3970. inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();
  3971. inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;
  3972. inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();
  3973. }
  3974. else
  3975. {
  3976. outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);
  3977. outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();
  3978. outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();
  3979. outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;
  3980. outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();
  3981. }
  3982. }
  3983. dev.inDeviceTypeInfos = inDeviceTypeInfo;
  3984. dev.outDeviceTypeInfos = outDeviceTypeInfo;
  3985. }
  3986. }
  3987. }
  3988. int rowCnt = 0, colCnt = 0;
  3989. //중계기 비사용 스타일
  3990. DataGridViewCellStyle styUnUse = new DataGridViewCellStyle();
  3991. styUnUse.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3992. styUnUse.BackColor = System.Drawing.Color.White;
  3993. //중계기 사용 스타일
  3994. DataGridViewCellStyle styUse = new DataGridViewCellStyle();
  3995. styUse.Alignment = DataGridViewContentAlignment.MiddleCenter;
  3996. styUse.BackColor = System.Drawing.Color.Aqua;
  3997. //중계기 차단 스타일
  3998. DataGridViewCellStyle styOut = new DataGridViewCellStyle();
  3999. styOut.Alignment = DataGridViewContentAlignment.MiddleCenter;
  4000. styOut.BackColor = System.Drawing.Color.Silver;
  4001. foreach (DataGridViewRow row in this.dataGridView_Repeater_Main.Rows)
  4002. {
  4003. colCnt = 0;
  4004. foreach (DataGridViewCell col in row.Cells)
  4005. {
  4006. ++colCnt;
  4007. int no = rowCnt * 10 + colCnt;
  4008. if (no <= 127)
  4009. {
  4010. RepeaterDeviceTypeInfo dev = REP[no - 1]; //중계기및 회로 설정정보
  4011. col.Value = String.Format("{0}{1:000}", dev.RepeaterType, no);
  4012. if (dev.CutFlag)
  4013. {
  4014. col.Style = styOut;
  4015. }
  4016. else if (dev.UseFlag)
  4017. {
  4018. col.Style = styUse;
  4019. }
  4020. else
  4021. {
  4022. col.Style = styUnUse;
  4023. }
  4024. }
  4025. }
  4026. ++rowCnt;
  4027. }
  4028. //비화재보호기능
  4029. chkFireResetFlag.Checked = FireResetFlag;
  4030. //첫번째 중계기가 선택되므로 회로 표시
  4031. RepeaterStatus(String.Format("{0}001", REP[0].RepeaterType));
  4032. DeviceStatus(REP[0]);
  4033. // cyim 2014.5.7 : 수신기설정정보 변경 (하단 코드로 인하여 강제로 삭제되버린다)
  4034. //표시된 보드가 변경되면 수신기 변경은 무효됨...
  4035. //mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false;
  4036. }
  4037. catch (Exception ex)
  4038. {
  4039. Util.UErrorMessage(ex, 0, 0);
  4040. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  4041. }
  4042. }
  4043. //중계기 회로 설정값 저장버튼 클릭시
  4044. private void btnRepeaterSave_Click(object sender, EventArgs e)
  4045. {
  4046. try
  4047. {
  4048. if (cboBoardList.Items.Count < 1) return;
  4049. if (cboLoopList.Items.Count < 1) return;
  4050. if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return;
  4051. String BoardID = cboBoardList.SelectedItem.ToString();
  4052. String Loop = cboLoopList.SelectedItem.ToString();
  4053. int LoopNo = int.Parse(Loop);
  4054. //String FireResetFlag = chkFireResetFlag.Checked ? "Y" : "N";
  4055. this.Cursor = Cursors.WaitCursor;
  4056. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  4057. DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  4058. for (int i = 0; i < 127; i++)
  4059. {
  4060. int RepeaterId = i + 1;
  4061. //중계기및 회로 설정정보
  4062. RepeaterDeviceTypeInfo dev = REP[i];
  4063. String RepeaterType = dev.RepeaterType == null ? "" : dev.RepeaterType;
  4064. if (RepeaterType.Equals(""))
  4065. {
  4066. //중계기 타입이 없는경우는 삭제한다.
  4067. dacRepeaterConfig.Repeater_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4068. , RepeaterId, "중계기" + RepeaterId.ToString(), "", "");
  4069. dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo, RepeaterId, 0, "", "", "", "");
  4070. }
  4071. else
  4072. {
  4073. //차단된 중계기는 비사용으로 저장한다.
  4074. //String UseFlag = dev.CutFlag ? "N" : "Y";
  4075. String UseFlag = "Y";
  4076. // cyim 2015.6.8 아날로그 감지기 연동 추가
  4077. // '1' = A : 2X2
  4078. // '2' = B : 4X4
  4079. // '4' = C : 아날로그연감지기
  4080. // '5' = D : 아날로그열감지기
  4081. if (dev.RepeaterType == "A")
  4082. RepeaterType = "1";
  4083. else if (dev.RepeaterType == "B")
  4084. RepeaterType = "2";
  4085. else if (dev.RepeaterType == "C")
  4086. RepeaterType = "4";
  4087. else if (dev.RepeaterType == "D")
  4088. RepeaterType = "5";
  4089. //중계기 설정값 저장
  4090. dacRepeaterConfig.Repeater_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4091. , RepeaterId, "중계기" + RepeaterId.ToString()
  4092. , RepeaterType, UseFlag);
  4093. DeviceTypeInfo[] inDeviceTypeInfo = dev.inDeviceTypeInfos;
  4094. DeviceTypeInfo[] outDeviceTypeInfo = dev.outDeviceTypeInfos;
  4095. if (dev.RepeaterType.Equals("A"))
  4096. {
  4097. for (int DevID = 1; DevID <= 2; DevID++)
  4098. {
  4099. if (inDeviceTypeInfo[DevID - 1] != null)
  4100. {
  4101. //회로타입이 없는경우 삭제한다..
  4102. if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))
  4103. {
  4104. dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4105. , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);
  4106. }
  4107. else
  4108. {
  4109. dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4110. , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);
  4111. }
  4112. }
  4113. if (outDeviceTypeInfo[DevID - 1] != null)
  4114. {
  4115. //회로타입이 없는경우 삭제한다..
  4116. if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))
  4117. {
  4118. dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4119. , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);
  4120. }
  4121. else
  4122. {
  4123. dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4124. , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);
  4125. }
  4126. }
  4127. }
  4128. }
  4129. else if (dev.RepeaterType.Equals("B"))
  4130. {
  4131. for (int DevID = 1; DevID <= 4; DevID++)
  4132. {
  4133. if (inDeviceTypeInfo[DevID - 1] != null)
  4134. {
  4135. //회로타입이 없는경우 삭제한다..
  4136. if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))
  4137. {
  4138. dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4139. , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);
  4140. }
  4141. else
  4142. {
  4143. dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4144. , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);
  4145. }
  4146. }
  4147. if (outDeviceTypeInfo[DevID - 1] != null)
  4148. {
  4149. //회로타입이 없는경우 삭제한다..
  4150. if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))
  4151. {
  4152. dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4153. , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);
  4154. }
  4155. else
  4156. {
  4157. dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4158. , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);
  4159. }
  4160. }
  4161. }
  4162. }
  4163. // cyim 2015.6.8 아날로그 감지기 연동 추가
  4164. else if (dev.RepeaterType.Equals("C") || dev.RepeaterType.Equals("D"))
  4165. {
  4166. for (int DevID = 1; DevID <= 1; DevID++)
  4167. {
  4168. if (inDeviceTypeInfo[DevID - 1] != null)
  4169. {
  4170. //회로타입이 없는경우 삭제한다..
  4171. if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))
  4172. {
  4173. dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4174. , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);
  4175. }
  4176. else
  4177. {
  4178. dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4179. , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);
  4180. }
  4181. }
  4182. if (outDeviceTypeInfo[DevID - 1] != null)
  4183. {
  4184. //회로타입이 없는경우 삭제한다..
  4185. if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))
  4186. {
  4187. dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4188. , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);
  4189. }
  4190. else
  4191. {
  4192. dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo
  4193. , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);
  4194. }
  4195. }
  4196. }
  4197. }
  4198. }
  4199. }
  4200. //수신기설정정보 변경
  4201. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  4202. //MessageBox.Show("저장되었습니다.", Application.ProductName);
  4203. }
  4204. catch (Exception ex)
  4205. {
  4206. Util.UErrorMessage(ex, 0, 0);
  4207. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  4208. }
  4209. finally
  4210. {
  4211. this.Cursor = Cursors.Default;
  4212. }
  4213. }
  4214. //Loop선택을 변경하면 데이터를 다시 읽는다
  4215. private void cboLoopList_SelectedIndexChanged(object sender, EventArgs e)
  4216. {
  4217. try
  4218. {
  4219. Repeater_getDate();
  4220. }
  4221. catch (Exception ex)
  4222. {
  4223. Util.UErrorMessage(ex, 0, 0);
  4224. }
  4225. }
  4226. //1Page로 이동
  4227. private void btnPage1_Click(object sender, EventArgs e)
  4228. {
  4229. try
  4230. {
  4231. Point pos = dataGridView_Repeater_Main.Location;
  4232. pos.Y = 0;
  4233. dataGridView_Repeater_Main.Location = pos;
  4234. }
  4235. catch (Exception ex)
  4236. {
  4237. Util.UErrorMessage(ex, 0, 0);
  4238. }
  4239. }
  4240. //2Page로 이동
  4241. private void btnPage2_Click(object sender, EventArgs e)
  4242. {
  4243. try
  4244. {
  4245. Point pos = dataGridView_Repeater_Main.Location;
  4246. pos.Y = -(23 * 7 + 1); //row height : 23, 페이지row수: 7
  4247. dataGridView_Repeater_Main.Location = pos;
  4248. }
  4249. catch (Exception ex)
  4250. {
  4251. Util.UErrorMessage(ex, 0, 0);
  4252. }
  4253. }
  4254. //수신기쓰기 버튼
  4255. private void btnReceiverWrite_Click(object sender, EventArgs e)
  4256. {
  4257. try
  4258. {
  4259. if (cboBoardList.Items.Count < 1) return;
  4260. if (cboLoopList.Items.Count < 1) return;
  4261. //btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);
  4262. if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return;
  4263. String BoardID = cboBoardList.SelectedItem.ToString();
  4264. String Loop = cboLoopList.SelectedItem.ToString();
  4265. int LoopNo = int.Parse(Loop);
  4266. int BoardNo = int.Parse(BoardID);
  4267. bool FireResetFlag = chkFireResetFlag.Checked;
  4268. if (MessageBox.Show("모든 데이타 저장(수신기 쓰기) 버튼을 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  4269. {
  4270. this.Cursor = Cursors.WaitCursor;
  4271. btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);
  4272. //2010.12.05, k.s.d, repeater information unit write -> don't use.
  4273. /******************************************/
  4274. /* 중계기 쓰기 Progress 표시 */
  4275. /******************************************/
  4276. //frmProgress frm = new frmProgress();
  4277. ////중계기 설정 데이터를 CmdInfo에 넣어준다..
  4278. //CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_info_unit, mdi.myReceiverID, 1, LoopNo, BoardNo, null);
  4279. ////ReceiverTypeInfo Receiverinfo = this.mdi.ui.MyReceiverTypeInfo; //수신기설정
  4280. ////BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardNo); //통신보드savBoardID의 설정값
  4281. ////RepeaterDeviceTypeInfo[] repinfo; //중계기설정정보-설정쓰기를 위해
  4282. ////if (LoopNo == 0)
  4283. ////{
  4284. //// repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
  4285. ////}
  4286. ////else
  4287. ////{
  4288. //// repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
  4289. ////}
  4290. ////cmd.CommandData = repinfo;
  4291. //cmd.CommandData = REP; //화면에 설정된 데이터를 쓰기데이터로 이용한다.
  4292. //frm.Commandinfo = cmd;
  4293. //frm.ui = this.mdi.ui;
  4294. ////frm.ShowDialog();
  4295. ///******************************************/
  4296. //2010.12.05, k.s.d, repeater information block write.
  4297. DoWriteRepeaterInfoBoard_Loop(LoopNo, BoardNo);
  4298. btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);
  4299. this.Cursor = Cursors.Default;
  4300. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false; //수신기쓰기완료
  4301. }
  4302. }
  4303. catch (Exception ex)
  4304. {
  4305. Util.UErrorMessage(ex, 0, 0);
  4306. //MessageBox.Show(ex.Message, Application.ProductName);
  4307. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  4308. }
  4309. finally
  4310. {
  4311. this.Cursor = Cursors.Default;
  4312. }
  4313. }
  4314. //2010.12.05, k.s.d, repeater information block write.
  4315. private void DoWriteRepeaterInfoBoard_Loop(int LoopNo, int BoardNo)
  4316. {
  4317. CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_repeater_info_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null);
  4318. dCommandResponse deleg = new dCommandResponse(GetResponseWriteRepeaterInfoAll);
  4319. commandinfo.dEvent = deleg;
  4320. RepeaterDataAll RepaterDataAll = new RepeaterDataAll();
  4321. for (int i = 0; i < 127; i++)
  4322. {
  4323. int RepeaterSet = 0;
  4324. if (REP[i].UseFlag)
  4325. {
  4326. // cyim 2015.6.8 아날로그 감지기 연동 추가
  4327. if (REP[i].RepeaterType == "A")
  4328. RepeaterSet = 1;
  4329. else if (REP[i].RepeaterType == "B")
  4330. RepeaterSet = 2;
  4331. else if (REP[i].RepeaterType == "C")
  4332. RepeaterSet = 4;
  4333. else if (REP[i].RepeaterType == "D")
  4334. RepeaterSet = 5;
  4335. }
  4336. RepaterDataAll.Data[i].Set_Info_Data(REP[i].CutFlag, REP[i].FireResetFlag, false, false, RepeaterSet);
  4337. }
  4338. commandinfo.CommandData = RepaterDataAll;
  4339. this.mdi.ui.runCommand(commandinfo);
  4340. }
  4341. public void GetResponseWriteRepeaterInfoAll(CmdInfo resInfo)
  4342. {
  4343. mdi.ui.ReceiverDBRead(); //DB Read
  4344. mdi.FireReset_Process(); //demon RESET
  4345. this.lblReceiverConfigChangeFlag.Text = "모든 데이타 저장 (수신기 쓰기)이 완료되었습니다.";
  4346. this.lblReceiverConfigChangeFlag.Visible = true;
  4347. this.Cursor = Cursors.Default;
  4348. MessageBox.Show("설정정보가 변경되어 데몬을 Reset하였습니다.", Application.ProductName);
  4349. }
  4350. //선택값이 틀릴때마다 해당중계기 설정내용 radio에 표시
  4351. private void dataGridView2_SelectionChanged(object sender, EventArgs e)
  4352. {
  4353. if (dataGridView_Repeater_Sub.SelectedCells.Count > 0)
  4354. {
  4355. try
  4356. {
  4357. if (cboBoardList.Items.Count < 1) return;
  4358. if (cboLoopList.Items.Count < 1) return;
  4359. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  4360. int devNo = selectCell.ColumnIndex;
  4361. string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);
  4362. devNo = (devNo % 4);
  4363. int RepeaterID = Util.StrToInt(lblRepeaterID.Text, 0);
  4364. if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return;
  4365. int BoardID = Util.StrToInt(cboBoardList.SelectedItem, -1);
  4366. int LoopNo = Util.StrToInt(cboLoopList.SelectedItem, -1);
  4367. MskDeviceIDString device_str = new MskDeviceIDString(1, BoardID
  4368. , LoopNo, RepeaterID, devNo + 1, inputType);
  4369. mskDeviceID.Text = device_str.MskId;
  4370. RepeaterDeviceTypeInfo rep = REP[RepeaterID - 1]; //중계기및 회로 설정정보
  4371. if (rep != null)
  4372. {
  4373. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  4374. if (inputType.Equals(code_InOutType.Input))
  4375. {
  4376. DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];
  4377. if (dev != null)
  4378. {
  4379. txtDeviceTypeCode.Text = dev.DeviceType;
  4380. String type_name = dacDeviceConfig.Device_Type_Name(inputType, dev.DeviceType);
  4381. txtDeviceTypeName.Text = type_name;
  4382. txtPositionCode.Text = dev.PositionCode;
  4383. String position_name = dacDeviceConfig.Device_Position_Name(dev.PositionCode);
  4384. txtPositionName.Text = position_name;
  4385. txtDeviceMemo.Text = dev.DeviceName;
  4386. }
  4387. else
  4388. {
  4389. mskDeviceID.Text = "";
  4390. txtDeviceTypeCode.Text = "";
  4391. txtDeviceTypeName.Text = "";
  4392. txtPositionCode.Text = "";
  4393. txtPositionName.Text = "";
  4394. txtDeviceMemo.Text = "";
  4395. }
  4396. }
  4397. else if (inputType.Equals(code_InOutType.Output))
  4398. {
  4399. DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];
  4400. if (dev != null)
  4401. {
  4402. txtDeviceTypeCode.Text = dev.DeviceType;
  4403. String type_name = dacDeviceConfig.Device_Type_Name(inputType, dev.DeviceType);
  4404. txtDeviceTypeName.Text = type_name;
  4405. txtPositionCode.Text = dev.PositionCode;
  4406. String position_name = dacDeviceConfig.Device_Position_Name(dev.PositionCode);
  4407. txtPositionName.Text = position_name;
  4408. txtDeviceMemo.Text = dev.DeviceName;
  4409. }
  4410. else
  4411. {
  4412. mskDeviceID.Text = "";
  4413. txtDeviceTypeCode.Text = "";
  4414. txtDeviceTypeName.Text = "";
  4415. txtPositionCode.Text = "";
  4416. txtPositionName.Text = "";
  4417. txtDeviceMemo.Text = "";
  4418. }
  4419. }
  4420. }
  4421. else
  4422. {
  4423. mskDeviceID.Text = "";
  4424. txtDeviceTypeCode.Text = "";
  4425. txtDeviceTypeName.Text = "";
  4426. txtPositionCode.Text = "";
  4427. txtPositionName.Text = "";
  4428. txtDeviceMemo.Text = "";
  4429. }
  4430. }
  4431. catch (Exception ex)
  4432. {
  4433. Util.UErrorMessage(ex, 0, 0);
  4434. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  4435. }
  4436. }
  4437. }
  4438. private void btnDeviceSearchOpen_Click(object sender, EventArgs e)
  4439. {
  4440. try
  4441. {
  4442. if (this.dataGridView_Repeater_Sub.SelectedCells.Count < 1) return;
  4443. //코드를 찾는 모달창을 연다..
  4444. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  4445. int devNo = selectCell.ColumnIndex;
  4446. string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);
  4447. devNo = (devNo % 4);
  4448. frmModalDeviceType frm = new frmModalDeviceType(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  4449. SearchCodeVo vo = new SearchCodeVo(inputType);
  4450. vo.Code = txtDeviceTypeCode.Text.Trim();
  4451. vo.CodeName = txtDeviceTypeName.Text.Trim();
  4452. frm.SearchCode = vo;
  4453. frm.ShowDialog();
  4454. vo = frm.SearchCode;
  4455. //선택한 코드가 있다면
  4456. if (vo.SearchOK)
  4457. {
  4458. //선택한 코드값을 dataGridView2에 표시
  4459. txtDeviceTypeCode.Text = vo.Code;
  4460. txtDeviceTypeName.Text = vo.CodeName;
  4461. //변경값 저장
  4462. String RepeaterID = lblRepeaterID.Text;
  4463. if (!RepeaterID.Equals(""))
  4464. {
  4465. RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  4466. if (rep != null)
  4467. {
  4468. if (inputType.Equals(code_InOutType.Input))
  4469. {
  4470. DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];
  4471. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4472. dev.DeviceType = vo.Code;
  4473. //dev.DeviceName = txtDeviceMemo.Text.Trim();
  4474. //dev.PositionCode = txtPositionCode.Text.Trim();
  4475. //REP[int.Parse(RepeaterID) - 1].setInputDeviceTypeInfo(devNo + 1, vo.Code, txtDeviceMemo.Text.Trim(),txtPositionCode.Text.Trim(), false);
  4476. rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장
  4477. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨.
  4478. //DeviceStatus(rep);
  4479. }
  4480. else if (inputType.Equals(code_InOutType.Output))
  4481. {
  4482. DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];
  4483. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4484. dev.DeviceType = vo.Code;
  4485. //dev.DeviceName = txtDeviceMemo.Text.Trim();
  4486. //dev.PositionCode = txtPositionCode.Text.Trim();
  4487. //REP[int.Parse(RepeaterID) - 1].setOutputDeviceTypeInfo(devNo + 1, vo.Code, txtDeviceMemo.Text.Trim(), txtPositionCode.Text.Trim(), false);
  4488. rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장
  4489. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨.
  4490. }
  4491. }
  4492. }
  4493. }
  4494. }
  4495. catch (Exception ex)
  4496. {
  4497. Util.UErrorMessage(ex, 0, 0);
  4498. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  4499. }
  4500. }
  4501. private void btnPositionSearchOpen_Click(object sender, EventArgs e)
  4502. {
  4503. try
  4504. {
  4505. if (this.dataGridView_Repeater_Sub.SelectedCells.Count < 1) return;
  4506. //코드를 찾는 모달창을 연다..
  4507. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  4508. int devNo = selectCell.ColumnIndex;
  4509. string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);
  4510. devNo = (devNo % 4);
  4511. frmModalPositionCode frm = new frmModalPositionCode();
  4512. SearchCodeVo vo = new SearchCodeVo(null);
  4513. vo.Code = txtPositionCode.Text.Trim();
  4514. vo.CodeName = txtPositionName.Text.Trim();
  4515. frm.setMdiParent(this.mdi);
  4516. frm.SearchCode = vo;
  4517. frm.ShowDialog();
  4518. vo = frm.SearchCode;
  4519. //선택한 코드가 있다면
  4520. if (vo.SearchOK)
  4521. {
  4522. //선택한 코드값을 dataGridView2에 표시
  4523. txtPositionCode.Text = vo.Code;
  4524. txtPositionName.Text = vo.CodeName;
  4525. //변경값 저장
  4526. String RepeaterID = lblRepeaterID.Text;
  4527. if (!RepeaterID.Equals(""))
  4528. {
  4529. RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  4530. if (rep != null)
  4531. {
  4532. if (inputType.Equals(code_InOutType.Input))
  4533. {
  4534. DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];
  4535. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4536. dev.PositionCode = vo.Code;
  4537. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨.
  4538. }
  4539. else if (inputType.Equals(code_InOutType.Output))
  4540. {
  4541. DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];
  4542. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4543. dev.PositionCode = vo.Code;
  4544. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨.
  4545. }
  4546. }
  4547. }
  4548. }
  4549. }
  4550. catch (Exception ex)
  4551. {
  4552. Util.UErrorMessage(ex, 0, 0);
  4553. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  4554. }
  4555. }
  4556. private void txtDeviceMemo_TextChanged(object sender, EventArgs e)
  4557. {
  4558. try
  4559. {
  4560. //코드를 찾는 모달창을 연다..
  4561. if (txtDeviceMemo.Text.Trim().Equals("")) return;
  4562. if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)
  4563. {
  4564. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  4565. int devNo = selectCell.ColumnIndex;
  4566. string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);
  4567. devNo = (devNo % 4);
  4568. String RepeaterID = lblRepeaterID.Text;
  4569. if (!RepeaterID.Equals(""))
  4570. {
  4571. RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  4572. if (rep != null)
  4573. {
  4574. if (inputType.Equals(code_InOutType.Input))
  4575. {
  4576. DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];
  4577. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4578. dev.DeviceName = txtDeviceMemo.Text.Trim();
  4579. rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장
  4580. }
  4581. else if (inputType.Equals(code_InOutType.Output))
  4582. {
  4583. DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];
  4584. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4585. dev.DeviceName = txtDeviceMemo.Text.Trim();
  4586. rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장
  4587. }
  4588. }
  4589. }
  4590. }
  4591. }
  4592. catch (Exception ex)
  4593. {
  4594. Util.UErrorMessage(ex, 0, 0);
  4595. }
  4596. }
  4597. private void txtDeviceTypeCode_TextChanged(object sender, EventArgs e)
  4598. {
  4599. try
  4600. {
  4601. Util.ToUpper(txtDeviceTypeCode);
  4602. String typeCode = txtDeviceTypeCode.Text.Trim();
  4603. if (typeCode.Length == 2)
  4604. {
  4605. if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)
  4606. {
  4607. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  4608. int devNo = selectCell.ColumnIndex;
  4609. string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);
  4610. devNo = (devNo % 4);
  4611. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  4612. String type_name = dacDeviceConfig.Device_Type_Name(inputType, typeCode);
  4613. txtDeviceTypeName.Text = type_name;
  4614. String RepeaterID = lblRepeaterID.Text;
  4615. if (!RepeaterID.Equals(""))
  4616. {
  4617. RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  4618. if (rep != null)
  4619. {
  4620. if (inputType.Equals(code_InOutType.Input))
  4621. {
  4622. DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];
  4623. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4624. dev.DeviceType = typeCode;
  4625. rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장
  4626. }
  4627. else if (inputType.Equals(code_InOutType.Output))
  4628. {
  4629. DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];
  4630. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4631. dev.DeviceType = typeCode;
  4632. rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장
  4633. }
  4634. }
  4635. }
  4636. }
  4637. }
  4638. else
  4639. {
  4640. txtDeviceTypeName.Text = "";
  4641. if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)
  4642. {
  4643. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  4644. int devNo = selectCell.ColumnIndex;
  4645. string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);
  4646. devNo = (devNo % 4);
  4647. String RepeaterID = lblRepeaterID.Text;
  4648. if (!RepeaterID.Equals(""))
  4649. {
  4650. RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  4651. if (rep != null)
  4652. {
  4653. if (inputType.Equals(code_InOutType.Input))
  4654. {
  4655. DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];
  4656. if (dev != null)
  4657. {
  4658. dev.DeviceType = "";
  4659. rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장
  4660. }
  4661. }
  4662. else if (inputType.Equals(code_InOutType.Output))
  4663. {
  4664. DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];
  4665. if (dev != null)
  4666. {
  4667. dev.DeviceType = "";
  4668. rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장
  4669. }
  4670. }
  4671. }
  4672. }
  4673. }
  4674. }
  4675. }
  4676. catch (Exception ex)
  4677. {
  4678. Util.UErrorMessage(ex, 0, 0);
  4679. }
  4680. }
  4681. private void txtPositionCode_TextChanged(object sender, EventArgs e)
  4682. {
  4683. try
  4684. {
  4685. Util.ToUpper(txtPositionCode);
  4686. String positionCode = txtPositionCode.Text.Trim();
  4687. if (positionCode.Length == 2)
  4688. {
  4689. if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)
  4690. {
  4691. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  4692. int devNo = selectCell.ColumnIndex;
  4693. string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);
  4694. devNo = (devNo % 4);
  4695. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  4696. String position_name = dacDeviceConfig.Device_Position_Name(positionCode);
  4697. txtPositionName.Text = position_name;
  4698. String RepeaterID = lblRepeaterID.Text;
  4699. if (!RepeaterID.Equals(""))
  4700. {
  4701. RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보
  4702. if (rep != null)
  4703. {
  4704. if (inputType.Equals(code_InOutType.Input))
  4705. {
  4706. DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];
  4707. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4708. dev.PositionCode = positionCode;
  4709. rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장
  4710. }
  4711. else if (inputType.Equals(code_InOutType.Output))
  4712. {
  4713. DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];
  4714. if (dev == null) dev = new DeviceTypeInfo(devNo + 1);
  4715. dev.PositionCode = positionCode;
  4716. rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장
  4717. }
  4718. }
  4719. }
  4720. }
  4721. }
  4722. else
  4723. {
  4724. txtPositionName.Text = "";
  4725. }
  4726. }
  4727. catch (Exception ex)
  4728. {
  4729. Util.UErrorMessage(ex, 0, 0);
  4730. }
  4731. }
  4732. private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
  4733. {
  4734. try
  4735. {
  4736. if (chkSelectAll.Checked)
  4737. {
  4738. dataGridView_Repeater_Main.SelectAll();
  4739. chkSelectAll.Text = "선택해제";
  4740. }
  4741. else
  4742. {
  4743. int rowIndx = this.dataGridView_Repeater_Main.Rows.Count;
  4744. int colIndx = this.dataGridView_Repeater_Main.ColumnCount;
  4745. for (int i = 0; i < rowIndx; i++) //전체 셀 숫자에 따라서..
  4746. {
  4747. for (int j = 0; j < colIndx; j++) //전체 셀 숫자에 따라서..
  4748. dataGridView_Repeater_Main.Rows[i].Cells[j].Selected = false;
  4749. }
  4750. chkSelectAll.Text = "전체선택";
  4751. }
  4752. }
  4753. catch (Exception ex)
  4754. {
  4755. Util.UErrorMessage(ex, 0, 0);
  4756. }
  4757. }
  4758. private void btnWinClose_Click(object sender, EventArgs e)
  4759. {
  4760. try
  4761. {
  4762. if (mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag == true)
  4763. {
  4764. MessageBox.Show("설정 변경되었음. 반드시 모든 데이타 저장(수신기 쓰기) 버튼을 실행하십시요!");
  4765. return;
  4766. }
  4767. this.Close();
  4768. }
  4769. catch (Exception ex)
  4770. {
  4771. Util.UErrorMessage(ex, 0, 0);
  4772. }
  4773. }
  4774. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  4775. {
  4776. try
  4777. {
  4778. chkSelectAll.Text = "전체선택";
  4779. chkSelectAll.Checked = false;
  4780. }
  4781. catch (Exception ex)
  4782. {
  4783. Util.UErrorMessage(ex, 0, 0);
  4784. }
  4785. }
  4786. private void chkNoFireResetFlag_CheckedChanged(object sender, EventArgs e)
  4787. {
  4788. try
  4789. {
  4790. bool FireResetFlag = chkFireResetFlag.Checked;
  4791. int rowIndx = this.dataGridView_Repeater_Main.Rows.Count;
  4792. int colIndx = this.dataGridView_Repeater_Main.ColumnCount;
  4793. for (int i = 0; i < rowIndx; i++) //전체 셀 숫자에 따라서..
  4794. {
  4795. for (int j = 0; j < colIndx; j++) //전체 셀 숫자에 따라서..
  4796. {
  4797. int RepeaterID = i * 10 + j;
  4798. if (RepeaterID < 127)
  4799. {
  4800. RepeaterDeviceTypeInfo dev = REP[RepeaterID]; //중계기및 회로 설정정보
  4801. if (!dev.RepeaterType.Equals("")) dev.FireResetFlag = FireResetFlag;
  4802. }
  4803. }
  4804. }
  4805. // cyim 2014.5.7 : 수신기설정정보 변경
  4806. mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;
  4807. }
  4808. catch (Exception ex)
  4809. {
  4810. Util.UErrorMessage(ex, 0, 0);
  4811. }
  4812. }
  4813. /******************************************************************************************************/
  4814. #endregion
  4815. }
  4816. public class CTBoard
  4817. {
  4818. public int boardID;
  4819. public string name;
  4820. public bool use;
  4821. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  4822. public bool loop0Use;
  4823. public bool loop1Use;
  4824. public bool loop2Use;
  4825. public bool loop3Use;
  4826. }
  4827. }