Subversion Repositories Aluchemie.virtualisatie

Rev

Rev 204 | Blame | Compare with Previous | Last modification | View Log | Download

public PVB_MPV_File_DateTime_Read(4) as Date

sub mpv_lees_file (ByVal PVB_Nr as Integer)
 
 Dim PVB_mpv_lotnummer(50) as String
 Dim PVB_mpv_vormmachine(50) as String
 Dim PVB_mpv_code(50) as String
 Dim PVB_mpv_waarde(50) as String
 Dim PVB_mpv_plus_min(50) as String
 Dim PVB_mpv_regelgrens(50) as String
 Dim PVB_mpv_afkeurgrens(50) as String
 Dim PVB_count as Integer
 Dim PVB_RecNr as Integer
 DIM PVB_CokesNr as Integer
 DIM PVB_PekNr as Integer
 DIM PVB_File as Integer
 DIM PVB_MPV_File_DateTime(4) as Date


 Critical
 PVB_count = 0

 Do while (mf_MPV_LOG_Busy) and (PVB_count < 10)
   Sleep 500
   PVB_count = PVB_count + 1
 Loop

 if PVB_count > 0 then 
   PVB_count = 0

   Do while (PVB_count < 10)
     Sleep 500
     PVB_count = PVB_count + 1
   Loop
 end if

 if (mf_MPV_LOG_Busy = 0) and (mf_MPV_count(PVB_Nr)>1) then 'check op mf_MPV_count om trigger bij reset counter te voorkomen
   mf_MPV_LOG_Busy = PVB_Nr
   mf_MPV_Status(PVB_Nr) = ""
'   mf_MPV_Lotnr(PVB_Nr) = ""
   On Error Goto Trap1

'  Check for a new file
   mf_MPV_Status(PVB_Nr) = TIME & " Check for new MPV file"
   PVB_MPV_File_DateTime(PVB_Nr)=FileDateTime("c:/inetpub/ftproot/ftps" & PVB_Nr & ".txt")
   mf_MPV_File_DateTime(PVB_Nr)=Format(PVB_MPV_File_DateTime(PVB_Nr),"General date")

   if PVB_MPV_File_DateTime(PVB_Nr)<>PVB_MPV_File_DateTime_Read(PVB_Nr) then
