- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题,自上周以来我一直在解决这个问题,尽管高级开发人员提出了建议。
我想通过计时器通过 COM 端口向电机发送机动命令。
envoi_commande_motorisation()
没有任何争论。它只是将特定格式的帧发送到 COM 端口,以使电机移动。然而,在逐步退出调试时,它似乎永远不会被调用。此命令包含在
Timer_moto_tick(sender, e) As Timer_moto.tick
中这只是我用来定期验证电机是否处于正确方位角的计时器,通过
Demande_etat_motorisation()
知道它的位置.
envoi_commande_motorisation()
手动,它的工作原理!然而,这是手工的,我想自动化Private Sub Timer_moto_Tick(sender As Object, e As EventArgs) Handles Timer_moto.Tick
'asking for the motor position
Demande_etat_motorisation()
'checking if we are acually in the automatize management of the motor and not in the manual way
If RadioButton_Manuel.Checked = False Then
'checking if the motor isn't already at the right place
If ((CDbl(Liste_azimut.Text) <> Val(Aff_position_azimut_source.Text)) Or (CDbl(Liste_elevation.Text) <> Val(Aff_position_site_source.Text))) Then
'otherwise we change the motor position text and say him to go this way
lecture_port_comm_moto()
Liste_azimut.Text = CType(Val(Aff_position_azimut_source.Text), String)
Liste_elevation.Text = CType(Val(Aff_position_site_source.Text), String)
envoi_commande_motorisation()
End If
envoi_commande_motorisation()
End If
End Sub
Demande_etat_motorisation
和
envoi_commande_motorisation
Public Sub Demande_etat_motorisation()
Dim i As Integer
Dim info As String
If init_en_cours = True Then Exit Sub
'asking for motor state
'frame in hexa : 57 00 00 00 00 00 00 00 00 00 00 1F 20
tableau_hexa(0) = &H57
For i = 1 To 10
tableau_hexa(i) = &H00
Next i
tableau_hexa(11) = &H1F
tableau_hexa(12) = &H20
'envoi de la données
info = "sending frames on ports "
'port 1 -------------------------------------------------------------------------------------------------------------------------
If etat_port_4.Checked = True And CheckBox_Moto_1.Checked = True Then
'chosing which port for motorisation
Try
Select Case Liste_port_4.Text
Case Zone_param_comm1.Text
Port_serie_1.Write(tableau_hexa, 0, 13)
Port_serie_1.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm2.Text
Port_serie_2.Write(tableau_hexa, 0, 13)
Port_serie_2.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm3.Text
Port_serie_3.Write(tableau_hexa, 0, 13)
Port_serie_3.ReceivedBytesThreshold = seuil_port_reception_moto
End Select
Catch ex As Exception
zone1.Text = "Error Motorisation 1 : " + ex.ToString
End Try
End If
'End If
'port 2 ----------------------------------------------------------------------------------------------------------------------
If etat_port_5.Checked = True And CheckBox_Moto_2.Checked = True Then
'sending the command
'here we chose which port to write in for the motor
Try
'assignation du à ouvrir
Select Case Liste_port_5.Text
Case Zone_param_comm1.Text
Port_serie_1.Write(tableau_hexa, 0, 13)
Port_serie_1.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm2.Text
Port_serie_2.Write(tableau_hexa, 0, 13)
Port_serie_2.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm3.Text
Port_serie_3.Write(tableau_hexa, 0, 13)
Port_serie_3.ReceivedBytesThreshold = seuil_port_reception_moto
End Select
Catch ex As Exception
zone1.Text = "Error Motorisation 2 : " + ex.ToString
End Try
End If
End Sub
Public Sub envoi_commande_motorisation()
'sending data on serial ports
'sending 13 chars
Dim i As Integer
Dim cjunk, cjunk1 As String
Dim nombre As Integer
Dim info As String
BorneMinAz = Nothing
BorneMaxAz = Nothing
BorneMinElev = Nothing
BorneMaxElev = Nothing
If init_en_cours = True Then Exit Sub
If Me.Liste_azimut.Text <> "" And Me.Liste_elevation.Text <> "" Then
Me.zone1.Text = ""
'classical command is being sent
tableau_hexa(0) = &H57
tableau_hexa(1) = &H30
'in degree degre
tableau_hexa(5) = &H1
tableau_hexa(6) = &H30
tableau_hexa(10) = &H1
'final bits for a command
tableau_hexa(11) = &H2F
tableau_hexa(12) = &H20
'azimut calculation
nombre = CInt(Liste_azimut.Text) + 360
cjunk1 = CStr(nombre)
'numbers upper to 100
cjunk = Mid(cjunk1, 1, 1)
tableau_hexa(2) = CByte(&H30 + Val(cjunk))
'having back the decade
cjunk = Mid(cjunk1, 2, 1)
tableau_hexa(3) = CByte(&H30 + Val(cjunk))
'unite
cjunk = Mid(cjunk1, 3, 1)
tableau_hexa(4) = CByte(&H30 + Val(cjunk))
'tilt calculation
nombre = CInt(Liste_elevation.Text) + 360
cjunk1 = CStr(nombre)
'number upper to 100
cjunk = Mid(cjunk1, 1, 1)
tableau_hexa(7) = CByte(&H30 + Val(cjunk))
'decade recuperation
cjunk = Mid(cjunk1, 2, 1)
tableau_hexa(8) = CByte(&H30 + Val(cjunk))
'unite
cjunk = Mid(cjunk1, 3, 1)
tableau_hexa(9) = CByte(&H30 + Val(cjunk))
'affichage de la trame envoyée
cjunk = ""
For i = 0 To 12
cjunk = cjunk + CStr(Hex(tableau_hexa(i))) + " "
Next
envoi_azimut_elevation.Text = "frame sent: " + cjunk
info = "frames being sent on the port : "
'port 1
'motorisation 1 --------------------------------------------------------------------------------------------------------------------
If etat_port_4.Checked = True And CheckBox_Moto_1.Checked = True Then
'chosing port for motor 1
Try
Select Case Liste_port_4.Text
Case Zone_param_comm1.Text
Port_serie_1.Write(tableau_hexa, 0, 13)
Port_serie_1.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm2.Text
Port_serie_2.Write(tableau_hexa, 0, 13)
Port_serie_2.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm3.Text
Port_serie_3.Write(tableau_hexa, 0, 13)
Port_serie_3.ReceivedBytesThreshold = seuil_port_reception_moto
End Select
Catch ex As Exception
zone1.Text = "Erreur Motorisation 1 : " + ex.ToString
End Try
'affichage de l'info sur l'afficheur noir
'azimut
i = CInt(Val(Liste_azimut.Text))
Select Case i
Case 0 To 9
Affiche_info_azimut.Text = "00" + Format(i, "##0")
Case 10 To 99
Affiche_info_azimut.Text = "0" + Format(i, "##0")
Case Else
Affiche_info_azimut.Text = Format(i, "##0")
End Select
Affiche_info_azimut.ForeColor = Color.Green
'tilt
i = CInt(Val(Liste_elevation.Text))
Select Case i
Case -9 To -1
Affiche_info_elevation.Text = "-0" + Format(Abs(i), "##")
Case 0 To 9
Affiche_info_elevation.Text = "0" + Format(i, "##")
Case Else
Affiche_info_elevation.Text = Format(i, "##")
End Select
Affiche_info_elevation.ForeColor = Color.Green
End If
'port 2 -------------------------------------------------------------------------------------------------------------------------
If etat_port_5.Checked = True And CheckBox_Moto_2.Checked = True Then
'envoi de la commande
'choix du port choisi pour la motorisation 1
Try
'assignation du à ouvrir
Select Case Liste_port_5.Text
Case Zone_param_comm1.Text
Port_serie_1.Write(tableau_hexa, 0, 13)
Port_serie_1.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm2.Text
Port_serie_2.Write(tableau_hexa, 0, 13)
Port_serie_2.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm3.Text
Port_serie_3.Write(tableau_hexa, 0, 13)
Port_serie_3.ReceivedBytesThreshold = seuil_port_reception_moto
End Select
Catch ex As Exception
zone1.Text = "Erreur Motorisation 2 : " + ex.ToString
End Try
'affichage de l'info sur l'afficheur noir
'azimut
i = CInt(Val(Liste_azimut.Text))
Select Case i
Case 0 To 9
Affiche_info_azimut.Text = "00" + Format(i, "##0")
Case 10 To 99
Affiche_info_azimut.Text = "0" + Format(i, "##0")
Case Else
Affiche_info_azimut.Text = Format(i, "##0")
End Select
Affiche_info_azimut.ForeColor = Color.LightGreen
'elevation
i = CInt(Val(Liste_elevation.Text))
Select Case i
Case -9 To -1
Affiche_info_elevation.Text = "-0" + Format(Abs(i), "##")
Case 0 To 9
Affiche_info_elevation.Text = "0" + Format(i, "##")
Case Else
Affiche_info_elevation.Text = Format(i, "##")
End Select
Affiche_info_elevation.ForeColor = Color.Green
'demande de position
Demande_etat_motorisation()
End If
'End If
'
End If
End Sub
Diagnostics.Debug.Writeline("some specific text here")
我的程序可能在任何地方都崩溃了。实际上,在终端中写入的行中,我注意到它是
Serialports.Writeline(,,)
这会造成问题。
Private Sub Timer_moto_Tick(sender As Object, e As EventArgs) Handles Timer_moto.Tick
'asking for the motor position
Demande_etat_motorisation()
'checking if we are acually in the automatize management of the motor and not in the manual way
If RadioButton_Manuel.Checked = False Then
Diagnostics.Debug.WriteLine("test if we are at the right place")
If ((CDbl(Liste_azimut.Text) <> Val(Aff_position_azimut_source.Text)) Or (CDbl(Liste_elevation.Text) <> Val(Aff_position_site_source.Text))) Then
lecture_port_comm_moto()
Liste_azimut.Text = CType(Val(Aff_position_azimut_source.Text), String)
Liste_elevation.Text = CType(Val(Aff_position_site_source.Text), String)
envoi_commande_motorisation()
Diagnostics.Debug.WriteLine("we have just send the orders to the camera")
End If
End If
End Sub
envoi_commande_motorisation()
中添加了一些
Public Sub envoi_commande_motorisation()
'sending data on serial ports
'sending 13 chars
Dim i As Integer
Dim cjunk, cjunk1 As String
Dim nombre As Integer
Dim info As String
BorneMinAz = Nothing
BorneMaxAz = Nothing
BorneMinElev = Nothing
BorneMaxElev = Nothing
Diagnostics.Debug.WriteLine("We just get into envoi_commande_motorisation()")
If init_en_cours = True Then Exit Sub
If Me.Liste_azimut.Text <> "" And Me.Liste_elevation.Text <> "" Then
Me.zone1.Text = ""
'classical command is being sent
tableau_hexa(0) = &H57
tableau_hexa(1) = &H30
'transforming it in degree
tableau_hexa(5) = &H1
tableau_hexa(6) = &H30
'again
tableau_hexa(10) = &H1
'final bits for a command
tableau_hexa(11) = &H2F
tableau_hexa(12) = &H20
'azimut calculation
nombre = CInt(Liste_azimut.Text) + 360
cjunk1 = CStr(nombre)
'number bigger than 100
cjunk = Mid(cjunk1, 1, 1)
tableau_hexa(2) = CByte(&H30 + Val(cjunk))
'taking the decade
cjunk = Mid(cjunk1, 2, 1)
tableau_hexa(3) = CByte(&H30 + Val(cjunk))
'unity
cjunk = Mid(cjunk1, 3, 1)
tableau_hexa(4) = CByte(&H30 + Val(cjunk))
'elevation calculation
nombre = CInt(Liste_elevation.Text) + 360
cjunk1 = CStr(nombre)
'number bigger than 100
cjunk = Mid(cjunk1, 1, 1)
tableau_hexa(7) = CByte(&H30 + Val(cjunk))
'taking the decade
cjunk = Mid(cjunk1, 2, 1)
tableau_hexa(8) = CByte(&H30 + Val(cjunk))
'units
cjunk = Mid(cjunk1, 3, 1)
tableau_hexa(9) = CByte(&H30 + Val(cjunk))
displaying the frame sent
cjunk = ""
For i = 0 To 12
cjunk = cjunk + CStr(Hex(tableau_hexa(i))) + " "
Next
envoi_azimut_elevation.Text = "Trame envoi : " + cjunk
Diagnostics.Debug.WriteLine("We are going to get into the writes")
info = "sending data on ports "
'port 1
'motorisation 1 --------------------------------------------------------------------------------------------------------------------
If etat_port_4.Checked = True And CheckBox_Moto_1.Checked = True Then
'chosing ports
Try
Select Case Liste_port_4.Text
Case Zone_param_comm1.Text
Port_serie_1.Write(tableau_hexa, 0, 13)
'Port_serie_1.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm2.Text
Port_serie_2.Write(tableau_hexa, 0, 13)
'Port_serie_2.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm3.Text
Port_serie_3.Write(tableau_hexa, 0, 13)
'Port_serie_3.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm4.Text
Diagnostics.Debug.WriteLine("we are going to write in COM port 4")
Port_serie_4.Write(tableau_hexa, 0, 13)
Diagnostics.Debug.WriteLine("We just wrote in COM Port 4")
Timer_moto.Start()
'Port_serie_4.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm5.Text
Port_serie_5.Write(tableau_hexa, 0, 13)
'Port_serie_5.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm6.Text
Port_serie_6.Write(tableau_hexa, 0, 13)
'Port_serie_6.ReceivedBytesThreshold = seuil_port_reception_moto
End Select
Catch ex As Exception
zone1.Text = "Erreur Motorisation 1 : " + ex.ToString
End Try
'displaying azimut infomations on screen
'azimut
i = CInt(Val(Liste_azimut.Text))
Select Case i
Case 0 To 9
Affiche_info_azimut.Text = "00" + Format(i, "##0")
Case 10 To 99
Affiche_info_azimut.Text = "0" + Format(i, "##0")
Case Else
Affiche_info_azimut.Text = Format(i, "##0")
End Select
Affiche_info_azimut.ForeColor = Color.Green
'elevation
i = CInt(Val(Liste_elevation.Text))
Select Case i
Case -9 To -1
Affiche_info_elevation.Text = "-0" + Format(Abs(i), "##")
Case 0 To 9
Affiche_info_elevation.Text = "0" + Format(i, "##")
Case Else
Affiche_info_elevation.Text = Format(i, "##")
End Select
Affiche_info_elevation.ForeColor = Color.Green
End If
'port 2 -------------------------------------------------------------------------------------------------------------------------
If etat_port_5.Checked = True And CheckBox_Moto_2.Checked = True Then
'sending command
'chosing port
Try
Select Case Liste_port_5.Text
Case Zone_param_comm1.Text
Port_serie_1.Write(tableau_hexa, 0, 13)
'Port_serie_1.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm2.Text
Port_serie_2.Write(tableau_hexa, 0, 13)
'Port_serie_2.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm3.Text
Port_serie_3.Write(tableau_hexa, 0, 13)
'Port_serie_3.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm4.Text
Port_serie_4.Write(tableau_hexa, 0, 13)
'Port_serie_4.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm5.Text
Port_serie_5.Write(tableau_hexa, 0, 13)
'Port_serie_5.ReceivedBytesThreshold = seuil_port_reception_moto
Case Zone_param_comm6.Text
Port_serie_6.Write(tableau_hexa, 0, 13)
'Port_serie_6.ReceivedBytesThreshold = seuil_port_reception_moto
End Select
Catch ex As Exception
zone1.Text = "Erreur Motorisation 2 : " + ex.ToString
End Try
'affichage de l'info sur l'afficheur noir
'azimut
i = CInt(Val(Liste_azimut.Text))
Select Case i
Case 0 To 9
Affiche_info_azimut.Text = "00" + Format(i, "##0")
Case 10 To 99
Affiche_info_azimut.Text = "0" + Format(i, "##0")
Case Else
Affiche_info_azimut.Text = Format(i, "##0")
End Select
Affiche_info_azimut.ForeColor = Color.LightGreen
'elevation
i = CInt(Val(Liste_elevation.Text))
Select Case i
Case -9 To -1
Affiche_info_elevation.Text = "-0" + Format(Abs(i), "##")
Case 0 To 9
Affiche_info_elevation.Text = "0" + Format(i, "##")
Case Else
Affiche_info_elevation.Text = Format(i, "##")
End Select
Affiche_info_elevation.ForeColor = Color.Green
'demande de position
'Demande_etat_motorisation()
End If
'End If
'
End If
End Sub
Diagnostics.Debug.WriteLine
消息被读取并显示在终端上,但相机没有移动 .因此,当链接到COM端口4时,我认为是
Port_serie_4.Write(tableau_hexa, 0, 13)
有一个严重的问题,
test if we are at the right place
然后。即使我下令移动,就像他认为我们在正确的地方一样,除非单击调用
envoi_commande_motorisation()
的按钮。 .
Case Zone_param_comm4.Text
Diagnostics.Debug.WriteLine("we are going to write in COM port 4")
Port_serie_4.Write(tableau_hexa, 0, 13)
System.Threading.Thread.Sleep(500)
Diagnostics.Debug.WriteLine("We just wrote in COM Port 4")
最佳答案
假设您在调试期间没有禁用某些中断,那么当您单步执行那些在您让它自动运行时无法完成的程序时,在您点击“下一步”的延迟期间,可以异步完成某些事情。我查看了你的代码,没有什么是显而易见的。
首先尝试在使用调试器执行的步骤之间添加延迟。每一步大约一秒钟,所以它就像你正在点击“下一步......下一步......下一步”,但它只会是“延迟......延迟......延迟”如果有效,请尝试消除一次延迟一个,直到它停止工作。然后你就会知道你的代码的哪一部分正在寻找尚未准备好的结果。
我怀疑你的代码中需要一些东西来检查之前的通信是否完成。然后,如果前一个通信未完成,您将在下一个循环之前什么都不做。您可能最好将代码转换为状态机,在其中一次完成一个操作,并且在您可以验证系统已完成前一个状态之前不要移动到下一个状态。
关于vb.net - 除非按部就类,否则妨碍自身功能运行的定时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38830283/
我有几个问题。我是 Visual Basic 这个领域的新手,所以不要取笑我。 1.) VB.NET之间有什么区别和 VB ? 2.) 我需要为 Windows 开发基本的应用程序。(如记事本)我应该
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我是框架 3.5 的新手。我注意到,在创建 Web 内容表单时,除了 aspx.vb 页面之外,它还会创建一个 aspx.designer.vb 页面。谁能向我解释一下它们之间的区别以及它们的用途吗?
我只是想知道 VB.NET 和 VB 2010 是否相同。 我只是想知道。 最佳答案 VB 2010 是 VB.Net 的最新版本。 Microsoft 在 VB 2005 版本中删除了 VB 的“.
我是框架 3.5 的新手。我注意到,在创建 Web 内容表单时,除了 aspx.vb 页面之外,它还会创建一个 aspx.designer.vb 页面。谁能向我解释一下它们之间的区别以及它们的用途吗?
我正在尝试将 VB 函数移植到 VB.NET,但我无法使该函数正常工作并正确更新。 rFormat = Format(Format(Value, fmt), String$(Len(fmt), "@"
如何在VB中注释多行代码/代码块? 最佳答案 VB 在语言级别上没有这样的构造。它有使用撇号字符的单行注释: ' hello world ' this is a comment Rem this is
我正在使用我在 VB2005 中创建的表单在按下按钮时打开程序,然后在文本字段中显示进程 ID(再次按下按钮时)。当我运行它时,表单将打开程序 (Notepad.exe) 但当我单击按钮查看进程 ID
我正在尝试添加一个从 vb.net 创建的 dll,并且想将其导入到现有的 vb 6 项目中,但它给了我错误“无法添加对指定文件的引用”。 。有人知道如何解决这个问题吗? 最佳答案 需要遵循以下步骤:
我有一个数据 GridView 。右键单击它会显示一个上下文菜单,但它始终位于右上角。我想要它,以便菜单出现在用户右键单击的单元格上。它可能是单元格 1 或单元格 2 或其他。 谢谢福尔坎 最佳答案
我只是在 Visual Studio 2010 中使用 Visual Basic。有人知道我将如何制作“浏览文件夹(或文件)”按钮吗?我对 VB 真的很陌生,我只是在寻找一些简单的帮助:) 最佳答案
这次感到困惑... 最简单的代码行有时可能起作用,有时却没有。首先,我认为问题在于我试图读取DWORD的值,但是由于我可以从某些键读取DWORD值,所以这一定不是问题。现在的问题似乎是,如果 key
我的代码中有此方法: Private Sub Display() Received.AppendText(" - " & RXArray) End Sub 这两个调用之间有什么区别:
我正在创建一个宏程序来记录和回放鼠标和键盘输入。录制效果很好,鼠标播放也一样,但是我在播放键盘输入时遇到了麻烦——特别是在释放之前按住一个键几秒钟。这不等同于重复按键。这是我尝试过的: 技巧 1:Me
我最近刚刚了解了 VB.NET 中静态局部变量的使用,并想知道它在延迟加载属性中的潜在用途。 考虑以下示例代码。 Public Class Foo Implements IFoo End Clas
VB 有一个 C# 没有的特性,在项目级别导入命名空间(我的项目>引用>导入命名空间)。当新人在源代码控制之外检查项目时,我们的自定义导入不包括在内。这个 VB 特定的导入命名空间存储在哪里? 最佳答
我已将我的问题缩小到这个简单的案例,但似乎无法找到发生了什么: 我有两个表单,一个只有一个按钮,另一个是空的。 单击按钮时,form1 隐藏和显示 form2 出现时,form2隐藏,form1再次显
为什么下面的简单代码会失败?无论我使用 LinearGradientMode 的哪个值,这段代码总是用从左到右的渐变填充路径。 graphPath 是在别处创建的 GraphicPath 对象(基本上
我可以多快替换字符串中的字符? 所以这个问题的背景是这样的:我们有几个应用程序通过套接字相互通信并与客户端的应用程序通信。这些套接字消息包含不可打印的字符(例如 chr(0)),需要用预定的字符串(例
如何从任何文件中读取原始字节数组... Dim bytes() as Byte ..然后将该字节数组写回新文件? 我需要它作为一个字节数组来做一些处理。 我目前正在使用: 阅读 Dim fInfo
我是一名优秀的程序员,十分优秀!