Python:测试数据输出到csv

测试目的

因项目需要,需要实现1-8个通道执行运动时,将获取的gaps值记录并输出到csv文件中,方便进行统计

测试代码

 1 def test_loadTipGaps():
 2     """
 3     测试台面及版本:
 4         1)台面文件:TestDeck_V0.4_20211105.SPD(注意同步更新自定义载架的json文件)
 5         2)台面编辑版本:V0.4_20211029_2
 6         3)控制软件版本:V0.4.0.15
 7     测试目的:扎排吸头压力测试
 8     测试场景:
 9         1)可用于收集扎吸头gaps
10         2)也可用于扎吸头硬件可靠性测试
11     """
12     TipSequence = ["Lane7TipsPos1", "Lane7TipsPos2", "Lane7TipsPos3", "Lane7TipsPos4", "Lane7TipsPos5"]
13     with open("record_loads_gaps" + ".csv", "a") as f:
14         f.write("Time,Pos,Channel1,channel2,channel3,channel4,channel5,channel6,channel7,channel8\n")  # titles
15         for j in range(200):
16             sp8Channels.WorkflowDeck.ReloadDeck()
17             for SequenceName in TipSequence:
18                 for i in range(12):
19                     load_tips({"Sequence": SequenceName, "Channels": [1, 2, 3, 4, 5, 6, 7, 8], "IfIncrement": False})
20                     current_time = time.strftime('%Y%m%d-%H%M%S', time.localtime(time.time()))
21                     line = current_time + ',' + str(SequenceName) + base_action.Gaps
22                     print(line)
23                     f.write(line + "\n")
24                     unload_tips({"Sequence": SequenceName, "Channels": [1, 2, 3, 4, 5, 6, 7, 8], "IfIncrement": True})
25                     time.sleep(0.5)
26     reload_sequences(["Lane7TipsPos1", "Lane7TipsPos2", "Lane7TipsPos3", "Lane7TipsPos4", "Lane7TipsPos5"])
27 
28 test_loadTipGaps()

运行结果(示例)

 

posted @ 2021-12-14 17:44  鱼衔花影去  阅读(634)  评论(0)    收藏  举报