You are on page 1of 5

;This command procedure starts the communication in the FE.

Stations and line are


stored in a user defined process object in the FE computer (updated every time PC-
net is started). This procedure also creates Base System Stations for the SYS if
they doesnt exist (i.e. at cold start).
;***************************
;Creates Base System stations and start communication in FrontEnd
;uses the global variable %start_node_for_apl which is the application
;number of the application for the FrontEnd
;
;version info
;ver. date version changes
;1.01 12/2016 added local debug variable,
; added @my_apl alternatives
; Block added to ignore proxy stations
; (create stations before lines...*Todo*, requires code change)
;---------------------------------------------------
#local debug=TRUE
@TR=TRACE_BEGIN("PICT/TRACE_FE_START.TXT")

;Read Main&WD APL No


@apl_buv10 = apl:buv(10) ;Application numbers
@apl_buv_main = %apl_buv10(1) ;Main Application number
@apl_buv_wd = %apl_buv10(2) ;WD Application number

;Switch COM application to the hot application


@my_nod = SYS:BND
@my_apl = APL:BAN ;use this when SYS main apl no. in SYS AND in FE == 1
;@my_apl = SYS:BND ;use this when SYS main apl no. in FE is same as SYS:BND of
SYS
@apl_bsr = APL:BSR * 1000 ;VeJa 01/2011, Apl receive timeout used in HSB
application, multiply by 1000 to get milliseconds

#error ignore
@start_node_for_apl=%start_node_for_apl
@i_status = status
#error stop

#if %i_status == 0 #then @v_my_FE_APLs = vector('start_node_for_apl') ;executed


from SYS_EVENT:C *ToDo* when FE basesystem node FOUND
#else_if %i_status <> 0 #then #block
#if %my_nod==11 #then @v_my_FE_APLs = vector(5) ;apl:buv(4) ;executed from
APL_INIT_1
#if %my_nod==12 #then @v_my_FE_APLs = vector(6) ;apl:buv(4) ;executed from
APL_INIT_1
#block_end

#loop_with i=1..length(%v_my_FE_APLs)
@start_node_for_apl=%v_my_FE_APLs('i')
;*VeJa 05/2010 END
@apl_node=apl'start_node_for_apl':bnd
;;; ;VeJa 08/2010
;;; #CASE %start_node_for_apl
;;; #when 41, 51 @t_FE = "TARCOMA"
;;; #when 42, 52 @t_FE = "TARCOMB"
;;; #when 43, 53 @t_FE = "TARCOMC"
;;; #case_end
;;; ;VeJa 08/2010 end
@t_FE = "FE"
;VeJa 12/2010
@temp = %t_FE+"_STATIONS"
#loop_with i=1..length('temp':psa)
#set 'temp':psa(%i)=0
#set 'temp':pst(%i)=""
#set 'temp':pnd(%i)=0
#set 'temp':ptn(%i)=0
#loop_end

#loop_with i=1..length('temp':pli)
#set 'temp':pli(%i)=0
#loop_end
;VeJa 12/2010 end