'    new file  
     mf_MPV_Status(PVB_Nr) = TIME & " Openen MPV file"
     PVB_File = FreeFile
     Open "c:/inetpub/ftproot/ftps" & PVB_Nr & ".txt" for input lock read write as PVB_File
     PVB_count = 1
     Do while (NOT EOF(PVB_File)) and (PVB_count < 50)
       input PVB_File, PVB_mpv_lotnummer(PVB_count)
       input PVB_File, PVB_mpv_vormmachine(PVB_count)
       input PVB_File, PVB_mpv_code(PVB_count)
       input PVB_File, PVB_mpv_waarde(PVB_count)
       input PVB_File, PVB_mpv_plus_min(PVB_count)
       input PVB_File, PVB_mpv_regelgrens(PVB_count)
       input PVB_File, PVB_mpv_afkeurgrens(PVB_count)
       PVB_count = PVB_count + 1
     Loop
     mf_MPV_Status(PVB_Nr) = TIME & " Sluiten MPV file"
     if PVB_count > 1 then
       PVB_MPV_File_DateTime_Read(PVB_Nr)=PVB_MPV_File_DateTime(PVB_Nr)
     else
       Err = 999
       Close PVB_File
       goto Trap1
     end if
     Close PVB_File

     for PVB_CokesNr=1 to 5
       mf_MPV_LOG_Cokes(PVB_CokesNr)=""
       mf_MPV_LOG_CokesP(PVB_CokesNr)=0
     next PVB_CokesNr
     PVB_CokesNr=1

     for PVB_PekNr=1 to 2
       mf_MPV_LOG_Peksoort(PVB_PekNr)=""
       mf_MPV_LOG_PeksoortP(PVB_PekNr)=0
     next PVB_PekNr
     PVB_PekNr=1

     for PVB_RecNr=1 to PVB_count-1
       select case PVB_mpv_code(PVB_RecNr)
         case "C99999"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)=""
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90010"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Lingen"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90020"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Esso"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90030"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Marathon"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90040"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Mongstad"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90050"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Veba"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90060"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Conoco"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90300"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Great Lakes"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90310"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Copetro"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90320"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="CII"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90330"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Reynolds"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90350"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="BP ARCO"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90400"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="ALBA"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90500"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Petrobras"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90600"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="Sumitomo"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90650"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="ZCP"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "C90670"
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)="ZCGG"
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           end if
         case "P92100"
           if PVB_PekNr<=2 then
             mf_MPV_LOG_Peksoort(PVB_PekNr)="Cindu"
             mf_MPV_LOG_PeksoortP(PVB_PekNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_PekNr=PVB_PekNr+1
           end if
         case "P92200"
           if PVB_PekNr<=2 then
             mf_MPV_LOG_Peksoort(PVB_PekNr)="Tarco"
             mf_MPV_LOG_PeksoortP(PVB_PekNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_PekNr=PVB_PekNr+1
           end if
         case "P92300"
           if PVB_PekNr<=2 then
             mf_MPV_LOG_Peksoort(PVB_PekNr)="Deza"
             mf_MPV_LOG_PeksoortP(PVB_PekNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_PekNr=PVB_PekNr+1
           end if
         case "P92400"
           if PVB_PekNr<=2 then
             mf_MPV_LOG_Peksoort(PVB_PekNr)="Vft"
             mf_MPV_LOG_PeksoortP(PVB_PekNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_PekNr=PVB_PekNr+1
           end if
         case "P92500"
           if PVB_PekNr<=2 then
             mf_MPV_LOG_Peksoort(PVB_PekNr)="Tarpol"
             mf_MPV_LOG_PeksoortP(PVB_PekNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_PekNr=PVB_PekNr+1
           end if
         case "P92600"
           if PVB_PekNr<=2 then
             mf_MPV_LOG_Peksoort(PVB_PekNr)="Nalon"
             mf_MPV_LOG_PeksoortP(PVB_PekNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_PekNr=PVB_PekNr+1
           end if
         case "DOS_1"
'          pekdosering
           mf_MPV_LOG_Pek=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_2"
'          molenstof
           mf_MPV_LOG_Molenstof=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_3"
'          korrel 0.25-1
           mf_MPV_LOG_Korrel(1)=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_4"
'          korrel 1-2
           mf_MPV_LOG_Korrel(3)=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_5","DOSS_03"
'          korrel 2-4
           mf_MPV_LOG_Korrel(4)=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_6","DOSS_02"
'          korrel 4-8
           mf_MPV_LOG_Korrel(5)=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_7","DOSS_01"
'          korrel 8-16
           mf_MPV_LOG_Korrel(2)=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_8"
'          fijne resten
           mf_MPV_LOG_Fijne_Resten=PVB_mpv_waarde(PVB_RecNr)
         case "DOS_9"
'          resten.cokes
           mf_MPV_LOG_Grove_Resten=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Verd_Cokes=100-PVB_mpv_waarde(PVB_RecNr)
         case "VAR_1A","VAR_2A","VAR_3A"
           mf_MPV_LOG_Gr_Toeslag=PVB_mpv_waarde(PVB_RecNr)
         case "VAR_1B","VAR_2B","VAR_3B"
           mf_MPV_LOG_Doorzet=PVB_mpv_waarde(PVB_RecNr)
         case "MASSA_1"
           mf_MPV_LOG_Pek_T=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Pek_T_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Pek_T_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "MASSA_2"
           mf_MPV_LOG_Vw_T=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Vw_T_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Vw_T_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "MASSA_3"
           mf_MPV_LOG_Bm_T=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Bm_T_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Bm_T_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "MASSA_4"
           mf_MPV_LOG_Om_T=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Om_T_Afw=PVB_mpv_plus_min(PVB_RecNr)
           mf_MPV_LOG_Om_T_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Om_T_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "MASSA_5"
           mf_MPV_LOG_Vw_Rpm=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Vw_Rpm_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case "MASSA_7"
           mf_MPV_LOG_Bm_Rpm=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Bm_Rpm_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case "MASSA_8"
           mf_MPV_LOG_Om_Rpm=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Om_Rpm_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case "MASSA_9"
           mf_MPV_LOG_K_Kwton=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_K_Kwton_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_K_Kwton_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "MASSA10"
           mf_MPV_LOG_Blain=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Blain_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case "MASSA11"
           mf_MPV_LOG_Vulgr=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Vulgr_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case "VORM_1"
           mf_MPV_LOG_Hoogte=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Hoogte_Afw=PVB_mpv_plus_min(PVB_RecNr)
           mf_MPV_LOG_Hoogte_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Hoogte_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "VORM_2"
           mf_MPV_LOG_Gewicht=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Gewicht_Afw=PVB_mpv_plus_min(PVB_RecNr)
           mf_MPV_LOG_Gewicht_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Gewicht_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "VORM_3","VORM_3A"
           mf_MPV_LOG_Temp=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Temp_Afw=PVB_mpv_plus_min(PVB_RecNr)
           mf_MPV_LOG_Temp_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Temp_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "VORM_4"
           mf_MPV_LOG_Sg_Factor=PVB_mpv_waarde(PVB_RecNr)
         case "VORM_4A"
           mf_MPV_LOG_Sg=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Sg_Reg=PVB_mpv_regelgrens(PVB_RecNr)
           mf_MPV_LOG_Sg_Afk=PVB_mpv_afkeurgrens(PVB_RecNr)
         case "VORM_5","VORM_8"
           mf_MPV_LOG_Rpm_P_Inst=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Rpm_P_Inst_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case "VORM_6","VORM_6A"
           mf_MPV_LOG_Tijd=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Tijd_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case "VORM_7"
           mf_MPV_LOG_Balg=PVB_mpv_waarde(PVB_RecNr)
           mf_MPV_LOG_Balg_Afw=PVB_mpv_plus_min(PVB_RecNr)
         case else
           if PVB_CokesNr<=5 then
             mf_MPV_LOG_Cokes(PVB_CokesNr)=PVB_mpv_code(PVB_RecNr)
             mf_MPV_LOG_CokesP(PVB_CokesNr)=PVB_mpv_waarde(PVB_RecNr)
             PVB_CokesNr=PVB_CokesNr+1
           else
             mf_MPV_Status(PVB_Nr) = "onbekend label in MPV file (" & PVB_mpv_code(PVB_RecNr) & " )"
           end if
       end select
     next PVB_RecNr
     mf_MPV_LOG_Lotnr=PVB_mpv_lotnummer(1)
     mf_MPV_LOG_Systeem=PVB_NR
     mf_MPV_LOG_V_Machine=PVB_mpv_vormmachine(1)
     mf_MPV_Status(PVB_Nr) = TIME & " Lezen MPV file OK"
     'if (mf_MPV_Lotnr(PVB_Nr) <> mf_MPV_LOG_Lotnr) then
       mf_MPV_Lotnr(PVB_Nr)  = mf_MPV_LOG_Lotnr
       mf_MPV_Update.force 1
     'end if
   else
     mf_MPV_Status(PVB_Nr) = TIME & " Geen nieuwe MPV file"
     mf_MPV_LOG_Busy = 0
   end if
 end if  
Exit Sub

Trap1:
 mf_MPV_Status(PVB_Nr) = TIME & " ERROR tijdens lezen MPV file (" & Err & " )"
 mf_MPV_LOG_Busy = 0
  Exit Sub
end sub