概述
很简单的进制转换, pyhton代码如下
active time T3324 秒➡bits
#T3324 Requested_Active-Time
import math
#input_time=input("Please enter the time:")
#t=int(input_time)
t=34
if t>=0 and t<=62:
if t%2==0:
T3="000";
t4=bin(math.ceil(t/2)).replace('0b','')
T4=t4.zfill(5)
T=T3+T4
print(T)
else:
print("illegal time")
elif t>=120 and t<=1860:
if t%60==0:
T3="001";
t4=bin(math.ceil(t/60)).replace('0b','')
T4=t4.zfill(5)
T=T3+T4
print(T)
else:
print("illegal time")
elif t>=2160 and t<=11160:
if t%360==0:
T3="000";
t4=bin(math.ceil(t/360)).replace('0b','')
T4=t4.zfill(5)
T=T3+T4
print(T)
else:
print("illegal time")
else:
print("illegal time")
period time T3412 秒➡bits
#T3412 Requested_Periodic-TAU
import math
#input_time=input("Please enter the time:")
#t=int(input_time)
t=10800
if t>=0 and t<=62:
if t%2==0:
T1="011";
t2=bin(math.ceil(t/2)).replace('0b','')
T2=t2.zfill(5)
T=T1+T2
print(T)
else:
print("illegal time")
elif t>=90 and t<=930:
if t%30==0:
T1="100"
t2=bin(math.ceil(t/30)).replace('0b','')
T2=t2.zfill(5)
T=T1+T2
print(T)
else:
print("illegal time")
elif t>=960 and t<=1860:
if t%60==0:
T1="101"
t2=bin(math.ceil(t/60)).replace('0b','')
T2=t2.zfill(5)
T=T1+T2
print(T)
else:
print("illegal time")
elif t>=2400 and t<=18600:
if t%600==0:
T1="000"
t2=bin(math.ceil(t/600)).replace('0b','')
T2=t2.zfill(5)
T=T1+T2
print(T)
else:
print("illegal time")
elif t>=21600 and t<=111600:
if t%3600==0:
T1="001"
t2=bin(math.ceil(t/3600)).replace('0b','')
T2=t2.zfill(5)
T=T1+T2
print(T)
else:
print("illegal time")
elif t>=144000 and t<=1116000:
if t%36000==0:
T1="010";
t2=bin(math.ceil(t/36000)).replace('0b','')
T2=t2.zfill(5)
T=T1+T2
print(T)
else:
print("illegal time")
elif t>=1152000 and t<=35712000:
if t%115200==0:
T1="110";
t2=bin(math.ceil(t/115200)).replace('0b','')
T2=t2.zfill(5)
T=T1+T2
print(T)
else:
print("illegal time")
else:
print("illegal time")
最后
以上就是曾经秀发为你收集整理的NBIoT的PSM时间格式转换python的全部内容,希望文章能够帮你解决NBIoT的PSM时间格式转换python所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复