iPDC Programmer Manual

401 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
401
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

iPDC Programmer Manual

  1. 1. Phasor Data Concentrator Code Documentation Programmers ManualSubmitted in partial fulllment of the requirements for the degree of Master of Technology by Kedar Khandeparkar Nitesh Pandit under the guidance of Prof. A.M. Kulkarni Indian Institute of Technology, Bombay
  2. 2. s would like to express my sin™ere th—nks —nd gr—titude to my guideD €rofF †FF ett—rD€rofF ƒF…F qhum˜re —nd €rofF eFwF uulk—rni for the ™onst—nt motiv—tion —nd v—lu—˜leguid—n™e they provided me throughout the ™ourse of the proje™tF s —m highly inde˜tedto them for giving me this opportunity to work under them for this wF„e™h proje™tD —nd—lso ™l—rifying my dou˜ts —nd for ˜ringing into perspe™tiveD the dierent —spe™ts of theproje™t topi™F „hey ™onst—ntly en™our—ged me ˜y giving suggestions —nd ™riti™isms on myworkF ‡orking under them h—s ˜een — gre—t le—rning experien™e for meF i
  3. 3. Abstract With information and measurement technology evolving rapidly within the elec-tric power industry, wide-area measurement is deemed to be the key technology toimprove power system reliability. Phasor Measurement Unit (PMU) deployment forWide Area Measurement System(WAMS) results in large amount± of data beinggenerated every second across the PMU network. Currently, many transmission op-erators do not have the ability to process, store, and utilize this data. We aim tobuild a Phasor data concentrator that can do these operations. This report givesthe complete implementation details of the iPDC Phasor Data Concentrator. ii
  4. 4. Contents1 General Working of iPDC 2 IFI inter i€hg ƒetup F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F Q IFP edd — ƒour™e hevi™e F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F Q IFQ ‚emove — ƒour™e hevi™e F F F F F F F F F F F F F F F F F F F F F F F F F F F F Q IFR „urn ypp the d—t— „r—nsmission F F F F F F F F F F F F F F F F F F F F F F F R IFS „urn yx the d—t— „r—nsmission F F F F F F F F F F F F F F F F F F F F F F F F R IFT ‚equest gon(gur—tion fr—me F F F F F F F F F F F F F F F F F F F F F F F F F F R IFU edd — hestin—tion hevi™e F F F F F F F F F F F F F F F F F F F F F F F F F F F S IFV ‚emove — hestin—tion hevi™e F F F F F F F F F F F F F F F F F F F F F F F F F S IFW i€hg gonne™tion „—˜le F F F F F F F F F F F F F F F F F F F F F F F F F F F F S2 Source Code Documentation of iPDC 6 PFI i€hgF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F T PFP ipd™quiF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F U PFQ pun™tions in re™re—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F V PFR pun™tions in ™onne™tionsF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F V PFS pun™tions in new•pmu•or•pd™F™ F F F F F F F F F F F F F F F F F F F F F F F V PFT pun™tions in p—rserF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F W PFU pun™tions in d—llo™—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F W PFV pun™tions in —lign•sortF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F IH PFW glo˜—lFh F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IH PFIH het—iled hes™ription F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IH PFIHFI re™re—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IH PFIHFP ™onne™tionsF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F II PFIHFQ new•pmu•or•pd™F™ F F F F F F F F F F F F F F F F F F F F F F F F F F IP PFIHFR p—rserF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IP PFIHFS d—llo™—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IR PFIHFT —lign•sortF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IR PFII h—t— ƒtru™tures …sed F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IT3 Source Code Documentation of DBServer 22 QFI d˜ƒerverF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PP QFP pun™tions in re™re—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PP QFQ pun™tions in ™onne™tionsF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F PP QFR pun™tions in p—rserF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PQ QFS pun™tions in d—llo™—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PQ iii
  5. 5. QFT glo˜—lFh F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PQ QFU het—iled hes™ription F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PQ QFUFI re™re—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PQ QFUFP ™onne™tionsF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PR QFUFQ p—rserF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PR QFUFR d—llo™—teF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PS QFV h—t— ƒtru™tures …sed F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PS4 iPDC Database 295 General Working of PMU Simulator 31 SFI inter €w… ƒetup F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F QP SFP gre—te gon(gur—tion pr—me F F F F F F F F F F F F F F F F F F F F F F F F F F QP SFQ re—der pr—me qener—tion F F F F F F F F F F F F F F F F F F F F F F F F F F F QP SFR …pd—te €w… gon(gur—tion F F F F F F F F F F F F F F F F F F F F F F F F F F QQ SFS †iew €w… het—ils F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F QQ SFT €w… ixit F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F QQ6 Source Code Documentation of PMU Simulator 33 TFI pmuF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F QR TFP pun™tions in €muquiF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F QR TFQ pun™tions in ƒerverpun™tionF™ F F F F F F F F F F F F F F F F F F F F F F F F F QS TFR pun™tions in gfgquipun™tionsF™ F F F F F F F F F F F F F F F F F F F F F F F F QS TFS pun™tions in gfgpun™tionF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F QT TFT pun™tions in fun™tionF™ F F F F F F F F F F F F F F F F F F F F F F F F F F F F F QT iv
  6. 6. List of Figures I Conguration Frame. F F F F F F F F F F F F F F F F F F F F F F F F F F F F IV P Data Frame. F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IW Q PMU Status Change. F F F F F F F F F F F F F F F F F F F F F F F F F F F F IW R Source Device Details F F F F F F F F F F F F F F F F F F F F F F F F F F F F PH S Destination Device Details F F F F F F F F F F F F F F F F F F F F F F F F F PH T Time Stamp Buer F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PI U DBServer Conguration Frame F F F F F F F F F F F F F F F F F F F F F F PU V DBServer Data Frame F F F F F F F F F F F F F F F F F F F F F F F F F F F PV W i€hg h—t—˜—se F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F QHOrganization Of the Report IF gh—pter I des™ri˜es the v—rious —r™hite™ture 8 design of i€hgF PF gh—pter P des™ri˜es h—ndling of d—t— 8 ™on(gur—tion fr—mes —r i€hgF QF gh—pter Q des™ri˜es i€hg h—t—˜—seF RF gh—pter R des™ri˜es ‡ewƒ ƒe™urityF SF gh—pter S des™ri˜es the design of €w… ƒimul—torF I
  7. 7. 1 General Working of iPDC€w…9sGi€hg9s —™t —s servers when they —re ™ommuni™—ting with —nother i€hg whomthey —re sending the d—t—G™on(gur—tion fr—mesF „he i€hg re™eiving d—t— in this ™—se—™ts —s — ™lientF rowever when the s—me i€hg sends d—t— to —nother i€hgD it would —™t—s — serverF „his p—ttern will ˜e repe—ted in the ‡ewƒ topology with one peer —™ting —sserver —nd its ™ounterp—rt — ™lientF „he i€hg when —™ting —s — server ˜inds to P ports …h€€y‚„ —nd „g€€y‚„F stwould ˜e listening for …h€ ™onne™tions on …h€€y‚„ —nd „g€ ™onne™tions on „g€E€y‚„F „he i€hg ™—n then send the ™om˜ined ™on(gur—tion fr—mes to —ny num˜er ofother i€hg9sF foth the ™ommuni™—ting peers —uthenti™—te e—™h otherF i€hg —uthentiE™—tes for e—™h re™eived p—™kets irrespe™tive of ™ommun™—tion proto™ols used@„g€G…h€AF ‡hen the i€hg st—rts for the (rst time the user is prompted to enter i€hg sd™odeD…h€ €ortD „g€ €ort —nd h—t—˜—se ƒerver s€F „he ports en—˜le i€hg to re™eive requestsfrom other i€hg —nd to send the ™om˜ined d—t— —nd ™on(gur—tion fr—mesF h—t—˜—seƒerver s€ is the s€ —ddress of the m—™hine where the pro™ess d˜server is runningF „hedef—ult port on whi™h d˜server is listening for d—t— is WHHH —nd it is — …h€ serverF „hed—t— whi™h the i€hg re™eives would —lso ˜e dire™ted to d˜server for stor—ge in wyƒvd—t—˜—seF „he user is provided with the following options —t i€hg • inter i€hg ƒetup • edd — ƒour™e hevi™e • ‚emove — ƒour™e hevi™e • „urn ypp the d—t— „r—nsmission • „urn yx the d—t— „r—nsmission • ‚equest gon(gur—tion fr—me • edd — hestin—tion hevi™e • ‚emove — hestin—tion hevi™e • i€hg gonne™tion „—˜le P
  8. 8. 1.1 Enter iPDC Setup„his is the (rst pop up window th—t would —sk the user to enter the i€hg setup inform—EtionF st in™ludes …h€ 8 „g€ ports on whi™h the i€hg would re™eive ™omm—nd fr—merequests from other i€hg9sF „he two ports should ˜e dierentF „he ™om˜ined d—t— —nd™on(gur—tion fr—mes would ˜e sent on these portsF i€hg sd™ode —lso need to ˜e enteredFs€ —ddress of the m—™hine where the d—t— would ˜e stored in wyƒv d—t—˜—seis —lso needto ˜e enteredF„his fun™tion—lity is distri˜uted in the following fun™tions XE void ll_pdc_details (),int validation_pdc_detail (GtkButton *button, gpointer udata) from the (le ipdcGui.cF1.2 Add a Source Device„his would m—ke —n entry in the (le ip—ddressFtxt for e—™h newly —dded €w…F feforem—king the entry it would ™he™k if there is —lre—dy — ™onne™tion with the s—me nodeF sfsoD no entry is m—deF ytherwise — new thre—d would ˜e ™re—ted for e—™h ™onne™tion ˜—sedon type of the proto™ols th—t h—ve ˜een sele™ted ˜y user @„g€G…h€AF elso — new nodeof the type vower•v—yer•het—ils would ˜e ™re—tedF int add_PMU(char pmuid[],„his fun™tion—lity is distri˜uted in the following fun™tions XEchar ip[], char port[], char protocol[]),void* connect_pmu_tcp(),void* connect_pmu_udp(),void add_PMU_Node() from the (le new_pmu_or_pdc.c—nd void PMU_process_UDP(), void PMU_process_TCP from (le connections.cF1.3 Remove a Source Device„his would displ—y the user with —v—il—˜le €w… node entries —nd would prompt the userto enter the det—ils of node to ˜e removedF ‡hen user enters the ™orre™t det—ilsD the€w… node entry would ˜e removed from the (e ip—ddressFtxtF elso the ™orrespondingvower•v—yer het—ils node would ˜e removed from dou˜ly vvF e sign—l would ˜e sent tothe thre—d th—t h—ndles this ™onne™tionF yn re™eiv—l of the sign—l the thre—d would ™losethe so™ket —nd exitF„his fun™tion—lity is distri˜uted in the following fun™tions XE int remove_Lower_Node(charpmuid[], char protocol[]), void remove_Lower_Node() and void* remove_llnode(void*)from the (le new_pmu_or_pdc.cF Q
  9. 9. 1.4 Turn OFF the data Transmission„his would displ—y the user with —v—il—˜le €w… entries —nd would prompt the user to enterthe det—ils of node whose d—t— tr—nsmission is to ˜e put oF ‡hen user enters the ™orre™t ¡det—ilsD the ™omm—nd fr—me would ˜e sent to th—t nodeF „he )—g d—t—•tr—nsmission•oóf the ™orresponding node in vower•v—yer•het—ils stru™ture dou˜ly vv would ˜e set to IF„his fun™tion—lity is distri˜uted in the following fun™tions XE int put_data_transmission_o(char pmuid[], char protocol[]) and void* data_o_llnode(void* temp)from the (le new_pmu_or_pdc.cF1.5 Turn ON the data Transmission„his would displ—y the user with —v—il—˜le €w… entries whose d—t— tr—nsmission h—s˜een put o —nd would prompt the user to enter the det—ils of node whose d—t— tr—nsEmission is to ˜e put onF ‡hen user enters the ™orre™t det—ilsD the ™omm—nd fr—me to ¡put o d—t— tr—msission would ˜e sent to th—t nodeF „he )—g d—t—•tr—nsmission•o ófthe ™orresponding node in vower•v—yer•het—ils stru™ture dou˜ly vv would ˜e reset to HF„his fun™tion—lity is distri˜uted in the following fun™tions XE int put_data_transmission_on(char pmuid[], char protocol[]) and void* data_on_llnode(void* temp)from the (le new_pmu_or_pdc.cF1.6 Request Conguration frame„his would displ—y the user with —v—il—˜le €w… entries —nd would prompt the user toenter the det—ils of node to whom the ™on(gur—tion fr—me request is to ˜e sentF ‡henuser enters the ™orre™t det—ilsD the ™omm—nd fr—me to send the ™on(gur—tion fr—me would˜e sent to th—t nodeF„his fun™tion—lity is distri˜uted in the following fun™tions XE int conguration_request(charpmuid[], char protocol[]) and void* cong_request(void* temp)from the (le new_pmu_or_pdc.cF R
  10. 10. 1.7 Add a Destination Deviceen entry is m—de in the (le upperpd™•ipFtxtF elso — node of the type …pper•v—yer•het—ilsis ™re—tedF st in™ludes ipD port —nd proto™ol det—ils of other i€hgF i€hg when —™tEing —s — server m—y get ™onne™tion requests on THHH —nd THHI ports for …h€ —nd „g€repe™tivelyF „he re™eived ™omm—nd fr—mes —re —uthenti™—ted —g—int the entries in the…pper•v—yer•het—ils dou˜ly vvF sf the ™omm—nd fr—me is for ™on(gur—tion fr—me thenD™he™k is m—de if there —re no sd™odes in the ±t—tus•™h—nge•pmupd™id ¡ ±t—tus•™h—nge•pmupd™id Fís — vv whi™h m—int—ins the id™odes of —ll €w…± whose ™on(gur—tion h—s ˜eed ™h—ngedFsf the list is not empty thenD poll till the list is emptyF ‡hen — new gon(gur—tion fr—meof the ™orresponding sh ™odes —rrives then its entry is removed from the listF efterthe list is empty ™re—te•™fgfr—me@A is ™—lled th—t ™re—tes ™om˜ined ™on(gur—tion fr—mefrom ™on(gur—tion o˜je™tsF „hen the )—g …v•upper•pd™•™fgsent in the ™orresponding…pper•v—yer•het—ils node of the €hg is setF sf the ™omm—nd fr—me is for d—t— thenD …v•upper•pd™•d—t—sent is set —nd…v•d—t—•tr—nsmission•o in the ™orresponding …pper•v—yer•het—ils node of the i€hgis resetF „he fun™tions disp—t™h@A in —lign•sort@A will send the ™om˜ined d—t— on oneof the so™kets ˜y ™he™king the v—ri—˜les …v•use•udpD …v•upper•pd™•™fgsent —nd…v•d—t—•tr—nsmission•oF sf the ™omm—nd fr—me is for d—t— tr—nsmisssion o then…v•d—t—•tr—nsmission•o in the ™orresponding …pper•v—yer•het—ils node is setF int add_PDC(char ip[], „his fun™tion—lity is distri˜uted in the following fun™tions XEchar protocol[]) from the (le new_pmu_or_pdc.c —nd void* UL_udp() and void*UL_tcp() from (le connections.cF1.8 Remove a Destination Device„his would remove the i€hg entry from the (le upperpd™•ipFtxtF elso the ™orrespondingnode of the type …pper•v—yer•het—ils would ˜e removed from the dou˜ly vvF1.9 iPDC Connection Table„his would displ—y the ™onne™tions t—˜les showing €w… —nd i€hg det—ils to whi™h thei€hg is ™onne™tedF S
  11. 11. 2 Source Code Documentation of iPDC„he ™ode is distri˜uted in the following (les • i€hgF™ • ipd™quiF™ • ipd™quiFh • re™re—teF™ • re™re—teFh • ™onne™tionsF™ • ™onne™tionsFh • new•pmu•or•pd™F™ • new•pmu•or•pd™Fh • p—rserF™ • p—rserFh • d—llo™—teF™ • d—llo™—teFh • —lign•sortF™ • —lign•sortFh • glo˜—lFh2.1 iPDC.cst is the (le th—t ™ont—ins the m—in@AF st intern—lly ™—lls P fun™tions • void re™re—te•™fg•o˜je™ts@A • void setup@A T
  12. 12. 2.2 ipdcGui.cst is the (le th—t ™ont—ins —ll the q…s fun™tions for i€hg • int isxum˜er@™h—r BsA • void destroy @qtk‡idget BwidgetD gpointer ud—t—A • void displ—y•pd™•det—il @qtkfutton BwidgetD gpointer ud—t—A • void —˜out•ipd™ @qtkfutton BwidgetD gpointer ud—t—A • void ipd™•help @qtkfutton B˜utD gpointer ud—t—A • void v—lid—tion•result @™h—r BmsgA • void ipd™•™olors @A • void pd™•det—ils @qtkfutton B˜uttonD gpointer ud—t—A • void (ll•pd™•det—ils @A • int v—lid—tion•pd™•det—il @qtkfutton B˜uttonD gpointer ud—t—A • void —dd•pmu @qtkfutton B˜utD gpointer ud—t—A • int —dd•pmu•v—lid—tion @qtkfutton B˜utD gpointer ud—t—A • void ™md•or•remove•pmu @qtkfutton B˜utD gpointer ud—t—A • int ™md•or•remove•pmu•v—lid—tion @qtkfutton B˜utD gpointer ud—t—A • void —dd•new•pd™ @qtkfutton B˜utD gpointer ud—t—A • int new•pd™•v—lid—tion @qtkfutton B˜utD gpointer ud—t—A • void remove•pd™ @qtkfutton B˜utD gpointer ud—t—A • int remove•pd™•v—lid—tion @qtkfutton B˜utD gpointer ud—t—A • void ™onne™tion•t—˜le @qtkfutton B˜utD gpointer ud—t—A U
  13. 13. 2.3 Functions in recreate.c • void re™re—te•™fg•o˜je™ts@A • void init•™fgp—rser@unsigned ™h—r st‘“A • void re™re—te•gonne™tion•„—˜le@A2.4 Functions in connections.c • void setup@A • void sig™hld•h—ndler@A • voidB …v•udp@A • voidB …v•t™p@A • voidB …v•t™p•™onne™tion@void B newfdA • void €w…•pro™ess•…h€@unsigned ™h—r BDstru™t so™k—ddr•inDint so™kfdA • void €w…•pro™ess•„g€@unsigned ™h—r t™p•˜uer‘“Dint so™kfdA2.5 Functions in new_pmu_or_pdc.c • int —dd•€w…@™h—r pmuid‘“D ™h—r ip‘“D ™h—r port‘“D ™h—r proto™ol‘“A • voidB ™onne™t•pmu•t™p@void BtempA • voidB ™onne™t•pmu•udp@void BtempA • int remove•vower•xode@™h—r pmuid‘“D ™h—r proto™ol‘“A • voidB remove•llnode@voidBA • int put•d—t—•tr—nsmission•o@™h—r pmuid‘“D ™h—r proto™ol‘“A • voidB d—t—•o•llnode@voidB tempA • int put•d—t—•tr—nsmission•on@™h—r pmuid‘“D ™h—r proto™ol‘“A • voidB d—t—•on•llnode@voidB tempA • int ™on(gur—tion•request@™h—r pmuid‘“D ™h—r proto™ol‘“A • voidB ™on(g•request@voidB tempA V
  14. 14. • int —dd•€hg@™h—r ip‘“D ™h—r proto™ol‘“A • int remove•€hg@™h—r ip‘“D ™h—r port•num‘“D ™h—r proto™ol‘“A • void displ—y•g„@A • void ™re—te•™omm—nd•fr—me@int typeDint pmuidD™h—r BA • int ™he™kip@™h—r ip‘“A2.6 Functions in parser.c • void ™fgp—rser@unsigned ™h—r ‘“A • int remove•old•™fg@unsigned ™h—r‘“A • void d—t—p—rser@unsigned ™h—r‘“A • int ™he™k•st—tword@unsigned ™h—r st—t‘“A • void —dd•pmuid•from•st—tus•™h—nge•list@unsigned ™h—r id™ode‘“A • void remove•id•from•st—tus•™h—nge•list@unsigned ™h—r id™ode‘“A • unsigned int to•int™onvertor@unsigned ™h—r ‘“A • void long•int•to•—s™ii•™onvertor @long int nDunsigned ™h—r hex‘“A • void ™opy•™˜y™@unsigned ™h—r dst‘“Dunsigned ™h—r BsDint sizeA • int n™mp•™˜y™@unsigned ™h—r dst‘“Dunsigned ™h—r sr™‘“Dint sizeA • void ˜yte•˜y•˜yte•™opy@unsigned ™h—r dst‘“Dunsigned ™h—r sr™‘“Dint indexDint nA • unsigned long int to•long•int•™onvertor@unsigned ™h—r —rr—y‘“A • uintIT•t ™ompute•g‚g@unsigned ™h—r Bmess—geD™h—r lengthA2.7 Functions in dallocate.c • void free•™fgfr—me•o˜je™t@stru™t ™fg•fr—me B™fgA • void free•d—t—fr—me•o˜je™t@stru™t d—t—•fr—me BdfA • void free•Pd—rr—y@™h—rBB —rr—yD int xA W
  15. 15. 2.8 Functions in align_sort.c • void time•—lign@stru™t d—t—•fr—me BdfA • void —ssign•df•to•„ƒf@stru™t d—t—•fr—me BdfDint indexA • void disp—t™h@int indexA • void sort•d—t—•inside•„ƒf@int indexA • void ™le—r•„ƒf@int indexA • void ™re—te•d—t—fr—me@int indexA • void ™re—te•™fgfr—me@A2.9 global.hst ™ont—ins the mutex v—ri—˜les —nd other glo˜—l v—ri—˜les to ˜e used —™ross —ll the (lesF2.10 Detailed Description2.10.1 recreate.c • void recreate_cfg_objects() re™re—te•™fg•o˜je™ts@A is present in the (le re™re—teF™F ‡hen p—rsing the ™on(gE ur—tion fr—meD —long with ™on(gur—tion o˜je™ts ™re—tion the ™on(gur—tion fr—me is —lso written into (le ™fgF˜inF sf FGserver —˜orts the ™on(gur—tion o˜je™ts in the memory would ˜e lostF ƒo on rest—rting the FGserver this fun™tion ™—ll would re—d the (le ™fgF˜in —nd re™re—te ™on(gur—tion o˜je™ts in memoryF por this it ™—lls init•™fgp—rser@AF • void init_cfgparser(unsigned char st[]) st is ™—lled ˜y re™re—te•™fg•o˜je™ts@AF „he fun™tion re™re—te•™fg•o˜je™ts@A re—ds (le 9™fgF˜in9 line ˜y lineF i—™h line is — preEstored ™fg o˜je™tsF por e—™h line re—dD init•™fgp—rser@lineA is ™—lled whi™h ™re—tes the o˜jet™s in the memoryF • void recreate_Connection_Table() IH
  16. 16. 2.10.2 connections.c • void setup() setup@A is present in the (le ™onne™tionsF™F st ™re—tes P so™kets for …h€ —nd „g€ e—™hF ƒep—r—te ports for e—™h —re m—int—inedD …h€€y‚„ for …h€ —nd „g€€y‚„ for „g€ so th—t the €w… ™—n ™ommuni™—te using —ny ™ommuni™—tion proto™olF st ™re—tes P thre—ds ˜y ™—lling voidB …v•udp —nd voidB …v•t™pF „hre—ds th—t —re ™re—ted —re in xyxEhi„egrih modeF „here is one more thre—d ™re—ted ˜y ™—lling voidB ehh•€w…•€hg@AF „his is — prompt to user provided with — set of options like —dd €w… et™F „here is —nother so™ket ™re—ted th—t ˜inds to — port hf€y‚„ @def—ult WHHHAF s€ spe™i(ed ˜y the user when the €hg is st—rtedF „his so™ket is to send the d—t— to — m—™hine where d˜server is runningF • void sigchld_handler() • void* UL_udp() r—ndles …h€ ™onne™tions on port …h€€y‚„F ‚esponsi˜le for h—ndling ™omm—nd fr—mes from i€hg± on — …h€ ™ommuni™—tion proto™olF • void* UL_tcp() e™™epts „g€ ™onne™tions of i€hg on port „g€€y‚„F • void* UL_tcp_connection(void * newfd) ‚esponsi˜le for h—ndling ™omm—nd fr—mes from i€hg± on — „g€ ™ommuni™—tion proto™olF • void PMU_process_UDP(unsigned char *,struct sockaddr_in,int sockfd) st ™he™ks the type of fr—me th—t h—s ˜een re™eived —nd ™—lls —ppropri—te p—rserF sf ¡ d—t— fr—meís re™eivedD then it ™—lls d—t—•p—rser@AF f—sed on the return v—lue of the d—t—•p—rser@A t—ke —ppropri—te —™tion su™h —s if st—t ˜it IH is I then send the ™omm—nd fr—me to €w… to send its ™on(gur—tion fr—meF sf ¢on(gur—tion ¡ fr—me is re™eivedD then it ™—lls ™fgp—rser@AF st —lso sends the ™omm—nd fr—me to €w… to st—rt sending its d—t— fr—mesF sf ¢omm—nd¡ fr—me is re™eived the —™tion to ˜e t—ken is not h—ndledF • void PMU_process_TCP(unsigned char tcp_buer[],int sockfd) st ™he™ks the type of fr—me th—t h—s ˜een re™eived —nd ™—lls —ppropri—te p—rserF sf ¡ d—t— fr—meís re™eivedD then it ™—lls d—t—•p—rser@A present in (le p—rserF™F f—sed on the return v—lue of the d—t—•p—rser@A t—ke —ppropri—te —™tion su™h —s if st—t ˜it II
  17. 17. IH is I then send the ™omm—nd fr—me to €w… to send its ™on(gur—tion fr—meF sf ¢on(gur—tion ¡fr—me is re™eivedD then it ™—lls ™fgp—rser@A present in (leF st —lso sends the ™omm—nd fr—me to €w… to st—rt sending its d—t— fr—mesF sf ¢omm—nd ¡ fr—me is re™eived the —™tion to ˜e t—ken is not h—ndledF2.10.3 new_pmu_or_pdc.c • Explained under General working of iPDC int —dd•€w…@™h—r pmuid‘“D ™h—r ip‘“D ™h—r port‘“D ™h—r proto™ol‘“AD int remove•€hg@AD void —dd•€w…@AD voidB ™onne™t•pmu•t™p@AD voidB ™onne™t•pmu•udp@AD void —dd•€w…•xode@AD void remove•vower•xode@AD voidB remove•llnode@voidBAD void put•d—t—•tr—nsmission•o@AD voidB d—t—•o•llnode@voidB tempAD void put•d—t—•tr—nsmission•on@AD voidB d—t—•on•llnode@voidB tempAD void ™onE (gur—tion•request@AD voidB ™on(g•request@voidB tempAD void displ—y•g„@A • void create_command_frame(int type,int pmuid,char *) „his would ™re—te Q kinds of ™omm—nd fr—mesD gomm—nd to send the gpqD gomE m—nd to send the d—t— Dgomm—nd to put o the d—t— tr—nsmissionF • int checkip(char ip[]) „his fun™tion ™he™ks if the sp —ddress entered ˜y the user is — v—lid s€ —ddressF2.10.4 parser.c • void cfgparser(unsigned char []) ƒimil—r to init•™fgp—rser@fr—meA ex™ept the fr—me is now the fr—me th—t —™tu—lly ™omes from €w… over „g€G…h€F st p—rses —nd ™re—tes o˜je™ts in memoryF • int remove_old_cfg(unsigned char[]) sf — ™h—nged ™fg —rrives —t i€hg thenD this fun™tion rep—™es the old entry in the (le ™fgF˜in with the new fr—meF • void dataparser(unsigned char[]) €—rses the d—t— fr—me —nd ™re—tes d—t— o˜je™ts in memoryF st (rst ™he™ks the ™on(gu—rtion o˜je™ts th—t to (nd — m—t™h for — ™orresponding idF „hen sep—r—tes the (elds of the d—t— fr—me —nd ™re—tes d—t— o˜je™tsF ƒin™e there —re no sep—r—ters for the d—t— in d—t— fr—me the ™orresponding ™on(gur—tion o˜je™t gives these det—ilsF por ex—mples it ™ont—ins the num˜er of pmu d—t—DphnmrD —nnmr et™F „hese num˜ers ™—n ˜e used to sep—r—te the d—t— fr—me ˜y — (xed num˜er of ˜ytesF por ex—mple if ™fg o˜je™ts s—ys phnmr a PD —nd form—t is re™t—ngul—r for ph—sorD then we —llo™—te IP
  18. 18. memory for P ph—sors —nd sep—r—te IT ™h—r—™ters from the existing d—t— fr—me from the ™urrent pointer position@es ph—sor with re™t—ngul—r form—t —nd —ssuming d—t— ™oming hex—de™im—l form e—™h ph—sor me—surement in the d—t— fr—me would V ™h—r—™ters in lengthAF• int check_statword(unsigned char stat[]) st—t word in the d—t— fr—me is the most import—ntF st indi™—tes the st—tus of the d—t— ˜lo™k in the d—t— fr—meF ren™e we ™he™k the ˜its of of sts wordF es per the error indi™—tions mentioned in the siiigQUFIIV ƒt—nd—rd for e—™h ˜it in the st—t word we m—ke — print on ™onsoleF st reurn the ˜it num˜ers —s errorsF„he progr—mmer h—s ¡ reserved ˜its HQEHH whose v—lue —s IIII or píndi™—tes the d—t— h—s not —rived for th—t €w…F „his is set —nd is useful when — i€hg sends — ™om˜ined d—t— fr—me to other i€hgF• void add_pmuid_from_status_change_list(unsigned char idcode[]) sf the error is pert—ining to ™on(gur—tion ™h—nge of €w…Gi€hg then we —dd the its entry to — ±t—tus•™h—nge•pmupd™id whi™h is — linked list m—int—ining the ids of ¡ —ll €w…Gi€hg under the ™urrent i€hg whose st—tus rel—ted to ™on(gur—tion h—s ˜een ™h—ngedF• void remove_id_from_status_change_list(unsigned char idcode[]) ‡hen — new ™on(gur—tion fr—me is re™eived —nd there is ™—ll to ™fgp—rser@AD there is — ™—ll within this ™fgp—rser@A for — remove•id•from•st—tus•™h—nge•list@™h—r id™ode‘“AF st looks if its id™ode is in the list ±t—tus•™h—nge•pmupd™id ¡ sf so it F removes its entry from the listF• unsigned int to_intconvertor(unsigned char []) gonverts the ˜in—ry P ˜yte unsigned ™h—r—™ter v—lue to equiv—lent intF• void long_int_to_ascii_convertor (long int n,unsigned char hex[]) gonverts the unsigned long int v—lue to — R ˜yte unsigned ™h—r—™ter v—lueF• void copy_cbyc(unsigned char dst[],unsigned char *s,int size) €erforms ™opy of size ˜ytes to destin—tion —rr—yF• int ncmp_cbyc(unsigned char dst[],unsigned char src[],int size) €erforms ™om—prison of size ˜ytes of ˜oth —rr—ysF• void byte_by_byte_copy(unsigned char dst[],unsigned char src[], int index,int n) IQ
  19. 19. €erforms ™opy of size ˜ytes to destin—tion —rr—y from its index position to index C nF • unsigned long int to_long_int_convertor(unsigned char array[]) gonverts the ˜in—ry R ˜yte unsigned ™h—r—™ter v—lue to equiv—lent unsigned long intF • uint16_t compute_CRC(unsigned char *message,char length) g—l™ul—tes ™he™ksum of — fr—me of size lengthF2.10.5 dallocate.c • void free_cfgframe_object(struct cfg_frame *cfg) ƒin™e we dyn—mi™—lly —llo™—te memory to ™fg o˜jet™s we need to free it on™e our t—sk is doneF „his fun™tion does the s—meF • void free_dataframe_object(struct data_frame *df) ƒin™e we dyn—mi™—lly —llo™—te memory to d—t— o˜jet™s we need to free it on™e our t—sk is doneF „his fun™tion does the s—meF • void free_2darray(char** array, int x) prees Ph err—ys th—t were —llo™—ted memory using m—llo™@AF2.10.6 align_sort.c • void time_align(struct data_frame *df) ‡e use gir™ul—r queue to —lign the d—t— fr—me o˜je™ts —s per their so™ —nd fr—™se™F „he size of ™ir™ul—r queue is de(ned —s weˆ„ƒfF „his fun™tion (nds the ™orre™ts „ƒf‘“ —nd ™—lls —ssign•df•to•„ƒf@A ˜y p—ssing the index of the „ƒf to whi™h the d—t— fr—me o˜je™t df is to ˜e —ssigned toF elso if —ll „ƒf‘“ ˜uers —re full it ™—lls disp—t™h@re—rAD ™le—r•„ƒf@re—rAD —ssign•df•to•„ƒf@dfDre—rA in the s—me orderF • void assign_df_to_TSB(struct data_frame *df,int index) st —ssigns df d—t—•fr—me o˜je™t to the „ƒf‘index“ —t the end of list —s indi™—ted ˜y stru™t d—t—•fr—me B(rst•d—t—•fr—meF st tr—verses the end of the list of d—t— fr—me o˜je™ts —nd then —ssigns df to the Bdnext of l—st d—t— fr—me o˜je™tF elso if the „ƒf‘“ is used for the (rst time it —llo™—tes memory to the mem˜er v—ri—˜les of the „ƒf‘index“ —nd (lls the ídlistwith the pmuGpd™ id± from whom d—t— fr—mes would ¡ —rriveF IR
  20. 20. • void dispatch(int index) st intern—lly ™—lls void sort•d—t—•inside•„ƒf@indexAD void ™re—te•d—t—fr—me@indexAD ™le—r•„ƒf@indexA in the s—me orderF• void sort_data_inside_TSB(int index) „his fun™tion will sort the d—t— fr—me o˜je™t vv —s per the id± in ídlistˆvF• void clear_TSB(int index) „his will ™le—r „ƒf‘index“ mem˜er v—ri—˜les to ¡ ¡ HF• void create_dataframe(int index) „his will ™re—te ™om˜ined d—t— fr—me to ˜e sent to — hestin—tion €hg when — ™omm—nd fr—me is re™eivedF• void create_cfgframe() „his will ™re—te ™om˜ined ™on(gur—tion fr—me to ˜e sent to — hestin—tion €hg when — ™omm—nd fr—me is re™eivedF IS
  21. 21. 2.11 Data Structures Used • Data Structure for Conguration Frame ™fg•fr—meD for•e—™h•pmuD ™h—nnel•n—mesD dgn—mesD form—t —re the d—t— stru™E tures de(ned for the ™on(gur—tion fr—meF ¡ form—t ís —n —ddition—l d—t— stru™ture th—t h—s ˜een de(nedF st simpli(es the t—sk of distinguishing the me—surements —s )o—tingG(xedD pol—rGre™t—ngul—rF es per siiigQUFIIV ƒyn™hroph—sor ƒt—nd—rdD form—t (eld in ™on(gur—tion fr—me is P ˜ytes @R ™h—r—™ters in hex—de™im—lAF fits ISER …nused fit QX H a p‚iGhp‚i IT E˜it integerD I a )o—ting point fit PX H a —n—logs IT E˜it integerD I a )o—ting point fit IX H a ph—sors IT E˜it integerD I a )o—ting point fit HX H a ph—sor re™t—ngul—rD I a ph—sor re™t—ngul—r • Data Structure for Data Frame d—t—•fr—me —nd d—t—•for•e—™h•pmu —re the d—t— stru™tures de(ned for d—t— fr—mesF • Data Structure to store ID± of those PMU/iPDC whose CFG has changed ±t—tus•™h—nge•pmupd™id ¡he d—t— stru™ture de(ned to m—int—in the id™odes of t €w…Gi€hg whose ™on(gur—tion h—s ˜een ™h—ngedF sd rem—ining in the memory till new gon(gur—tion o˜je™t for th—t id™ode —rrivesF • Data Structure to store Source Device Details vower•v—yer•het—ils is the d—t— stru™ture de(ned to m—int—in the the det—ils of sour™e devi™es from whi™h i€hg re™eives the d—t—F • Data Structure to store Destination Device Details …pper•v—yer•het—ils is the d—t— stru™ture de(ned to m—int—in the the det—ils of destin—tion devi™es to whi™h i€hg sends the d—t—F IT
  22. 22. • Data Structure for Time Stamp Buer „imeƒt—mpfuer —nd pmupd™•id•list —re the d—t— stru™tures de(ned to ˜e used in time —ligning —nd sorting of d—t— fr—mesF IU
  23. 23. struct cfg_frame { unsigned char *framesize; unsigned char *idcode; unsigned char *soc; unsigned char *fracsec; unsigned char *time_base; unsigned char *num_pmu; struct for_each_pmu **pmu; unsigned char *data_rate; struct cfg_frame *cfgnext;}*cfgfirst;struct for_each_pmu{ unsigned char *stn; unsigned char *idcode; unsigned char *data_format; struct format *fmt; unsigned char *phnmr; unsigned char *annmr; unsigned char *dgnmr; struct channel_names *cnext; unsigned char **phunit; unsigned char **anunit; unsigned char **dgunit; unsigned char *fnom; unsigned char *cfg_cnt;};struct channel_names { unsigned char **phnames; unsigned char **angnames; struct dgnames *first;};struct dgnames { unsigned char **dgn; struct dgnames *dg_next;};struct format{ unsigned char freq; unsigned char analog; unsigned char phasor; unsigned char polar;}; IV pigure IX Conguration Frame.
  24. 24. struct data_frame { unsigned char *framesize; unsigned char *idcode; unsigned char *soc; unsigned char *fracsec; int num_pmu; struct data_for_each_pmu **dpmu; struct data_frame *dnext;};struct data_for_each_pmu { unsigned char *stat; int phnmr; int annmr; int dgnmr; struct format *fmt; unsigned char **phasors; unsigned char **analog; unsigned char *freq; unsigned char *dfreq; unsigned char **digital;}; pigure PX Data Frame.struct status_change_pmupdcid { char idcode[5]; struct status_change_pmupdcid *pmuid_next;}*root_pmuid; pigure QX PMU Status Change. IW
  25. 25. struct Lower_Layer_Details { unsigned int pmuid; char ip[16]; int port; char protocol[4]; int sockfd; int up; //used only in tcp struct sockaddr_in llpmu_addr; pthread_t thread_id; int data_transmission_off; int pmu_remove; int request_cfg_frame; struct Lower_Layer_Details *next; struct Lower_Layer_Details *prev;}*LLfirst,*LLlast; pigure RX Source Device Detailsstruct Upper_Layer_Details { char ip[16]; int port; char protocol[4]; int sockfd; struct sockaddr_in pdc_addr; int config_change; int UL_upper_pdc_cfgsent; int UL_data_transmission_off; int address_set; struct Upper_Layer_Details *next; struct Upper_Layer_Details *prev;}*ULfirst,*ULlast; pigure SX Destination Device Details PH
  26. 26. struct TimeStampBuffer { char *soc; char *fracsec; struct pmupdc_id_list *idlist; struct data_frame *first_data_frame;}TSB[MAXTSB];struct pmupdc_id_list { char *idcode; int num_pmu; struct pmupdc_id_list *nextid;}; pigure TX Time Stamp Buer PI
  27. 27. 3 Source Code Documentation of DBServer„he ™ode is distri˜uted in the following (les • d˜ƒerverF™ • re™re—teF™ • re™re—teFh • ™onne™tionsF™ • ™onne™tionsFh • p—rserF™ • p—rserFh • d—llo™—teF™ • d—llo™—teFh • glo˜—lFh3.1 dbServer.cst is the (le th—t ™ont—ins the m—in@AF st intern—lly ™—lls P fun™tions • void re™re—te•™fg•o˜je™ts@A • void setup@A3.2 Functions in recreate.c • void re™re—te•™fg•o˜je™ts@A • void init•™fgp—rser@unsigned ™h—r st‘“A3.3 Functions in connections.c • void setup@A • void hf•udp@A • voidB hf•udph—ndler@void B udp•f…pA • void hf•pro™ess•…h€@unsigned ™h—rB udp•f…pA PP
  28. 28. 3.4 Functions in parser.c • void ™fgp—rser@unsigned ™h—r ‘“A • void ™fginsert@stru™t ™fg•fr—me BA • int remove•old•™fg@unsigned ™h—r‘“A • void d—t—p—rser@unsigned ™h—r‘“A • int ™he™k•st—tword@unsigned ™h—r st—t‘“A • unsigned int to•int™onvertor@unsigned ™h—r ‘“A • unsigned long int to•long•int•™onvertor@unsigned ™h—r —rr—y‘“A • )o—t de™ode•ieee•single@™onst void BvA • void ™opy•™˜y™@unsigned ™h—r dst‘“Dunsigned ™h—r BsDint sizeA • int n™mp•™˜y™@unsigned ™h—r dst‘“Dunsigned ™h—r sr™‘“Dint sizeA3.5 Functions in dallocate.c • void free•™fgfr—me•o˜je™t@stru™t ™fg•fr—me B™fgA • void free•d—t—fr—me•o˜je™t@stru™t d—t—•fr—me BdfA • void free•Pd—rr—y@™h—rBB —rr—yD int xA3.6 global.hst ™ont—ins the mutex v—ri—˜les —nd other glo˜—l v—ri—˜les to ˜e used —™ross —ll the (lesF3.7 Detailed Description3.7.1 recreate.cƒ—me —s des™ri˜ed —˜ove in re™re—teF™ PQ
  29. 29. 3.7.2 connections.c • void setup@A „his fun™tion ™re—ted wyƒv d—t—˜—se ™onne™tion —nd —lso ˜inds to …h€ port WHHHF • void hf•udp@A st re™eives the udp d—t— from i€hgD ™re—tes — thre—d ˜y ™—lling hf•udph—ndler@A —nd p—sses the d—t— to itF • voidB hf•udph—ndler@void B udp•f…pA sntern—lly it ™—lls hf•pro™ess•…h€@AF • void hf•pro™ess•…h€@unsigned ™h—rB udp•f…pA st ™he™ks the type of fr—me th—t h—s ˜een re™eived —nd ™—lls —ppropri—te p—rserF sf d—t— fr—me ís re™eivedD then it ™—lls d—t—•p—rser@AF sf ¢on(gur—tion ¡ ¡ fr—me is re™eivedD then it ™—lls ™fgp—rser@AF3.7.3 parser.c • void cfgparser(unsigned char []) ƒimil—r to init•™fgp—rser@fr—meA it p—rses —nd ™re—tes o˜je™ts in memoryF • void cfginsert(struct cfg_frame *) snsertG…pd—te the ™on(gur—tion fr—me in the ™on(gur—tion t—˜lesF • int remove_old_cfg(unsigned char[]) sf — ™h—nged ™fg —rrives —t i€hg then for — €w…D this fun™tion rep—™es the old entry in the (le ™fgF˜in with the new fr—meF • void dataparser(unsigned char[]) €—rse the d—t— fr—me —n insert into the d—t— t—˜les of i€hg d—t—˜—seF • int check_statword(unsigned char stat[]) st—t word in the d—t— fr—me is the most import—ntF st indi™—tes the st—tus of the d—t— ˜lo™k in the d—t— fr—meF ren™e we ™he™k the ˜its of of sts wordF es per the error indi™—tions mentioned in the siiigQUFIIV ƒt—nd—rd for e—™h ˜it in the st—t word we m—ke — print on ™onsoleF st reurn the ˜it num˜ers —s errorsF„he progr—mmer h—s ¡ reserved ˜its HQEHH whose v—lue —s IIII or píndi™—tes the d—t— h—s not —rived for th—t €w…F „his is set —nd is useful when — €hg sends — ™om˜ined d—t— fr—me to other i€hgF PR
  30. 30. • unsigned int to_intconvertor(unsigned char []) gonverts the ˜in—ry P ˜yte unsigned ™h—r—™ter v—lue to equiv—lent intF • unsigned long int to_long_int_convertor(unsigned char array[]) gonverts the ˜in—ry R ˜yte unsigned ™h—r—™ter v—lue to equiv—lent long intF • oat decode_ieee_single(const void *v) gonverts the ˜in—ry R ˜yte unsigned ™h—r—™ter v—lue to equiv—lent )o—t v—lueF • void copy_cbyc(unsigned char dst[],unsigned char *s,int size) €erforms ™opy of size ˜ytes to destin—tion —rr—yF • int ncmp_cbyc(unsigned char dst[],unsigned char src[],int size) €erforms ™om—prison of size ˜ytes of ˜oth —rr—ysF3.7.4 dallocate.cƒ—me —s des™ri˜e —˜oveF3.8 Data Structures Used • Data Structure for Conguration Frame ™fg•fr—meD for•e—™h•pmuD ™h—nnel•n—mesD dgn—mesD form—t —re the d—t— stru™E tures de(ned for the ™on(gur—tion fr—meF ¡ form—t ís —n —ddition—l d—t— stru™ture th—t h—s ˜een de(nedF st simpli(es the t—sk of distinguishing the me—surements —s )o—tingG(xedD pol—rGre™t—ngul—rF es per siiigQUFIIV ƒyn™hroph—sor ƒt—nd—rdD form—t (eld in ™on(gur—tion fr—me is P ˜ytes @R ™h—r—™ters in hex—de™im—lAF fits ISER …nused fit QX H a p‚iGhp‚i IT E˜it integerD I a )o—ting point fit PX H a —n—logs IT E˜it integerD I a )o—ting point fit IX H a ph—sors IT E˜it integerD I a )o—ting point fit HX H a ph—sor re™t—ngul—rD PS
  31. 31. I a ph—sor re™t—ngul—r• Data Structure for Data Frame d—t—•fr—me —nd d—t—•for•e—™h•pmu —re the d—t— stru™tures de(ned for d—t— fr—mesF PT
  32. 32. struct cfg_frame { unsigned int framesize; unsigned int idcode; unsigned long int soc; unsigned long int fracsec; unsigned long int time_base; unsigned int num_pmu; struct for_each_pmu **pmu; unsigned int data_rate; struct cfg_frame *cfgnext;}*cfgfirst;struct for_each_pmu{ unsigned char stn[17]; unsigned int idcode; char data_format[3]; struct format *fmt; unsigned int phnmr; unsigned int annmr; unsigned int dgnmr; struct channel_names *cnext; float **phunit; float **anunit; unsigned char **dgunit; unsigned int fnom; unsigned int cfg_cnt;};struct channel_names { unsigned char **phnames; unsigned char **angnames; struct dgnames *first;};struct dgnames { unsigned char **dgn; struct dgnames *dg_next;};struct format{ char freq; char analog; char phasor; char polar;}; PU pigure UX DBServer Conguration Frame
  33. 33. struct data_frame { unsigned char *framesize; unsigned char *idcode; unsigned char *soc; unsigned char *fracsec; int num_pmu; struct data_for_each_pmu **dpmu; struct data_frame *dnext;};struct data_for_each_pmu { unsigned char *stat; int phnmr; int annmr; int dgnmr; struct format *fmt; unsigned char **phasors; unsigned char **analog; unsigned char *freq; unsigned char *dfreq; unsigned char **digital;}; pigure VX DBServer Data Frame PV
  34. 34. 4 iPDC Databaseƒ™ript d˜Fsql gives the hhv st—tements to ™re—te the s™hem—F sn the wyƒv d—t—˜—sen—med open€hg there —re W t—˜les n—medXE • MAIN_CFG_TABLE • SUB_CFG_TABLE • PHASOR • ANALOG • DIGITAL • PHASOR_MEASUREMENTS • ANALOG_MEASUREMENTS • FREQUENCY_MEASUREMENTS • DIGITAL_MEASUREMENTSgon(gur—tion fr—mes —re stored in wesx•gpq•„efviD ƒ…f•gpq•„efviD €reEƒy‚D exevyqD hsqs„evF h—t— fr—mes —re stored in €reƒy‚•wieƒ…‚iwix„ƒDexevyq•wieƒ…‚iwix„ƒD p‚i…ixg‰•wieƒ…‚iwix„ƒDhsqs„ev•wieƒ…‚iwix„ƒF „he s™hem— di—gr—m shows the fun™tion—l dependen™ies—mong the t—˜lesF PW
  35. 35. pigure WX i€hg h—t—˜—se QH
  36. 36. 5 General Working of PMU Simulator€w… ƒimul—tor —™t —s servers when ™ommuni™—ting with €hg whom they —re sendingthe d—t—G™on(gur—tion fr—mesF „he €hg re™eiving d—t— in this ™—se —™ts —s — ™lientF „hisp—ttern will ˜e repe—ted in the ‡ewƒ topology with one peer —™ting —s server —nd its™ounterp—rt — ™lientF €w… ƒimul—tor —™ting —s — server —nd ˜inding — port for …h€ or „g€F st would ˜elistening for …h€ ™onne™tions on …h€€y‚„ or for „g€ ™onne™tions on „g€€y‚„F„he €w… ƒimul—tor re™eives the ™omm—nd fr—mes from €hg —nd send the ™on(gur—tionfr—me —nd d—t— fr—mes to €hgF foth the ™ommuni™—ting peers —uthenti™—te e—™h otherthrough sh godeF ‡hen the €w… ƒimul—tor st—rts for the (rst time the user is prompted to enter €w…ƒetup det—ils €ort num˜er —nd €roto™olF „he ports en—˜le €w… ƒimul—tor to re™eiverequests from €hg —nd to send the d—t— —nd ™on(gur—tion fr—mesF €w… ƒimul—tor genEer—tes the d—t— —nd ™on(gur—tion fr—mes in siii gQUFIIV form—tF „he user is provided with the following options —t €w… ƒimul—tor • inter €w… ƒetup • €w… gon(gur—tion ƒetup • re—der pr—me qener—tion • …pd—te €w… gon(gur—tion • †iew €w… het—ils • €w… ixit QI
  37. 37. 5.1 Enter PMU Setup„his is the (rst pop up window th—t would —sk the user to enter the €w… setup inforEm—tionF st in™ludes port on whi™h the €w… would re™eive ™omm—nd fr—me requests from€hgF „he d—t— —nd ™on(gur—tion fr—mes would ˜e sent on this portF gommuni™—tionproto™ol @…h€G„g€A —lso need to ˜e enteredF „his det—ils would ˜e s—ve in the (le€muƒerverFtxtD —nd —t the ˜eginning of €w… rest—rt it would re—d the entries —nd st—rt€w… ƒerverF„his fun™tion—lity is distri˜uted in the following fun™tions XE void pmu_server (), intvalidation_pmu_server (GtkButton *button, gpointer udata) from the (le PmuGui.c—nd void start_server() from (le ServerFunction.cF5.2 Create Conguration Frameefter (nishing the €w… ƒetupD €w… ™on(gur—tion o˜je™ts would ˜e ™r—eted if the (le™fgPF˜in —v—il—˜leD otherwise user h—s to enter the ™on(gur—tion det—ilsF sn order to ™omEplete the ™on(gur—tion fr—me user h—s to (ll det—ils through multiple pop up windowsD—nd (n—lly store in the (le ™fgPF˜inF ™h—ngeF˜in (le —lso ™re—ted —nd write H in itF void cfg_create_function„his fun™tion—lity is distri˜uted in the following fun™tions XE(GtkWidget *widget, gpointer udata), void channel_names_for_phasor (), void chan-nel_names_for_analog (), void channel_names_for_digital (), int validation_cfg_create() from the (le CfgGuiFunctions.c —nd int create_cfg() from (le CfgFunction.cF5.3 Header Frame Generation…ser ™—n enter det—ils —˜out —lgorithmD s™—lingD (ltering —nd other inform—ntion —˜out€w…D —nd this will store in the (le he—derF˜inF re—der fr—me —lso followse the siiigQUFIIV ƒt—nd—rdF void hdr_create_function„his fun™tion—lity is distri˜uted in the following fun™tions XE(GtkWidget *widget, gpointer udata), void validation_hdr_frm (GtkWidget *widget, gpointerudata) from the (le CfgGuiFunctions.c—nd void header_frm_gen(int len) from (le CfgFunction.cF QP
  38. 38. 5.4 Update PMU Conguration…ser ™—n ™h—nge the ƒ„e„ ‡ord ˜it in d—t— fr—me ˜y using the …pd—te €w… gon(guEr—tionF st ™—n —lso modi(es in the ™on(gur—tion fr—me to —dd or remove ™h—nnelsF void Change_pmu_conguration„his fun™tion—lity is distri˜uted in the following fun™tions XE(GtkWidget *widget, gpointer udata), void new_phasor_num(GtkWidget *widget, gpointerudata), void new_analog_num (), void remove_phasor_num (GtkWidget *widget, gpointerudata), void remove_analog_num (), void change_data_rate_option(),int nal_cfg_update_call (GtkButton *but, gpointer udata) from the (leCfgGuiFunctions.cD —nd void recong_cfg_CC() from the (le CfgFunction.cF5.5 View PMU Details„his would displ—y the €w… ƒerver det—ils —nd l—test €w… gon(gur—tion det—ils to userF„his fun™tion—lity is distri˜uted in the following fun™tions XE void show_pmu_details (Gtk-Widget *widget, gpointer udata), from the (le CfgFunction.cF5.6 PMU Exitst will ™lose —ll the thre—ds —nd pro™esses of €w… ƒimul—tor —nd termin—te itF„his fun™tion—lity is distri˜uted in the following fun™tions XE void destroy (GtkWidget*widget, gpointer udata) from the (le PmuGui.cF6 Source Code Documentation of PMU Simulator„he ™ode is distri˜uted in the following (les • pmuF™ • €muquiF™ • €muquiFh • ƒerverpun™tionF™ QQ
  39. 39. • ƒerverpun™tionFh • gfgquipun™tionsF™ • gfgquipun™tionsFh • gfgpun™tionF™ • gfgpun™tionFh • fun™tionF™ • fun™tionFh6.1 pmu.cst is the (le th—t ™ont—ins the m—in@AF st intern—lly ™—lls Q fun™tions • void pmu•server @A • void ™re—te•™fg @A • void pmu•™olors@A6.2 Functions in PmuGui.c • int ™he™kip@™h—r ip‘“A • int isxum˜er@™h—r BsA • void destroy @qtk‡idget BwidgetD gpointer ud—t—A • void destroyI @qtk‡idget BwidgetD gpointer ud—t—A • void —˜out•pmu @qtkfutton BwidgetD gpointer ud—t—A • void €mu•relp @qtkfutton B˜utD gpointer ud—t—A • void v—lid—tion•result @™h—r BmsgA • void pmu•™olors@A QR
  40. 40. 6.3 Functions in ServerFunction.c • void fr—me•size@A • void gener—te•d—t—•fr—me@A • voidB udp•send•d—t—@A • voidB pmu•udp@A • voidB t™p•send•d—t—@void B newfdA • voidB new•pmu•t™p@void B nfdA • voidB pmu•t™p@A • void st—rt•server@A6.4 Functions in CfgGuiFunctions.c • void ™fg•™re—te•fun™tion @qtk‡idget BwidgetD gpointer ud—t—A • int v—lid—tion•™fg•™re—te @A • void ™h—nnel•n—mes•for•ph—sor @A • int v—lid—tion•ph—sor•n—mes@qtk‡idget BwidgetD gpointer ud—t—A • void ™h—nnel•n—mes•for•—n—log @A • int v—lid—tion•—n—log•n—mes@qtk‡idget BwidgetD gpointer ud—t—A • void ™h—nnel•n—mes•for•digit—l @A • int v—lid—tion•digit—l•n—mes@qtk‡idget BwidgetD gpointer ud—t—A • void (n—l•™fg•™re—te @A • void ™fg•™hng•options@qtk‡idget BwidgetD gpointer ud—t—A • void ™fg•ƒ„e„•™h—nge @qtk‡idget BwidgetD gpointer ud—t—A • void gh—nge•pmu•™on(gur—tion@qtk‡idget BwidgetD gpointer ud—t—A • void new•ph—sor•num@qtk‡idget BwidgetD gpointer ud—t—A • void new•—n—log•num @A QS
  41. 41. • int v—lid—tion•ph•—n•num @qtkfutton B˜utD gpointer ud—t—A • void new•™h—nnel•n—mes•for•ph—sor @A • int v—lid—tion•new•ph—sor•n—mes@qtk‡idget BwidgetD gpointer ud—t—A • void new•™h—nnel•n—mes•for•—n—log @A • int v—lid—tion•new•—n—log•n—mes@qtk‡idget BwidgetD gpointer ud—t—A • void ™h—nge•d—t—•r—te•option@A • void enter•new•d—t—•r—te@qtk‡idget BwidgetD gpointer ud—t—A • int v—lid—tion•new•d—t—•r—te @qtkfutton B˜utD gpointer ud—t—A • void remove•ph—sor•num @qtk‡idget BwidgetD gpointer ud—t—A • void remove•—n—log•num @A • int v—lid—tion•remove•ph•—n•num @qtkfutton B˜utD gpointer ud—t—A • void hdr•™re—te•fun™tion @qtk‡idget BwidgetD gpointer ud—t—A • void v—lid—tion•hdr•frm @qtk‡idget BwidgetD gpointer ud—t—A • int (n—l•™fg•upd—te•™—ll @qtkfutton B˜utD gpointer ud—t—A6.5 Functions in CfgFunction.c • void he—der•frm•gen@int lenA • void re™on(g•™fg•gg@A • void show•pmu•det—ils @qtk‡idget BwidgetD gpointer ud—t—A • int ™re—te•™fg@A6.6 Functions in function.c • void f•™opy@unsigned ™h—r m—in‘“D unsigned ™h—r tmp‘“D int indD int nA • void rPƒ@™h—r —‘“D unsigned ™h—r temp•T‘“A • void iP™ @int tD unsigned ™h—r temp‘“A • void liP™ @long int tID unsigned ™h—r temp•I‘“A QT
  42. 42. • void fP™ @)o—t fD unsigned ™h—r temp•R‘“A• int ™Pi @unsigned ™h—r temp•P‘“A• long int ™Pli @unsigned ™h—r temp•Q‘“A• uintIT•t ™ompute•g‚g @unsigned ™h—r Bmess—geD™h—r lengthA• void sig™hld•h—ndler @int sA QU

×