;---------------------------------------------
; Mirroring configuration, added 090107
@use_mirroring=0 ;Use mirroring, 1 or 0
@mirroring_apl_NO = vector() ;Give application numbers where stations are
mirrored
;---------------------------------------------
@fe_apl_no=%start_node_for_apl
#if nod'apl_node':bnt=="SYS" #then #block ;we have communication to FE
@net_nodes=vector(0)
@i=1
#loop FE_STATIONS:'fe_apl_no'PLI(%i)<>0 and %i<=64
@node=trunc(FE_STATIONS:'fe_apl_no'PLI(%i)/32768)
#if %node<>%net_nodes(length(%net_nodes)) #then-
@net_nodes(length(%net_nodes)+1)=%node
@i=%i+1
#loop_end
@net_nodes=delete_element(%net_nodes,1)
#loop_with node_count=1..length(%net_nodes)
@node=%net_nodes(%node_count);
;**VeJa: #loop added to wait for the NET **
#error ignore
@no=0
#loop
@no=%no+1
#if nod'node':bnt=="NET" #then #block
@con=console_output(Timems+ " Looped NET'node' 'no' times")
#set SYS_N0'node'I:P10=0
#LOOP_EXIT
#block_end
#PAUSE 0.1
#IF %no==120 #then #block
@con=console_output(Timems+ " **** Could NOT configure NET'node', NET
not found!! *****")
#set SYS_N0'node'I:P10=10
#block_end
#loop_end(120)
#error stop
#if nod'node':bnt=="NET" #then #block ;**7
@i=1
@con=console_output(timems+" +++ FrontEnd PC-Net 'node' found, setting
stations in use... +++")
;** VeJa 05/2010 Begin2
;set nets to the hot MAIN application
#set net'node':'fe_apl_no'SSY'apl_buv_main' = ('my_nod','apl_buv_main')
#set NET'node':'fe_apl_no'SMS = 'my_apl'
;** VeJa 05/2010 END2

;set all lines in use


#loop FE_STATIONS:'fe_apl_no'PLI(%i)<>0 and %i<=64 ;**8
@line_no=FE_STATIONS:'fe_apl_no'PLI(%i)
@temp = %t_FE+"_STATIONS"
#SET 'temp':PLI(%i) = %line_no ;VeJa 12/2010
#if %node==trunc(%line_no/32768) #then #block ;** ;
@line_no=%line_no-(trunc(%line_no/32768)*32768)
#error ignore
;;; ;Added 01/2011 (for virtual serial port), simulate DCD and
CTS always 'HIGH' for the line
;; @i_cts = 100*%line_no + 5 ; pin 5 in 25 pin RS232
;; @i_dcd = 100*%line_no + 8 ; pin 8 in 25 pin RS232
;; ; modification for virtual serial port
;; #IF NET'node':'fe_apl_no'SPO'line_no' < 44 #then #set
net'node':ssg'i_cts' = 1 ;simulate CTS always on (PO = 44 - IEC104M, PO = 45 -
IEC104S)
;; #IF NET'node':'fe_apl_no'SPO'line_no' < 44 #then #set
net'node':ssg'i_dcd' = 1 ;simulate DCD always on (PO = 44 - IEC104M, PO = 45 -
IEC104S)
;Set Line MS and take line in use
#set NET'node':'fe_apl_no'SMS'line_no' = %my_apl ;*Veja
; #IF NET'node':'fe_apl_no'SLK'line_no' <> 1 #then #set
NOD'node':SIU'line_no'=1 ;*VeJa If dial-Up line do not set IU=1, temp when
configuring&testing, remove #IF at commissioning stage
@i_status=STATUS
#set NOD'node':SIU'line_no'=1
@i_status=STATUS

#error continue
@t_status=STATUS_CODE_NAME(%i_status)
#if %i_status<>0 #then @con=console_output("Error 'i_status'
('t_status') when starting line 'line_no' at Node 'node'")
#block_end
@i=%i+1
#loop_end

;** VeJa 12/2016, stations b4 lines


;set all stations in use for this node
@i=1
#loop FE_STATIONS:'fe_apl_no'PSA(%i)<>0 and %i<=2000 ;**
@st=status
#if FE_STATIONS:'fe_apl_no'PND(%i)==%node #then #block
@temp = %t_FE+"_STATIONS"
#SET 'temp':PND(%i) = %node ;VeJa 12/2010
@sta_no=FE_STATIONS:'fe_apl_no'PSA(%i)
@sta_TN=FE_STATIONS:'fe_apl_no'PTN(%i) ;added 2014/03 VeJa
; @con=console_output("Sta'sta_no' at node 'node'");*
;------Rules for address offset-----------------
;custom rules for project
@offset=0
;; #IF %node > 144 and %node < 149 #then @offset=300
;Old JohcomA stations get 300+
;; #IF %node > 144 and %node < 149 and %sta_no > 200 #then
@offset=130
;; #IF %node > 148 and %node < 151 #then @offset=500
;Old JohcomB stations get 500+
;------End--------------------------------------
@sta_no=%sta_no+%offset
@temp = %t_FE+"_STATIONS"
#SET 'temp':PSA(%i) = %sta_no ;VeJa 08/2010
#SET 'temp':PTN(%i) = %sta_TN ;added 2014/09 VeJa
@t_ST = FE_STATIONS:'fe_apl_no'PST(%i)
#SET 'temp':PST(%i) = %t_ST ;VeJa 12/2010
;;;************COMMENTED VeJa in EE project - Do not create Sta if doesn't exist,
modify PICT\APL_EXE_MIRCONF.txt instead
#if %sta_no<2000 #then @sta_no=%sta_no-1000 ;***++++-
********additional temp test 12/2016;;;;******++++++++additional TEMP line by VejA
12/2016******++++++++
#if sta'sta_no':btt=="NONE" #then #block ;station does not exist
#create STA:V = LIST(-
TT = "EXTERNAL",-
ST = FE_STATIONS:'fe_apl_no'PST(%i),-
ND = 'node',-
TN = %sta_TN)
#create STA'sta_no':B = %STA
#if DEBUG #then @con=console_output("Creating sta'sta_no' with
offset 'offset' at node 'node'")
#if %use_mirroring==1 #then #block
#loop_with h = 1..length(%mirroring_apl_NO)
@mirroring_apl_NO_tmp = %mirroring_apl_NO('h')
#set sta'Sta_no':bmr = "host"
#set sta'Sta_no':bis('h') = list(-
APL =
'mirroring_apl_NO_tmp',-
UN = 'Sta_No')
#loop_end
#block_end
#block_end
;;;************COMMENTED VeJa in EE project end
#error continue
#if STA'sta_no':bps == 0 #then #block ;Block added by VeJa
12/2016, Ignore proxy stations Begin***
#set STA'sta_no':SIU = 0
#set STA'sta_no':SMS = %my_apl ;*Veja
#set STA'sta_no':SAL = 0 ;
; #set STA'sta_no':SAS = %my_apl ;obsolete, will be the
allocating apl no
;; #if %sta_no ==1016 #then #exec APL_PROXYSTA_CREATE:C (@i=%sta_no-1000)
;;;;******++++++++additional TEMP line by VejA 12/2016******++++++++
#set STA'sta_no':SAL = 1
@st = status
#if %st<>0 #then @co = console_output("Could not allocate
station 'sta_no'!! ('st')")
#if %st==0 #then #block
#if STA'sta_no':BST == "IEC" #then #set STA'sta_no':SST =
'apl_bsr'+2000 ;Added Veja 01/2011, set STA:SST = apl:bsr +2sec for IEC stations
#set STA'sta_no':SIU = 1
#block_end
#block_end ;Block added by VeJa 12/2016, Ignore proxy stations
END***
#error continue
#block_end
@i=%i+1
#loop_end

;;lines

#block_end
#loop_end
#block_end
#else @con=console_output(Timems+ " **** FE_START:C Could NOT find FrontEnd node
'apl_node', external NET not configured! *****")
#loop_end ;*VeJa
@TR=TRACE_END

You might also like