You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
255 lines
10 KiB
255 lines
10 KiB
|
|
|
|
def getAgvStop(stop):
|
|
curStop = "01-112-3"
|
|
if stop > 0:
|
|
if 4000 <= stop:
|
|
# charge stop
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "01-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 50 > stop:
|
|
# main stop
|
|
stopStr = ("{}".format(stop)).zfill(2)
|
|
curStop = "{}-0000".format(stopStr)
|
|
print(curStop)
|
|
elif 100 > stop:
|
|
# connection area
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "01-{}-1".format(stopStr)
|
|
print(curStop)
|
|
else:
|
|
subStop = int(stop / 100)
|
|
if 1 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "01-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 2 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "02-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 3 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "03-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 4 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "04-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 5 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "05-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 6 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "06-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 7 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "07-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 8 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "08-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 9 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "09-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 10 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "10-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 11 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "11-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 12 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "12-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 14 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "13-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 15 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "14-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 16 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "15-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 17 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "16-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 18 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "17-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 19 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "18-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 20 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "19-{}-1".format(stopStr)
|
|
print(curStop)
|
|
elif 21 == subStop:
|
|
stopStr = ("{}".format(stop)).zfill(4)
|
|
curStop = "20-{}-1".format(stopStr)
|
|
print(curStop)
|
|
return curStop
|
|
|
|
'''
|
|
start = "01-0112-3"
|
|
end = "03-0311-2"
|
|
'''
|
|
def genPath(start, end):
|
|
print("start {}, end {}".format(start, end))
|
|
startParts = start.split("-")
|
|
endParts = end.split("-")
|
|
|
|
if endParts[0] != startParts[0]:
|
|
#cross stop
|
|
startMainStop = int(startParts[0])
|
|
stopMainStop = int(endParts[0])
|
|
startMain = [startMainStop, stopMainStop]
|
|
# startMain = []
|
|
# if startMainStop > stopMainStop:
|
|
# startMain = [x for x in range(startMainStop, stopMainStop - 1, -1)]
|
|
# else:
|
|
# startMain = [x for x in range(startMainStop, stopMainStop + 1)]
|
|
|
|
|
|
startStop = int(startParts[1])
|
|
if startStop >= 5000:
|
|
halfPath1 = [startStop, 5002]
|
|
elif startStop >= 4000:
|
|
halfPath1 = [startStop, 4000]
|
|
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
|
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
|
elif 50 < startStop and 100 > startStop:
|
|
halfPath1 = [startStop, 63]
|
|
#connection area stop number start from 60 to 68
|
|
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
|
elif startStop > 0:
|
|
crossStop1 = int(startStop / 100)*100 + 10
|
|
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
|
halfPath1 = [startStop, crossStop1]
|
|
else:
|
|
halfPath1 = []
|
|
|
|
|
|
endStop = int(endParts[1])
|
|
if endStop >= 5000:
|
|
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
|
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
|
halfPath2 = [5002, endStop]
|
|
elif endStop >= 4000:
|
|
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
|
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
|
halfPath2 = [4000, 4001, endStop]
|
|
elif 50 < endStop and 100 > endStop:
|
|
#connection area stop number start from 60 to 68
|
|
# halfPath2 = [x for x in range(60, endStop + 1)]
|
|
halfPath2 = [63, endStop]
|
|
elif endStop > 0:
|
|
crossStop2 = int(endStop / 100)*100 + 10
|
|
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
|
halfPath2 = [crossStop2, endStop]
|
|
else:
|
|
halfPath2 = []
|
|
|
|
return halfPath1 + startMain + halfPath2
|
|
|
|
elif endParts[0] == startParts[0]:
|
|
# in same passway
|
|
endStop = int(endParts[1])
|
|
startStop = int(startParts[1])
|
|
if endStop == startStop and 0 != startStop:
|
|
# need to be done
|
|
#same stop
|
|
return [startStop]
|
|
elif endStop == startStop and 0 == startStop:
|
|
return [ int(startParts[0]) ]
|
|
else:
|
|
|
|
if abs( endStop - startStop ) < 100 and endStop > 100 and startStop > 100:
|
|
#don't include connection area
|
|
# in same line
|
|
if endStop > startStop:
|
|
# return [x for x in range(startStop, endStop + 1)]
|
|
return [startStop, endStop]
|
|
else:
|
|
# return [x for x in range(startStop, endStop - 1, -1)]
|
|
return [startStop, endStop]
|
|
|
|
elif abs( endStop - startStop ) < 100 and endStop < 100 and endStop > 50 and startStop < 100 and startStop > 50:
|
|
#connection area
|
|
# in same line
|
|
if endStop > startStop > 63:
|
|
# return [x for x in range(startStop, endStop + 1)]
|
|
return [startStop, endStop]
|
|
elif endStop > startStop:
|
|
return [x for x in range(startStop, endStop + 1)]
|
|
elif 63 < endStop < startStop:
|
|
# return [x for x in range(startStop, endStop - 1, -1)]
|
|
return [startStop, endStop]
|
|
elif endStop < startStop:
|
|
return [x for x in range(startStop, endStop - 1, -1)]
|
|
|
|
|
|
elif abs( endStop - startStop ) < 100 and endStop >= 4000 and startStop >= 4000:
|
|
#Charge stop
|
|
# in same line
|
|
if endStop > startStop:
|
|
# return [x for x in range(startStop, endStop + 1)]
|
|
return [startStop, endStop]
|
|
else:
|
|
# return [x for x in range(startStop, endStop - 1, -1)]
|
|
return [startStop, endStop]
|
|
|
|
else:
|
|
if startStop >= 5000:
|
|
#charge stop
|
|
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
|
halfPath1 = [startStop, 5002]
|
|
elif startStop >= 4000:
|
|
#charge stop
|
|
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
|
halfPath1 = [startStop, 4000]
|
|
elif 50 < startStop and 100 > startStop:
|
|
#connection area stop number start from 60 to 68
|
|
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
|
halfPath1 = [startStop, 63]
|
|
elif startStop > 0:
|
|
# cross line
|
|
crossStop1 = int(startStop / 100)*100 + 10
|
|
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
|
halfPath1 = [startStop, crossStop1]
|
|
else:
|
|
halfPath1 = []
|
|
|
|
if endStop >= 5000:
|
|
#charge stop
|
|
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
|
halfPath2 = [5002, endStop]
|
|
elif endStop >= 4000:
|
|
#charge stop
|
|
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
|
halfPath2 = [4000, endStop]
|
|
elif 50 < endStop and 100 > endStop:
|
|
#connection area stop number start from 60 to 68
|
|
# halfPath2 = [x for x in range(60, endStop + 1)]
|
|
halfPath2 = [63, endStop]
|
|
elif endStop > 0:
|
|
crossStop2 = int(endStop / 100)*100 + 10
|
|
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
|
halfPath2 = [crossStop2, endStop]
|
|
else:
|
|
halfPath2 = []
|
|
# print("halfPath1 {}, startParts[0] {}, halfPath2 {}".format(halfPath1, startParts[0], halfPath2))
|
|
|
|
return halfPath1 + [ int(startParts[0]) ] + halfPath2 |