lampiran - media.unpad.ac.idmedia.unpad.ac.id/thesis/240110/2012/240110120060_l_5025.pdf ·...
TRANSCRIPT
77
Lampiran 2. Kondisi Final Gudang
Tata Letak Barang Tingkat 1
Tata Letak Barang Tingkat 2
Jalur Forklift
Pintu Masuk-Keluar
Loading Area
Lantai 1
Tingkat 1 Tingkat 2
79
Lampiran 4. Module 2
Public TimerActiveEmptyMap As Boolean Dim counter, max As Integer Dim jenisBarang As String Sub TakeOutOrdered(jumlah As Integer, jenisBarangX As String) 'fungsi untuk memicu pengosongan slot dengan jumlah dan jenis barang sesuai permintaan counter = 0 max = jumlah jenisBarang = jenisBarangX 'MsgBox max TimerActiveEmptyMap = True Call TimerTakeOutOrdered 'While TimerActiveEmptyMap ' Call runAppEmptyMap 'Wend End Sub Public Sub TimerTakeOutOrdered() 'timer untuk mengatur interval waktu yang dilakukan dalam pengosongan dari 1 slot ke slot lainnya 'bukan untuk mengatur waktu langkah waktu langkah beda lagi ada module nya masing masing karena 'module ini masih manggil module lain If TimerActiveEmptyMap Then Call runAppEmptyMap Application.OnTime Now() + TimeValue("00:00:02"), "TimerTakeOutOrdered" 'Application.OnTime Now() + 1.1 / (24 * 60 * 60# * 2), "TimerTimerXXX" End If End Sub Sub runAppEmptyMap() 'fungsi yang di ulang setiap 2 detiknya. mengecek apakah proses pengambilan barang 'sudah selesai atau belum jika sudah maka akan dilakukan lagi terus hingga antrian barang yang di ambill selesai If counter > max - 1 Then TimerActiveEmptyMap = False Else ' MsgBox counter If Module5.TimerPieceTakeActive = True Or Module8.TimerTravelActive Then Else Dim target As Integer target = Module6.finderZ(jenisBarang) 'MsgBox jenisBarang If target = 0 Then MsgBox "Not Found"
80
Lampiran 4. Lanjutan
counter = max + 1
Else Dim baris, kolom, level As Integer baris = Sheet7.Cells(target, 4) kolom = Sheet7.Cells(target, 3) level = Sheet7.Cells(target, 5) 'MsgBox baris & "," & kolom & "," & level counter = counter + 1 Call Module5.SpecTake(baris, kolom, level) End If End If End If End Sub
81
Lampiran 5. Module 3
Dim currentBaris As Integer Dim currentKolom As Integer Dim startBaris As Integer Dim startKolom As Integer Dim baris As Integer Dim kolom As Integer Dim level As Integer Dim turunin, naikin, firstStep As Boolean Dim geserKanan, geserKiri As Boolean Public TimerActive As Boolean Dim firstTime As Boolean Dim jenisBarang As String Dim tujuan, segment(6) As Range Sub FIFOfill() 'fungsi pemicu untuk melakukan pemenuhan pada slot kosong di gudang Call Sheet4.deactivateControl TimerActive = True Set tujuan = Nothing Set segment(0) = Range(Cells(4, 7), Cells(30, 15)) Set segment(1) = Range(Cells(31, 11), Cells(33, 14)) Set segment(2) = Range(Cells(34, 11), Cells(38, 18)) Set segment(3) = Range(Cells(43, 1), Cells(45, 18)) Set segment(4) = Range(Cells(46, 1), Cells(66, 19)) Set segment(5) = Range(Cells(67, 1), Cells(72, 21)) Call Module9.initialize firstTime = True Call Timer ' Do While TimerActive ' Call runAppx ' Loop End Sub Sub runAppx() 'fungsi yang di ulang setiap 1 detiknya. menentukan perubahan behaviour baik dari langkah 'sudah selesai atau belum jika sudah maka akan dilakukan lagi terus hingga gudang penuh If Module8.TimerTravelActive Then Call Module8.moveTravel Else If tujuan Is Nothing Then If Not firstTime Then Dim x As Integer x = 2 If level = 1 Then
82
Lampiran 5. Lanjutan x = 4 End If Module9.stepTaken = Module9.stepTaken + x Call Module10.addData(kolom, baris, level, "Put in") End If Set tujuan = firstFloorTargetSearch level = 1 If tujuan Is Nothing Then Set tujuan = secondFloorTargetSearch If tujuan Is Nothing Then TimerActive = False MsgBox ("Full") Call Sheet4.activateControl Exit Sub End If level = 2 End If Sheet5.Cells(1280, 7).Interior.Color = tujuan.Interior.Color startBaris = 2 startKolom = 7 currentBaris = startBaris currentKolom = startKolom baris = tujuan.Cells(1, 1).Row kolom = tujuan.Cells(1, 1).Column Call Module9.initialize firstTime = False Call move Else Call move End If End If End Sub Function firstFloorTargetSearch() As Range 'Fungsi untuk mencari slot kosong di lantai 1 Set result = Nothing Dim rg As Range Dim i As Integer i = 0 Do While i < 6 For Each slot In segment(i).Cells If (slot.Interior.Color = Sheet1.Cells(3, 1).Interior.Color) Then Set result = slot Dim induk As Integer If i < 3 Then induk = CInt(Int((7 * Rnd()))) + 1
83
jenisBarang = "A" & induk
Lampiran 5. Lanjutan Else induk = CInt(Int((4 * Rnd()))) + 1 jenisBarang = "B" & induk End If Exit For End If Next If result Is Nothing Then i = i + 1 Else Exit Do End If Loop If result Is Nothing Then 'TimerActive = False Set firstFloorTargetSearch = Nothing Else Set rg = Range(result, result) Set firstFloorTargetSearch = rg End If End Function Function secondFloorTargetSearch() As Range 'Fungsi untuk mencari slot kosong di lantai 2 Set result = Nothing Dim i As Integer i = 0 Do While i < 6 For Each slot In segment(i).Cells If (slot.Interior.Color = Sheet1.Cells(2, 1).Interior.Color) And (Sheet3.Cells(slot.Row, slot.Column).Interior.Color = Sheet1.Cells(1, 1).Interior.Color) Then Set result = slot Dim induk As Integer If i < 3 Then induk = CInt(Int((7 * Rnd()))) + 1 jenisBarang = "A" & induk Else induk = CInt(Int((4 * Rnd()))) + 1 jenisBarang = "B" & induk End If Exit For
84
End If Next If result Is Nothing Then
Lampiran 5. Lanjutan i = i + 1 Else Exit Do End If Loop 'For Each slot In Range(Cells(4, 7), Cells(30, 15)).Cells ' If (slot.Interior.Color = Sheet1.Cells(2, 1).Interior.Color) And (Sheet3.Cells(slot.Row, slot.Column).Interior.Color = Sheet1.Cells(1, 1).Interior.Color) Then ' Set result = slot ' Exit For ' End If 'Next Dim rg As Range If result Is Nothing Then 'TimerActive = False Set secondFloorTargetSearch = Nothing Else Set rg = Range(result, result) Set secondFloorTargetSearch = rg End If End Function Private Sub Timer() 'timer yang berguna untuk mengatur interval antar gerakan crane If TimerActive Then Call runAppx ' Application.OnTime Now() + TimeValue("00:00:01"), "Timer" Application.OnTime Now() + 1.1 / (24 * 60 * 60# * 2), "Timer" End If End Sub Sub move() 'fungsi yang menggerakan crane dan mengatur event crane If currentBaris = startBaris And currentKolom = startKolom Then firstStep = True End If Call eventChanger If turunin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call turun End If
85
If geserKanan = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kanan
Lampiran 5. Lanjutan End If If geserKiri = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kiri End If If naikin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call naik End If 'saat sampai If currentBaris = baris And currentKolom = kolom Then 'TimerActive = False Call Module6.addData(jenisBarang, kolom, baris, level) turunin = False naikin = False geserKanan = False geserKiri = False Call Module8.travel(baris, kolom, 2, 7) 'move 'tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color If Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(3, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color ElseIf Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color End If Set tujuan = Nothing Application.Wait (Now + TimeValue("0:00:01")) End If End Sub Sub eventChanger() 'fungsi yang menentukan arah gerak crane 'currentBaris = 62 'currentKolom = 1 'kolom = 1 'baris = 61 'kondisi harus turun If (currentBaris + 1 <= baris And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color _ And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color) Or _
86
(geserKanan = False And kolom >= 12 And (Cells(currentBaris, currentKolom + 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color _ Or Cells(currentBaris, currentKolom + 1).Interior.Color = Sheet1.Cells(7, 1).Interior.Color)) Then Lampiran 5. Lanjutan currentBaris = currentBaris + 1 turunin = True Else turunin = False End If If currentKolom > 1 And turunin = False Then If (geserKiri = False And kolom < 12 And (Cells(currentBaris, currentKolom - 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color)) Then currentBaris = currentBaris + 1 turunin = True End If End If 'kondisi harus ke kanan If (currentKolom + 1 <= kolom And turunin = False And _ Cells(currentBaris, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color) Or _ (turunin = False And geserKiri = False And currentBaris + 1 <= baris And _ (Cells(currentBaris + 1, currentKolom).Interior.Color = Sheet1.Cells(7, 1).Interior.Color Or _ Cells(currentBaris + 1, currentKolom).Interior.Color = Sheet1.Cells(1, 1).Interior.Color)) Then currentKolom = currentKolom + 1 geserKanan = True Else geserKanan = False End If 'kondisi harus ke kiri If currentKolom > 1 Then If currentKolom - 1 >= kolom And turunin = False And geserKanan = False And _ Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentKolom = currentKolom - 1 geserKiri = True Else geserKiri = False End If Else geserKiri = False End If 'kondisi ketika dia harusnya turun tapi di ubah ke kanan If turunin Then
87
If kolom >= 11 And currentBaris = baris And currentKolom <> kolom And _ Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom + 1 currentBaris = currentBaris - 1
Lampiran 5. Lanjutan geserKanan = True turunin = False End If If currentKolom > 1 Then If kolom < 12 And currentBaris = baris And currentKolom <> kolom And _ Cells(currentBaris - 1, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And _ Cells(currentBaris - 1, currentKolom - 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom - 1 currentBaris = currentBaris - 1 geserKiri = True turunin = False End If Else geserKiri = False End If End If 'kondisi ketika dia harusnya turun tapi di ubah ke kiri 'kondisi harus naik If currentBaris - 1 >= baris And turunin = False And geserKanan = False And geserKiri = False Then currentBaris = currentBaris - 1 naikin = True Else naikin = False End If End Sub 'masing masing fungsi menggerakan crane sesuai namanya Sub turun() If firstStep Then firstStep = False Else Cells(currentBaris - 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub naik()
88
If firstStep Then firstStep = False Else Cells(currentBaris + 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub
Lampiran 5. Lanjutan Sub kanan() If firstStep Then firstStep = False Else Cells(currentBaris, currentKolom - 1).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub kiri() If firstStep Then firstStep = False Else Cells(currentBaris, currentKolom + 1).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub
89
Lampiran 6. Module 4
Dim currentBaris As Integer Dim currentKolom As Integer Dim startBaris As Integer Dim startKolom As Integer Dim baris As Integer Dim kolom As Integer Dim level As Integer Dim tobegivenbaris As Integer Dim tobegivenkolom As Integer Dim tobegivenlevel As Integer Dim segmentStart, segmentEnd As Integer Dim jenisBarang As String Dim turunin, naikin, firstStep As Boolean Dim geserKanan, geserKiri As Boolean Public TimerSpecFillActive, btujuan As Boolean Public tujuan, segment(6) As Range Sub FIFOfill(jenisBarangX As String) 'fungsi pemicu untuk mengisi satu slot sesuai jenis barang yang ditentukan Call Sheet4.deactivateControl TimerSpecFillActive = True Set tujuan = Nothing btujuan = False Set segment(0) = Range(Cells(4, 7), Cells(30, 15)) Set segment(1) = Range(Cells(31, 11), Cells(33, 14)) Set segment(2) = Range(Cells(34, 11), Cells(38, 18)) Set segment(3) = Range(Cells(43, 1), Cells(45, 18)) Set segment(4) = Range(Cells(46, 1), Cells(66, 19)) Set segment(5) = Range(Cells(67, 1), Cells(72, 21)) jenisBarang = jenisBarangX If UCase(Left(jenisBarang, 1)) = "A" Then segmentStart = 0 segmentEnd = 2 Else segmentStart = 3 segmentEnd = 5 End If Call Module9.initialize Call TimerSpecFill 'Do While TimerSpecFillActive ' Call runAppx 'Loop End Sub
90
Sub runAppx() 'fungsi yang di ulang ulang untuk mengatur apakah dia harus melangkah atau menetukan target selanjutnya
Lampiran 6. Lanjutan If Module8.TimerTravelActive Then 'menggerakan crane kosong Call Module8.moveTravel Else If tujuan Is Nothing Then 'menentukan target selanjutnya 'penentuan level 1 Set tujuan = firstFloorTargetSearch level = 1 If tujuan Is Nothing Then 'penentuan level 2 Set tujuan = secondFloorTargetSearch If tujuan Is Nothing Then 'jika target sudah terisi sepenuhnya TimerSpecFillActive = False MsgBox ("Full") Call Sheet4.activateControl Exit Sub End If level = 2 End If btujuan = True Sheet5.Cells(1280, 7).Interior.Color = tujuan.Interior.Color startBaris = 2 startKolom = 7 currentBaris = startBaris currentKolom = startKolom baris = tujuan.Cells(1, 1).Row kolom = tujuan.Cells(1, 1).Column tobegivenbaris = baris tobegivenkolom = kolom tobegivenlevel = level 'jika tujuan di temukan maka selanjutnya Call move Else 'menggerakan crane yang ada isinya Call move End If End If End Sub Function firstFloorTargetSearch() As Range
91
'fungsi untuk menentukan tujuan jika ada di level 1 'This range for hall Range(Cells(4, 7), Cells(30, 15)).Cells Set result = Nothing Dim rg As Range Dim i As Integer
Lampiran 6. Lanjutan i = segmentStart Do While i < segmentEnd + 1 For Each slot In segment(i).Cells If (slot.Interior.Color = Sheet1.Cells(3, 1).Interior.Color) Then Set result = slot Exit For End If Next If result Is Nothing Then i = i + 1 Else Exit Do End If Loop If result Is Nothing Then 'TimerSpecFillActive = False Set firstFloorTargetSearch = Nothing Else Set rg = Range(result, result) Set firstFloorTargetSearch = rg End If End Function Function secondFloorTargetSearch() As Range 'fungsi untuk menentukan tujuan jika ada di level 2 'This range for hall Range(Cells(4, 7), Cells(30, 15)).Cells Set result = Nothing Dim i As Integer i = segmentStart Do While i < segmentEnd + 1 For Each slot In segment(i).Cells If (slot.Interior.Color = Sheet1.Cells(2, 1).Interior.Color) And (Sheet3.Cells(slot.Row, slot.Column).Interior.Color = Sheet1.Cells(1, 1).Interior.Color) Then Set result = slot Exit For End If
92
Next If result Is Nothing Then i = i + 1 Else Exit Do End If Loop Dim rg As Range If result Is Nothing Then
Lampiran 6. Lanjutan 'TimerSpecFillActive = False Set secondFloorTargetSearch = Nothing Else Set rg = Range(result, result) Set secondFloorTargetSearch = rg End If End Function Private Sub TimerSpecFill() 'timer yang menentukan lama nya interval waktu pengerjaan dari satu pekerjaan ke pekerjaan lainnya If TimerSpecFillActive Or Module8.TimerTravelActive Then Call runAppx Application.OnTime Now() + TimeValue("00:00:01"), "TimerSpecFill" 'Application.OnTime Now() + 1.1 / (24 * 60 * 60# * 2), "TimerSpecFill" Else Dim x As Integer x = 2 If level = 1 Then x = 4 End If Module9.stepTaken = Module9.stepTaken + x Call Module9.countCostAndTime Call Module6.addData(jenisBarang, tobegivenkolom, tobegivenbaris, tobegivenlevel) Call Module10.addData(tobegivenkolom, tobegivenbaris, tobegivenlevel, "Put in") btujuan = False End If End Sub Sub move() 'fungsi yang menggerakan crane ketika terisi barang If currentBaris = startBaris And currentKolom = startKolom Then firstStep = True
93
End If Call eventChanger If turunin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call turun End If If geserKanan = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kanan End If If geserKiri = True Then
Lampiran 6. Lanjutan Module9.stepTaken = Module9.stepTaken + 1 Call kiri End If If naikin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call naik End If 'saat sampai If currentBaris = baris And currentKolom = kolom Then TimerSpecFillActive = False turunin = False naikin = False geserKanan = False geserKiri = False Call Sheet4.activateControl 'move 'tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color If Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(3, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color ElseIf Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color End If 'Set tujuan = Nothing Set tujuan = Nothing Call Module8.travel(currentBaris, currentKolom, 2, 7) Application.Wait (Now + TimeValue("0:00:01")) End If End Sub Sub eventChanger()
94
'fungsi yang menetukan arah gerak crane pada fungsi ini semua logika pergerakan berlaku 'currentBaris = 6 'currentKolom = 7 'kolom = 11 'baris = 8 'kondisi harus turun If (currentBaris + 1 <= baris And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color _ And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color) Or _ (geserKanan = False And kolom >= 12 And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And (Cells(currentBaris, currentKolom + 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Or _ Cells(currentBaris, currentKolom + 1).Interior.Color = Sheet1.Cells(7, 1).Interior.Color)) Then
Lampiran 6. Lanjutan currentBaris = currentBaris + 1 turunin = True Else turunin = False End If If currentKolom > 1 And turunin = False Then If (geserKiri = False And kolom < 12 And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And (Cells(currentBaris, currentKolom - 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color)) Then currentBaris = currentBaris + 1 turunin = True End If End If 'kondisi harus ke kanan If (currentKolom + 1 <= kolom And turunin = False And _ Cells(currentBaris, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color) Or _ (turunin = False And geserKiri = False And currentBaris + 1 <= baris And _ (Cells(currentBaris + 1, currentKolom).Interior.Color = Sheet1.Cells(7, 1).Interior.Color Or _ Cells(currentBaris + 1, currentKolom).Interior.Color = Sheet1.Cells(1, 1).Interior.Color)) Then currentKolom = currentKolom + 1 geserKanan = True Else geserKanan = False End If 'kondisi harus ke kiri
95
If currentKolom > 1 Then If currentKolom - 1 >= kolom And turunin = False And geserKanan = False And _ Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentKolom = currentKolom - 1 geserKiri = True Else geserKiri = False End If Else geserKiri = False End If 'kondisi ketika dia harusnya turun tapi di ubah ke kanan If turunin Then If kolom >= 11 And (currentBaris = baris) And currentKolom <> kolom And _ Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And _ Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then
Lampiran 6. Lanjutan currentKolom = currentKolom + 1 currentBaris = currentBaris - 1 geserKanan = True turunin = False End If If kolom >= 11 And (currentBaris <= baris) And currentKolom <> kolom And _ Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And _ Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color And _ (Cells(currentBaris, currentKolom + 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Or Cells(currentBaris, currentKolom + 1).Interior.Color = Sheet1.Cells(7, 1).Interior.Color) And _ (Cells(currentBaris + 1, currentKolom).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Or Cells(currentBaris + 1, currentKolom).Interior.Color = Sheet1.Cells(7, 1).Interior.Color) Then currentKolom = currentKolom + 1 currentBaris = currentBaris - 1 geserKanan = True turunin = False End If If currentKolom > 1 Then If kolom < 11 And currentBaris = baris And currentKolom <> kolom And _
96
Cells(currentBaris - 1, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And _ Cells(currentBaris - 1, currentKolom - 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom - 1 currentBaris = currentBaris - 1 geserKiri = True turunin = False End If Else geserKiri = False End If If kolom >= 11 And (currentBaris = baris) And currentKolom <> kolom And _ Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And _ Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom + 1 currentBaris = currentBaris - 1 geserKanan = True turunin = False End If
Lampiran 6. Lanjutan End If 'kondisi ketika dia harusnya turun tapi di ubah ke kiri 'kondisi harus naik If currentBaris - 1 >= baris And turunin = False And geserKanan = False And geserKiri = False Then currentBaris = currentBaris - 1 naikin = True Else naikin = False End If End Sub 'fungsi di bawah adalah sub fungsi yang menggerakan dan di panggil pada fungsi move. Sub turun() If firstStep Then firstStep = False Else Cells(currentBaris - 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub
97
Sub naik() If firstStep Then firstStep = False Else Cells(currentBaris + 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub kanan() If firstStep Then firstStep = False Else Cells(currentBaris, currentKolom - 1).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub kiri() If firstStep Then firstStep = False Else Cells(currentBaris, currentKolom + 1).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color
Lampiran 6. Lanjutan Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub
98
Lampiran 7. Module 5
Dim currentBaris As Integer Dim currentKolom As Integer Dim startBaris As Integer Dim startKolom As Integer Dim baris As Integer Dim kolom As Integer Dim turunin, naikin As Boolean Dim geserKanan, geserKiri As Boolean Dim toBeTakenBaris, toBeTakenKolom, toBeTakenLevel, firstStepTemp As Integer Public TimerPieceTakeActive, TakeToTemp, BackFromTemp, firstStep As Boolean Dim tujuan, segment(6), temp As Range Sub test() Call SpecTake(32, 14, 1) 'CInt(targetKolom)) End Sub Sub SpecTake(ByVal targetBaris As Integer, ByVal targetKolom As Integer, ByVal level As Integer) 'fungsi spec take fungsi ini berfungsi untuk memicu pengambilan barang pada slot yang sudah ditentukan fungsi ini di gunakan oleh module lain contohnya ada pada module2 If Cells(targetBaris, targetKolom).Interior.Color = Sheet1.Cells(3, 1).Interior.Color Then MsgBox ("Sudah Kosong") Else Call Sheet4.deactivateControl TimerPieceTakeActive = True Set tujuan = Nothing Set segment(0) = Range(Cells(4, 7), Cells(30, 15)) Set segment(1) = Range(Cells(31, 11), Cells(33, 14)) Set segment(2) = Range(Cells(34, 11), Cells(38, 18)) Set segment(3) = Range(Cells(43, 1), Cells(45, 18)) Set segment(4) = Range(Cells(46, 1), Cells(66, 19)) Set segment(5) = Range(Cells(67, 1), Cells(72, 21)) Set tujuan = Range(Cells(targetBaris, targetKolom), Cells(targetBaris, targetKolom)) Sheet5.Cells(1280, 7).Interior.Color = tujuan.Cells(1, 1).Interior.Color startBaris = tujuan.Cells(1, 1).Row startKolom = tujuan.Cells(1, 1).Column currentBaris = startBaris currentKolom = startKolom baris = 2 kolom = 7 TakeToTemp = False Call Module9.initialize
99
If Cells(targetBaris, targetKolom).Interior.Color = Sheet1.Cells(1, 1).Interior.Color And level < 2 Then TakeToTemp = True If targetKolom < 12 Then Lampiran 7. Lanjutan
Set temp = Range(Cells(targetBaris, 12), Cells(targetBaris, 12)) Else Set temp = Range(Cells(targetBaris, 11), Cells(targetBaris, 11)) End If If targetBaris = 32 Then Set temp = Range(Cells(targetBaris + 2, targetKolom), Cells(targetBaris + 2, targetKolom)) End If Sheet5.Cells(1281, 7).Interior.Color = temp.Cells(1, 1).Interior.Color baris = temp.Cells(1, 1).Row kolom = temp.Cells(1, 1).Column End If toBeTakenBaris = targetBaris toBeTakenKolom = targetKolom toBeTakenLevel = level firstStep = True firstStepTemp = -2 Call Module8.travel(2, 7, startBaris, startKolom) Call TimerPieceTake 'Do While TimerPieceTakeActive Or Module8.TimerTravelActive ' Call runAppx ' If Not (TimerPieceTakeActive Or Module8.TimerTravelActive) Then ' Call Module10.addData(CInt(toBeTakenKolom), CInt(toBeTakenBaris), CInt(toBeTakenLevel), "Put out") ' Call Module6.delete(toBeTakenKolom, toBeTakenBaris, toBeTakenLevel) ' End If 'Loop End If End Sub Sub runAppx() 'fungsi ini menentukan pekerjaaan yang akan dilakukan If Module8.TimerTravelActive Then 'menggerakan crane kosong Call Module8.moveTravel ElseIf TakeToTemp Then 'menggerakan crane menuju tempat penyimpanan sementara Call moveToTemp ElseIf BackFromTemp Then 'menggerakan crane dari tempat penyimpanan sementara menuju posisi awal
100
Call moveBackFromTemp Else 'menggerakan crane yang berisi menuju tempat keluar barang Call move End If End Sub Private Sub TimerPieceTake()
Lampiran 7. Lanjutan 'timer yang mengatur waktu interval pengerjaan dari satu pekerjaan ke pekerjaan lain If TimerPieceTakeActive Or Module8.TimerTravelActive Then Call runAppx ' Application.OnTime Now() + TimeValue("00:00:01"), "TimerPieceTake" Application.OnTime Now() + 1.1 / (24 * 60 * 60# * 2), "TimerPieceTake" Else Dim x As Integer x = 2 If toBeTakenLevel = 1 Then x = 4 End If Module9.stepTaken = Module9.stepTaken + x Module10.nomorSeries = Sheet7.Cells(CInt(Module6.finder(CInt(toBeTakenKolom), CInt(toBeTakenBaris), CInt(toBeTakenLevel))), 6) Call Module9.countCostAndTime Call Module10.addData(CInt(toBeTakenKolom), CInt(toBeTakenBaris), CInt(toBeTakenLevel), "Put out") Call Module6.delete(toBeTakenKolom, toBeTakenBaris, toBeTakenLevel) End If End Sub Sub move() 'fungsi yang melakukan pergerakan barang dari tempat asal ke tempat keluarnya barang If currentBaris = startBaris And currentKolom = startKolom Then If Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(3, 1).Interior.Color ElseIf Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color End If firstStep = True End If Call eventChanger If turunin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call turun
101
End If If geserKanan = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kanan End If If geserKiri = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kiri End If If naikin = True Then
Lampiran 7. Lanjutan Module9.stepTaken = Module9.stepTaken + 1 Call naik End If If currentBaris = baris And currentKolom = kolom Then If temp Is Nothing Then TimerPieceTakeActive = False turunin = False naikin = False geserKanan = False geserKiri = False Set tujuan = Nothing 'MsgBox (toBeTakenBaris) 'Call Module9.countCostAndTime Cells(baris, kolom).Interior.Color = Sheet1.Cells(5, 1).Interior.Color Call Sheet4.activateControl 'Call Module9.countCostAndTime Else Cells(baris, kolom).Interior.Color = Sheet1.Cells(5, 1).Interior.Color TakeToTemp = False turunin = False naikin = False geserKanan = False geserKiri = False Sheet5.Cells(1281, 7).Interior.Color = temp.Cells(1, 1).Interior.Color startBaris = temp.Cells(1, 1).Row startKolom = temp.Cells(1, 1).Column currentBaris = startBaris currentKolom = startKolom baris = tujuan.Cells(1, 1).Row kolom = tujuan.Cells(1, 1).Column BackFromTemp = True Call Module8.travel(2, 7, startBaris, startKolom) End If
102
End If If (currentBaris - startBaris + currentKolom - startKolom) <> 0 And Not tujuan Is Nothing Then If Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(3, 1).Interior.Color ElseIf Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color End If End If End Sub Sub eventChanger()
Lampiran 7. Lanjutan 'fungsi ini menentukan arah gerak barang 'currentBaris = 6 'currentKolom = 8 'kolom = 7 'baris = 2 'kondisi harus naik If currentBaris < 4 Then If Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom - 1 geserKiri = True Else geserKiri = False End If If geserKiri = False And currentBaris - 1 <= baris Then currentBaris = currentBaris - 1 naikin = True Else naikin = False End If Else If (currentBaris + 1 >= baris And _ Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color And _ Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color) Then currentBaris = currentBaris - 1 naikin = True Else naikin = False End If
103
'kondisi harus ke kanan If currentKolom < 12 And naikin = False And Cells(currentBaris, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris, currentKolom + 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom + 1 geserKanan = True Else geserKanan = False End If 'kondisi harus ke kiri If currentKolom > 1 Then If startKolom >= 11 And naikin = False And geserKanan = False And Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom - 1
Lampiran 7. Lanjutan geserKiri = True Else geserKiri = False End If Else geserKiri = False End If 'kondisi ketika dia harusnya naik tapi di ubah ke kanan If currentKolom < 11 And naikin = True And Cells(currentBaris, currentKolom + 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color _ And (Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(2, 1).Interior.Color And _ Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(3, 1).Interior.Color) Then 'And (Cells(currentBaris - 2, currentKolom).Interior.Color <> Sheet1.Cells(2, 1).Interior.Color And Cells(currentBaris - 2, currentKolom).Interior.Color <> Sheet1.Cells(2, 1).Interior.Color) currentKolom = currentKolom + 1 currentBaris = currentBaris + 1 geserKanan = True naikin = False End If 'kondisi ketika dia harusnya naik tapi di ubah ke kiri If currentKolom > 1 Then If currentKolom > 12 And naikin = True And Cells(currentBaris, currentKolom - 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Then currentKolom = currentKolom - 1 currentBaris = currentBaris + 1
104
geserKiri = True naikin = False End If End If 'kondisi harus naik If naikin = False And geserKanan = False And geserKiri = False Then currentBaris = currentBaris + 1 turunin = True Else turunin = False End If End If End Sub Sub eventChangerToTemp() 'fungsi ini menentukan arah gerak barang menuju tempat penyimpanan sementara ' currentBaris = 38 ' currentKolom = 14 ' kolom = 11
Lampiran 7. Lanjutan ' baris = 38 If firstStep And firstStepTemp > -2 Then If baris = 32 Then currentBaris = currentBaris - 1 naikin = True ElseIf firstStepTemp = 1 Then currentBaris = currentBaris - 1 naikin = True ElseIf firstStepTemp = -1 Then currentBaris = currentBaris + 1 turunin = True Else If currentKolom + 1 <= kolom And Cells(currentBaris, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentKolom = currentKolom + 1 geserKanan = True geserKiri = False naikin = False turunin = False Else geserKanan = False End If If currentKolom - 1 >= kolom And Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentKolom = currentKolom - 1
105
geserKanan = False geserKiri = True naikin = False turunin = False Else geserKiri = False End If End If Else Sheet5.Cells(1, 1) = currentBaris Sheet5.Cells(1, 2) = currentKolom Sheet5.Cells(1, 3) = baris Sheet5.Cells(1, 4) = kolom 'kondisi harus turun If currentKolom + 1 <= kolom And Cells(currentBaris, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris, currentKolom + 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom + 1 geserKanan = True geserKiri = False naikin = False
Lampiran 7. Lanjutan turunin = False Else geserKanan = False End If If currentKolom > 1 Then If currentKolom - 1 >= kolom And Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris, currentKolom - 1).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentKolom = currentKolom - 1 geserKanan = False geserKiri = True naikin = False turunin = False Else geserKiri = False End If Else geserKiri = False End If If geserKanan = False And geserKiri = False Then If Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris + 1, currentKolom).Interior.Color <>
106
Sheet1.Cells(7, 1).Interior.Color And Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then If currentKolom = kolom Then If currentBaris - 1 >= baris Then currentBaris = currentBaris - 1 naikin = True ElseIf currentBaris + 1 <= baris Then currentBaris = currentBaris + 1 turunin = True End If End If If currentKolom <> kolom And currentKolom > 1 Then If Cells(currentBaris + 1, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Or Cells(currentBaris + 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentBaris = currentBaris + 1 turunin = True ElseIf Cells(currentBaris - 1, currentKolom - 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Or Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentBaris = currentBaris - 1 naikin = True End If ElseIf currentKolom <> kolom Then
Lampiran 7. Lanjutan If Cells(currentBaris + 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentBaris = currentBaris + 1 turunin = True ElseIf Cells(currentBaris - 1, currentKolom + 1).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentBaris = currentBaris - 1 naikin = True End If End If ElseIf currentKolom = kolom Then If currentBaris - 1 >= baris Then currentBaris = currentBaris - 1 naikin = True ElseIf currentBaris + 1 <= baris Then currentBaris = currentBaris + 1 turunin = True End If
107
ElseIf Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentBaris = currentBaris + 1 turunin = True ElseIf Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(1, 1).Interior.Color Then currentBaris = currentBaris - 1 naikin = True End If End If 'MsgBox ("" & turunin) End If End Sub '4fungsi dibawah adalah sub funsgi yang di panggil pada fungsi fungsi move Sub turun() If Not firstStep Then Cells(currentBaris - 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color Else firstStep = False End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub naik() If Not firstStep Then Cells(currentBaris + 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color
Lampiran 7. Lanjutan Else firstStep = False End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub kanan() If Not firstStep Then Cells(currentBaris, currentKolom - 1).Interior.Color = Cells(1780, 10).Interior.Color Else firstStep = False End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub kiri()
108
If Not firstStep Then Cells(currentBaris, currentKolom + 1).Interior.Color = Cells(1780, 10).Interior.Color Else firstStep = False End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(6, 1).Interior.Color End Sub Sub moveToTemp() 'fungsi yang menggerakan barang menuju tempat temporal If currentBaris = tujuan.Cells(1, 1).Row And currentKolom = tujuan.Cells(1, 1).Column Then If Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(3, 1).Interior.Color ElseIf Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color End If firstStep = True firstStepTemp = -2 End If Call eventChangerToTemp 'MsgBox ("" & turunin) If firstStep Then If turunin Then firstStepTemp = -1 ElseIf naikin Then firstStepTemp = 1 Else firstStepTemp = 0 End If
Lampiran 7. Lanjutan End If If turunin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call turun End If If geserKanan = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kanan End If If geserKiri = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kiri
109
End If If naikin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call naik End If If currentBaris = temp.Cells(1, 1).Row And currentKolom = temp.Cells(1, 1).Column Then TakeToTemp = False turunin = False naikin = False geserKanan = False geserKiri = False startBaris = tujuan.Cells(1, 1).Row startKolom = tujuan.Cells(1, 1).Column currentBaris = startBaris currentKolom = startKolom baris = 2 kolom = 7 Sheet5.Cells(1280, 7).Interior.Color = tujuan.Cells(1, 1).Interior.Color Call Module8.travel(temp.Cells(1, 1).Row, temp.Cells(1, 1).Column, startBaris, startKolom) If Sheet5.Cells(1281, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then temp.Cells(1, 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color ElseIf Sheet5.Cells(1281, 7).Interior.Color = Sheet1.Cells(3, 1).Interior.Color Then temp.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color End If 'Set tujuan = Nothing ' Cells(baris, kolom).Interior.Color = Sheet1.Cells(5, 1).Interior.Color 'Call Sheet4.activateControl End If End Sub
Lampiran 7. Lanjutan Sub moveBackFromTemp() 'fungsi yang menggerakan barang menuju tempat awal dari tempat barang. If currentBaris = temp.Cells(1, 1).Row And currentKolom = temp.Cells(1, 1).Column Then If Sheet5.Cells(1281, 7).Interior.Color = Sheet1.Cells(1, 1).Interior.Color Then temp.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color ElseIf Sheet5.Cells(1281, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then temp.Cells(1, 1).Interior.Color = Sheet1.Cells(3, 1).Interior.Color End If firstStep = True
110
Sheet5.Cells(1280, 7).Interior.Color = tujuan.Cells(1, 1).Interior.Color End If Call eventChangerToTemp 'MsgBox ("" & turunin) If turunin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call turun End If If geserKanan = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kanan End If If geserKiri = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kiri End If If naikin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call naik End If If currentBaris = tujuan.Cells(1, 1).Row And currentKolom = tujuan.Cells(1, 1).Column Then BackFromTemp = False TimerPieceTakeActive = False turunin = False naikin = False geserKanan = False geserKiri = False 'Call Module9.countCostAndTime ' Cells(baris, kolom).Interior.Color = Sheet1.Cells(5, 1).Interior.Color Call Sheet4.activateControl If Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(3, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(2, 1).Interior.Color
Lampiran 7. Lanjutan ElseIf Sheet5.Cells(1280, 7).Interior.Color = Sheet1.Cells(2, 1).Interior.Color Then tujuan.Cells(1, 1).Interior.Color = Sheet1.Cells(1, 1).Interior.Color End If Set temp = Nothing Set tujuan = Nothing Call Module8.travel(currentBaris, currentKolom, 2, 7) 'Set tujuan = Nothing
111
' Cells(baris, kolom).Interior.Color = Sheet1.Cells(5, 1).Interior.Color 'Call Sheet4.activateControl End If End Sub
112
Lampiran 8. Module 6
Sub addData(jenisBarang As String, kolom As Integer, baris As Integer, level As Integer) 'fungsi ini menambah data barang pada daatabase yang menjadi patokan dan represtasi data dari barang yang disimpan di gudang 'kolom As Integer, baris As Integer, jenis As String Dim emptyRow As Integer emptyRow = WorksheetFunction.CountA(Sheet7.Range("A:A")) + 1 Sheet7.Cells(emptyRow, 1).value = Now() Sheet7.Cells(emptyRow, 2).value = jenisBarang Sheet7.Cells(emptyRow, 3).value = kolom Sheet7.Cells(emptyRow, 4).value = baris Sheet7.Cells(emptyRow, 5).value = level Sheet7.Cells(emptyRow, 6).value = Module10.nomorSeries End Sub Sub testAdd() Call addData("A", 8, 9, 1) End Sub Sub testFinder() Dim target As Integer target = finderZ("A1") MsgBox (target) End Sub Sub testDelete() Call delete(7, 4, 1) End Sub Sub delete(ByVal kolom As Integer, ByVal baris As Integer, ByVal level As Integer) 'fungsi ini menghapus data pada database ketika barang dikeluarkan dari gudang Dim targetRow As Integer targetRow = finder(kolom, baris, level) If targetRow <> 0 Then 'MsgBox (targetRow) Sheet7.Range(Sheet7.Cells(CInt(targetRow), 1), Sheet7.Cells(CInt(targetRow), 5)).delete Shift:=xlUp If level < 2 Then targetRow = finder(kolom, baris, level + 1) If targetRow <> 0 Then Sheet7.Cells(targetRow, 5).value = 1 End If End If Else MsgBox ("Nothing to be deleted") End If End Sub Function finder(kolom As Integer, baris As Integer, level As Integer) As Integer
113
'fungsi yang digunakan untuk menemukan barang sesuai level baris dan kolom Dim emptyRow As Integer emptyRow = WorksheetFunction.CountA(Sheet7.Range("A:A")) + 1
Lampiran 8. Lanjutan Dim i As Integer For i = 1 To emptyRow - 1 If Sheet7.Cells(i, 3).value = kolom And Sheet7.Cells(i, 4).value = baris And Sheet7.Cells(i, 5).value = level Then Exit For End If Next If i = emptyRow Then finder = 0 Else finder = i End If End Function Function finderX(jenisBarang As String) As Integer Dim emptyRow As Integer emptyRow = WorksheetFunction.CountA(Sheet7.Range("A:A")) + 1 Dim i As Integer For i = 1 To emptyRow - 1 If UCase(Left(CStr(Sheet7.Cells(i, 2).value), 1)) = jenisBarang Then Exit For End If Next If i = emptyRow Then finderX = 0 Else finderX = i End If End Function Function finderZ(jenisBarang As String) As Integer 'fungsi yang digunakan untuk menemukan barang sesuai Jenis Barang Dim emptyRow As Integer emptyRow = WorksheetFunction.CountA(Sheet7.Range("A:A")) + 1 Dim i As Integer For i = 1 To emptyRow - 1 If Sheet7.Cells(i, 2).value = jenisBarang Then Exit For End If Next
114
If i = emptyRow Then finderZ = 0 Else finderZ = i End If End Function
Lampiran 9. Module 7
Dim segment(6) As Range Dim TimerActiveEmptyMap As Boolean Dim counter, max As Integer Dim ActionSet() As Integer Sub RandomAction(jumlah As Integer) 'trigger dari fungsi randomize di sheet emptymap counter = 0 max = jumlah 'MsgBox max Set segment(0) = Range(Cells(4, 7), Cells(30, 15)) Set segment(1) = Range(Cells(31, 11), Cells(33, 14)) Set segment(2) = Range(Cells(34, 11), Cells(38, 18)) Set segment(3) = Range(Cells(43, 1), Cells(45, 18)) Set segment(4) = Range(Cells(46, 1), Cells(66, 19)) Set segment(5) = Range(Cells(67, 1), Cells(72, 21)) TimerActiveEmptyMap = True Call TimerRandomAction 'While TimerActiveEmptyMap ' Call runAppEmptyMap 'Wend End Sub Public Sub TimerRandomAction() 'timer yang mengatur interval waktu antar randomize If TimerActiveEmptyMap Then Call runAppEmptyMap Application.OnTime Now() + TimeValue("00:00:02"), "TimerRandomAction" 'Application.OnTime Now() + 1.1 / (24 * 60 * 60# * 2), "TimerTimerXXX" End If End Sub Sub runAppEmptyMap() If counter > max - 1 Then TimerActiveEmptyMap = False Else ' MsgBox counter If Module5.TimerPieceTakeActive = True Or Module2.TimerActiveEmptyMap = True Or Module4.TimerSpecFillActive = True Or Module8.TimerTravelActive Then
115
Else 'seksi bagian yang ngerandom ' | ' V Dim value As Integer value = CInt(Int((2 * Rnd()))) + 2 Dim jenisBarang As String If value < 2 Then 'Dim baris, barisAtas, jumlahBaris, kolom, kolomKiri, jumlahKolom As Integer
Lampiran 9. Lanjutan 'barisAtas = segment(value).Cells(1, 1).Row 'jumlahBaris = segment(value).Rows.Count 'kolomKiri = segment(value).Cells(1, 1).Column 'jumlahKolom = segment(value).Columns.Count ' MsgBox barisAtas & "," & jumlahBaris 'baris = CInt(Int(((jumlahBaris - 1) * Rnd()) + barisAtas)) 'kolom = CInt(Int(((jumlahKolom - 1) * Rnd()) + kolomKiri)) 'MsgBox (value & " baris :" & baris & ", kolom:" & kolom) 'Call Module5.SpecTake(baris, kolom, 1) 'ini adalah code untuk mengeluarkan secara random If value = 0 Then jenisBarang = "A" Else jenisBarang = "B" End If Call Module2.TakeOutOrdered(1, jenisBarang) Else Dim induk As Integer 'induk = 0;ini adalaah code yang mengatur pengambilllan brang secara random If value = 2 Then induk = CInt(Int((7 * Rnd()))) + 1 jenisBarang = "A" & induk Else induk = CInt(Int((4 * Rnd()))) + 1 jenisBarang = "B" & induk End If MsgBox induk jenisBarang = jenisBarang 'MsgBox (value & " Jenis Barang :" & jenisBarang) Call Module4.FIFOfill(jenisBarang) End If counter = counter + 1
117
Lampiran 10. Module 8
Dim currentBaris As Integer Dim currentKolom As Integer Dim startBaris As Integer Dim startKolom As Integer Dim baris As Integer Dim kolom As Integer Dim turunin, naikin, firstStep As Boolean Dim geserKanan, geserKiri As Boolean Public TimerTravelActive As Boolean Sub test() 'test Call travel(43, 15, 2, 7) While TimerTravelActive Call moveTravel Wend End Sub Sub travel(ByVal barisAsal As Integer, ByVal kolomAsal As Integer, ByVal barisTujuan As Integer, ByVal kolomTujuan As Integer) 'ini adalah code untuk mentrigger pergerakan crane kosong startBaris = barisAsal startKolom = kolomAsal baris = barisTujuan kolom = kolomTujuan currentBaris = startBaris currentKolom = startKolom TimerTravelActive = True End Sub Sub moveTravel() 'fungsi tempat gerakan terjadi Call Sheet4.deactivateControl If currentBaris = startBaris And currentKolom = startKolom Then 'ketika mulai Sheet5.Cells(1280, 10).Interior.Color = Cells(baris, kolom).Interior.Color firstStep = True End If Call eventChangerTravel If turunin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call turun End If If geserKanan = True Then Module9.stepTaken = Module9.stepTaken + 1 Call kanan
118
End If If geserKiri = True Then Module9.stepTaken = Module9.stepTaken + 1
Lampiran 10. Lanjutan Call kiri End If If naikin = True Then Module9.stepTaken = Module9.stepTaken + 1 Call naik End If If currentBaris = baris And currentKolom = kolom Then 'ketika beres If Module5.TimerPieceTakeActive Or Module4.TimerSpecFillActive Or Module3.TimerActive Then Else Call Sheet4.activateControl End If TimerTravelActive = False Cells(currentBaris, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color End If End Sub Sub eventChangerTravel() 'menentukan arah pergerakan crane kosong If currentBaris <> baris Then If (currentBaris > baris) And Cells(currentBaris - 1, currentKolom).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentBaris = currentBaris - 1 naikin = True Else naikin = False End If 'kondisi harus naik If (currentBaris < baris) And Cells(currentBaris + 1, currentKolom).Interior.Color <> Sheet1.Cells(7, 1).Interior.Color Then currentBaris = currentBaris + 1 turunin = True Else turunin = False End If 'kondisi harus ke kanan If currentKolom < 11 And naikin = False And turunin = False Then currentKolom = currentKolom + 1 geserKanan = True Else
119
geserKanan = False End If 'kondisi harus ke kiri If currentKolom > 11 Then If currentKolom >= 11 And naikin = False And turunin = False Then currentKolom = currentKolom - 1
Lampiran 10. Lanjutan geserKiri = True Else geserKiri = False End If Else geserKiri = False End If Else If currentKolom - 1 >= kolom Then currentKolom = currentKolom - 1 geserKiri = True naikin = False turunin = False Else geserKiri = False End If If currentKolom + 1 <= kolom Then currentKolom = currentKolom + 1 geserKanan = True naikin = False turunin = False Else geserKanan = False End If End If End Sub '4 fungsi dibawah adalah sub fungsi dari move() Sub turun() If firstStep Then firstStep = False Else Cells(currentBaris - 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(8, 1).Interior.Color
120
End Sub Sub naik() If firstStep Then firstStep = False Else Cells(currentBaris + 1, currentKolom).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(8, 1).Interior.Color
Lampiran 10. Lanjutan End Sub Sub kanan() If firstStep Then firstStep = False Else Cells(currentBaris, currentKolom - 1).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(8, 1).Interior.Color End Sub Sub kiri() If firstStep Then firstStep = False Else Cells(currentBaris, currentKolom + 1).Interior.Color = Cells(1780, 10).Interior.Color End If Cells(1780, 10).Interior.Color = Cells(currentBaris, currentKolom).Interior.Color Cells(currentBaris, currentKolom).Interior.Color = Sheet1.Cells(8, 1).Interior.Color End Sub
121
Lampiran 11. Module 9
Public stepTaken As Double Sub initialize() 'dipanggil setiap kali suatu pekerjaan akan dilakukan untk mereset langkah kembali ke 0 stepTaken = 0 End Sub Sub countCostAndTime() 'menampilkan data jumlah langkah dan harga yg perlu dibayar Dim waktu, biaya As Double waktu = stepTaken biaya = stepTaken * CLng(1) Dim caption As String caption = "Faktor Pengali Biaya Sebesar Rp " & biaya & vbNewLine & " dan Faktor Pengali Waktu Sebesar " & waktu & " detik untuk mengambil barang" 'MsgBox caption End Sub
122
Lampiran 12. Module 10
Public nomorSeries, jumlahProses As Integer Sub addData(kolom As Integer, baris As Integer, level As Integer, ByVal keterangan As String) 'kolom As Integer, baris As Integer, jenis As String 'ini fungsi untuk menambahkan data pada log Dim emptyRow As Integer emptyRow = WorksheetFunction.CountA(Sheet8.Range("A:A")) + 1 Dim jenisBarang As String Dim i As Integer i = Module6.finder(kolom, baris, level) jenisBarang = CStr(Sheet7.Cells(i, 2).value) Sheet8.Cells(emptyRow, 1).value = Now() Sheet8.Cells(emptyRow, 2).value = jenisBarang Sheet8.Cells(emptyRow, 3).value = kolom Sheet8.Cells(emptyRow, 4).value = baris Sheet8.Cells(emptyRow, 5).value = level Sheet8.Cells(emptyRow, 6).value = Module9.stepTaken * 1 Sheet8.Cells(emptyRow, 7).value = Module9.stepTaken Sheet8.Cells(emptyRow, 8).value = keterangan 'Sheet8.Cells(emptyRow, 9).value = jenisBarang & "-" & nomorSeries & "-" & jumlahProses Sheet8.Cells(emptyRow, 9).value = nomorSeries End Sub Function finder(kolom As Integer, baris As Integer, level As Integer) As Integer 'fungsi untk mencar record di database Dim emptyRow As Integer emptyRow = WorksheetFunction.CountA(Sheet8.Range("A:A")) + 1 Dim i As Integer For i = 1 To emptyRow - 1 If Sheet8.Cells(i, 3).value = kolom And Sheet8.Cells(i, 4).value = baris And Sheet8.Cells(i, 5).value = level Then Exit For End If Next If i = emptyRow Then finder = 0 Else finder = i End If End Function
123
Lampiran 13. Module 11
Public TimerActivePutIn As Boolean Dim counter, max As Integer Dim jenisBarang As String Sub FillOrdered(jumlah As Integer, jenisBarangX As String) 'fungsi untuk memicu pengisian kotak kosong dengan jumlah dan jenis barang sesuai permintaan counter = 0 max = jumlah jenisBarang = jenisBarangX 'MsgBox max TimerActivePutIn = True Call TimerPutInOrdered 'Set Module4.tujuan = Nothing 'While TimerActivePutIn ' Call runAppEmptyMap 'Wend End Sub Public Sub TimerPutInOrdered() 'timer untuk mengatur interval waktu yang dilakukan dalam pengisian dari 1 slot ke slot lainnya 'bukan untuk mengatur waktu langkah waktu langkah beda lagi ada module nya masing masing karena 'module ini masih manggil module lain If TimerActivePutIn Then Call runAppEmptyMap Application.OnTime Now() + TimeValue("00:00:05"), "TimerPutInOrdered" 'Application.OnTime Now() + 1.1 / (24 * 60 * 60# * 2), "TimerTimerXXX" End If End Sub Sub runAppEmptyMap() 'fungsi yang di ulang setiap 2 detiknya. mengecek apakah proses pengisian barang 'sudah selesai atau belum jika sudah maka akan dilakukan terus hingga antrian barang yang di masukkan penuh atau habis selesai If counter > max - 1 Then TimerActivePutIn = False Else ' MsgBox counter If Module4.TimerSpecFillActive = True Or Module8.TimerTravelActive Then Else 'ini proses pemanggilan module yang di mention di atas If Module4.btujuan Then Else
124
counter = counter + 1 Module4.FIFOfill (jenisBarang) End If
Lampiran 13. Lanjutan End If End If End Sub
125
Lampiran 14. Grafik Simulasi Pergerakan Barang Jenis A2 dan A3
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 14 7 40 10 5 3 12 4 10 0 32 1
Crane Keluar 10 12 3 6 25 11 30 3 9 8 23 16
Forklift Masuk 14 7 40 10 5 3 12 4 10 0 32 1
Forklift Keluar 10 12 3 6 25 11 30 3 9 6 23 10
0
5
10
15
20
25
30
35
40
45Ju
mla
h M
ob
ilisa
si B
aran
g
Jenis A2
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 2 32 3 16 19 41 8 16 14 9 4 0
Crane Keluar 11 26 40 5 20 23 1 6 33 28 13 5
Forklift Masuk 2 32 3 16 19 5 8 16 14 9 4 0
Forklift Keluar 11 26 9 5 20 15 1 6 31 9 4 0
0
5
10
15
20
25
30
35
40
45
Jum
lah
Mo
bili
sasi
Bar
ang
Jenis A3
126
Lampiran 15. Grafik Simulasi Pergerakan Barang Jenis A4 dan A5
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 5 28 10 4 17 23 1 18 0 0 11 5
Crane Keluar 9 37 9 16 20 21 0 27 0 9 0 4
Forklift Masuk 5 28 10 4 17 23 1 18 0 0 11 5
Forklift Keluar 9 33 9 5 17 21 0 19 0 2 0 4
0
5
10
15
20
25
30
35
40
Jum
lah
Mo
bili
sasi
Bar
ang
Jenis A4
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 6 39 0 19 12 11 4 25 2 5 15 22
Crane Keluar 20 36 0 39 1 21 12 17 2 9 6 0
Forklift Masuk 6 39 0 19 12 11 4 25 2 5 15 22
Forklift Keluar 15 36 0 22 1 21 5 17 2 9 6 0
0
5
10
15
20
25
30
35
40
45
Jum
lah
Mo
bili
sasi
Bar
ang
Jenis A5
127
Lampiran 16. Grafik Simulasi Pergerakan Barang Jenis A6 dan A7
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 9 27 30 14 5 10 17 15 7 6 10 10
Crane Keluar 13 30 27 33 12 5 2 16 11 0 0 0
Forklift Masuk 9 27 30 14 5 10 7 15 7 6 10 10
Forklift Keluar 13 30 27 19 5 5 2 16 11 0 0 0
0
5
10
15
20
25
30
35
Jum
lah
Mo
bili
sasi
Bar
ang
Jenis A6
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 18 5 23 31 3 40 7 13 6 15 0 3
Crane Keluar 20 18 3 48 5 25 18 35 30 0 6 0
Forklift Masuk 18 5 23 31 3 40 7 13 6 15 0 3
Forklift Keluar 20 12 3 48 5 25 18 18 6 0 6 0
0
10
20
30
40
50
60
Jum
lah
Mo
bili
sasi
Bar
ang Jenis A7
128
Lampiran 17. Grafik Simulasi Pergerakan Barang Jenis B1 dan B2
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 1 10 39 27 13 37 5 60 16 0 0 28
Crane Keluar 9 15 20 8 2 33 21 1 5 3 7 4
Forklift Masuk 1 10 39 27 13 37 5 0 16 0 0 12
Forklift Keluar 9 15 20 8 2 33 21 1 5 3 7 4
0
10
20
30
40
50
60
70
Jum
lah
Mo
bili
sasi
Bar
ang
Jenis B2
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 30 14 24 30 20 11 43 41 3 19 11 29
Crane Keluar 25 22 15 19 48 5 10 0 12 30 0 0
Forklift Masuk 30 14 24 30 20 11 43 18 3 19 11 29
Forklift Keluar 25 22 15 19 48 5 10 0 12 30 0 0
0
10
20
30
40
50
60Ju
mla
h M
ob
ilisa
si B
aran
g
Jenis B1
129
Lampiran 18. Grafik Simulasi Pergerakan Barang Jenis B3 dan B4
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 2 42 8 5 1 56 14 21 0 9 4 1
Crane Keluar 15 33 14 12 18 3 10 38 2 1 0 2
Forklift Masuk 2 42 8 5 1 56 14 21 0 9 4 1
Forklift Keluar 15 33 14 12 18 3 10 38 2 1 0 2
0
10
20
30
40
50
60Ju
mla
h M
ob
ilisa
si B
aran
g
Jenis B3
Jan Feb Mar Apr Mei Jun Jul Ags Sep Okt Nov Des
Crane Masuk 1 15 24 12 2 9 63 40 6 15 0 0
Crane Keluar 21 22 8 75 23 1 9 0 31 3 16 9
Forklift Masuk 1 15 24 12 2 9 21 0 6 15 0 0
Forklift Keluar 21 22 8 75 11 1 9 0 26 3 12 0
0
10
20
30
40
50
60
70
80
Jum
lah
Mo
bili
sasi
Bar
ang
Jenis A4