-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathucVDCPController.vb
2305 lines (1850 loc) · 86 KB
/
ucVDCPController.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports System.Net.Sockets
Imports System.Text
Imports System.IO
Public Class ucVDCPController
Private m_DataBuffer As Byte() = New Byte(9) {}
Private m_asynResult As IAsyncResult
Public pfnCallBack As AsyncCallback
Public m_socClient As Socket
Dim client As New TcpClient
Dim NetStream As NetworkStream
Dim fps As Decimal = 25
Dim currrow As Integer
Dim tempRow As DataGridViewRow
Public Class CSocketPacket
Public thisSocket As System.Net.Sockets.Socket
Public dataBuffer As Byte() = New Byte(0) {}
End Class
Public Sub OnDataReceived(asyn As IAsyncResult)
On Error Resume Next
Control.CheckForIllegalCrossThreadCalls = False
Dim theSockId As CSocketPacket = DirectCast(asyn.AsyncState, CSocketPacket)
'end receive...
Dim iRx As Integer = 0
iRx = theSockId.thisSocket.EndReceive(asyn)
Dim chars As Char() = New Char(iRx) {}
Dim d As System.Text.Decoder = System.Text.Encoding.UTF8.GetDecoder()
Dim charLen As Integer = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0)
Dim szData As New System.String(chars)
txtgbRemoteLogging.AppendText(szData)
WaitForData()
End Sub
Private Sub cmdConnectRemoteLogging_Click(sender As Object, e As EventArgs) Handles cmdConnectRemoteLogging.Click
On Error Resume Next
m_socClient = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
m_socClient.Connect(cmbhost.Text, cmbportgbRemoteLogging.Text)
If m_socClient.Connected Then
cmdConnectRemoteLogging.Enabled = False
cmddisConnectRemoteLogging.Enabled = True
WaitForData()
Else
m_socClient = Nothing
End If
End Sub
Private Sub cmddisConnectRemoteLogging_Click(sender As Object, e As EventArgs) Handles cmddisConnectRemoteLogging.Click
On Error Resume Next
If m_socClient IsNot Nothing Then
m_socClient.Dispose()
m_socClient.Close()
m_socClient = Nothing
cmdConnectRemoteLogging.Enabled = True
cmddisConnectRemoteLogging.Enabled = False
End If
End Sub
Public Sub WaitForData()
On Error Resume Next
If pfnCallBack Is Nothing Then
pfnCallBack = New AsyncCallback(AddressOf OnDataReceived)
End If
Dim theSocPkt As New CSocketPacket()
theSocPkt.thisSocket = m_socClient
m_asynResult = m_socClient.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length, SocketFlags.None, pfnCallBack, theSocPkt)
End Sub
Private Sub cmdtcpsend_Click(sender As Object, e As EventArgs) Handles cmdtcpsend.Click
On Error Resume Next
Dim byData As [Byte]() = System.Text.Encoding.ASCII.GetBytes(txttcpsend.Text + vbCrLf)
m_socClient.Send(byData)
End Sub
Sub SendString(ByVal Stream As NetworkStream, ByVal Data As String)
On Error Resume Next
Dim Bytes As [Byte]() = Encoding.UTF8.GetBytes(Data)
If Stream.CanTimeout Then
Stream.WriteTimeout = 1000 * 5
End If
Stream.Write(Bytes, 0, Bytes.Length)
Return
End Sub
Sub GetSerialPortNames()
On Error Resume Next
cmbportsvtr.Items.AddRange(IO.Ports.SerialPort.GetPortNames())
End Sub
Private Sub initialisedatafordgvcuepointsvtr()
dgvcuepointsvtr.Rows.Add(10)
dgvcuepointsvtr.Rows(0).Cells(0).Value = "00:00:00:00"
dgvcuepointsvtr.Rows(1).Cells(0).Value = "00:01:00:00"
dgvcuepointsvtr.Rows(2).Cells(0).Value = "00:02:00:00"
dgvcuepointsvtr.Rows(3).Cells(0).Value = "00:03:00:00"
dgvcuepointsvtr.Rows(4).Cells(0).Value = "00:04:00:00"
dgvcuepointsvtr.Rows(5).Cells(0).Value = "00:05:00:00"
dgvcuepointsvtr.Rows(6).Cells(0).Value = "00:06:00:00"
dgvcuepointsvtr.Rows(7).Cells(0).Value = "00:07:00:00"
dgvcuepointsvtr.Rows(8).Cells(0).Value = "00:08:00:00"
dgvcuepointsvtr.Rows(9).Cells(0).Value = "00:09:00:00"
dgvcuepointsvtr.CurrentCell = dgvcuepointsvtr.Rows(2).Cells(0)
End Sub
Sub openport()
On Error Resume Next
If sp.IsOpen = False Then
sp.PortName = cmbportsvtr.Text
sp.Encoding = System.Text.Encoding.Default
sp.Open()
End If
'tmrgettc.Enabled = True
End Sub
Sub closeport()
On Error Resume Next
If sp.IsOpen = True Then
sp.PortName = cmbportsvtr.Text
sp.Encoding = System.Text.Encoding.Default
sp.Close()
End If
'tmrgettc.Enabled = False
End Sub
Private Sub tmrgettc_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrgettc.Tick
On Error Resume Next
sp.WriteLine(Chr(97) & Chr(12) & Chr(1) & Chr(110))
Threading.Thread.Sleep(15)
Dim timecode As String = ""
Dim bb As String = sp.ReadExisting
Dim str As String = ""
For ivtr = 3 To Len(bb) - 1
str = Mid(bb, ivtr, 1)
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
timecode = Val(Hex(byteArray(0))).ToString("00") & ":" & timecode
Next
lbltimecode.Text = Mid(timecode, 13, 11)
End Sub
Private Sub cmdopenportsvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdopenportsvtr.Click
On Error Resume Next
openport()
End Sub
Private Sub cmdplayvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdplayvtr.Click
On Error Resume Next
sp.WriteLine(Chr(CInt("&H20")) & Chr(1) & Chr(33))
End Sub
Private Sub cmdstopvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdstopvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(0) & Chr(32))
End Sub
Private Sub cmdrewindvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrewindvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(32) & Chr(64))
End Sub
Private Sub cmdffvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdffvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(16) & Chr(48))
End Sub
Private Sub cmdinpointvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdinpointvtr.Click
On Error Resume Next
sp.WriteLine(Chr(64) & Chr(16) & Chr(80))
lblinpointvtr.Text = lbltimecode.Text
End Sub
Private Sub cmdoutpointvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdoutpointvtr.Click
On Error Resume Next
sp.WriteLine(Chr(64) & Chr(17) & Chr(81))
lbloutpointvtr.Text = lbltimecode.Text
End Sub
Private Sub cmdPreRollvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPreRollvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(48) & Chr(80))
End Sub
Private Sub cmdejectvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdejectvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(15) & Chr(47))
End Sub
Private Sub cmdstandbyonvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdstandbyonvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(5) & Chr(37))
End Sub
Private Sub cmdstandbyoffvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdstandbyoffvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(4) & Chr(36))
End Sub
Private Sub cmdcuevtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcuevtr.Click
On Error Resume Next
Dim aa As Array = Split(dgvcuepointsvtr.CurrentRow.Cells(0).Value, ":")
Dim bb As String = Chr(36) & Chr(49) & Chr(System.Convert.ToInt32(aa(3), 16)) & Chr(System.Convert.ToInt32(aa(2), 16)) & Chr(System.Convert.ToInt32(aa(1), 16)) & Chr(System.Convert.ToInt32(aa(0), 16)) &
Chr(36 + 49 + System.Convert.ToInt32(aa(3), 16) + System.Convert.ToInt32(aa(2), 16) + System.Convert.ToInt32(aa(1), 16) + System.Convert.ToInt32(aa(0), 16))
sp.WriteLine(bb)
End Sub
Private Sub cmdmarkvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdmarkvtr.Click
On Error Resume Next
dgvcuepointsvtr.CurrentRow.Cells(0).Value = lbltimecode.Text
dgvcuepointsvtr.Rows.Add()
dgvcuepointsvtr.CurrentCell = dgvcuepointsvtr.Rows(dgvcuepointsvtr.CurrentRow.Index + 1).Cells(0)
End Sub
Sub submouseleave() Handles HScrollBarjogvtr.MouseLeave, HScrollBarvtr.MouseLeave, HScrollBarshuttlevtr.MouseLeave
On Error Resume Next
HScrollBarjogvtr.Value = 0
HScrollBarvtr.Value = 0
HScrollBarshuttlevtr.Value = 0
End Sub
Private Sub HScrollBarshuttlevtr_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBarshuttlevtr.ValueChanged
On Error Resume Next
Dim aa As Integer = HScrollBarshuttlevtr.Value
If aa > 0 Then
sp.WriteLine(Chr(33) & Chr(19) & Chr(aa) & Chr(33 + 19 + aa))
Else
sp.WriteLine(Chr(33) & Chr(35) & Chr(Math.Abs(aa)) & Chr(33 + 35 + Math.Abs(aa)))
End If
End Sub
Private Sub HScrollBarvtr_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBarvtr.ValueChanged
On Error Resume Next
Dim aa As Integer = HScrollBarvtr.Value
If aa > 0 Then
sp.WriteLine(Chr(33) & Chr(18) & Chr(aa) & Chr(33 + 18 + aa))
Else
sp.WriteLine(Chr(33) & Chr(34) & Chr(Math.Abs(aa)) & Chr(33 + 34 + Math.Abs(aa)))
End If
End Sub
Private Sub HScrollBarjogvtr_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBarjogvtr.ValueChanged
On Error Resume Next
Dim aa As Integer = HScrollBarjogvtr.Value
If aa > 0 Then
sp.WriteLine(Chr(33) & Chr(17) & Chr(aa) & Chr(33 + 17 + aa))
Else
sp.WriteLine(Chr(33) & Chr(33) & Chr(Math.Abs(aa)) & Chr(33 + 33 + Math.Abs(aa)))
End If
End Sub
Private Sub cmdrecordvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrecordvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(2) & Chr(32 + 2))
End Sub
Private Sub cmdautoeditvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdautoeditvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(66) & Chr(32 + 66))
End Sub
Private Sub cmdpreviewvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdpreviewvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(64) & Chr(32 + 64))
End Sub
Private Sub cmdReviewvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReviewvtr.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(65) & Chr(32 + 65))
End Sub
Private Sub cmdplusoneframevtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdplusoneframevtr.Click
On Error Resume Next
Dim aa As Array = Split(lbltimecode.Text, ":")
Dim bb As String = Chr(36) & Chr(49) & Chr(System.Convert.ToInt32(aa(3), 16) + 1) & Chr(System.Convert.ToInt32(aa(2), 16)) & Chr(System.Convert.ToInt32(aa(1), 16)) & Chr(System.Convert.ToInt32(aa(0), 16)) &
Chr(36 + 49 + System.Convert.ToInt32(aa(3), 16) + 1 + System.Convert.ToInt32(aa(2), 16) + System.Convert.ToInt32(aa(1), 16) + System.Convert.ToInt32(aa(0), 16))
sp.WriteLine(bb)
End Sub
Private Sub cmdminusoneframevtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdminusoneframevtr.Click
On Error Resume Next
Dim aa As Array = Split(lbltimecode.Text, ":")
Dim bb As String = Chr(36) & Chr(49) & Chr(System.Convert.ToInt32(aa(3) - 1, 16)) & Chr(System.Convert.ToInt32(aa(2), 16)) & Chr(System.Convert.ToInt32(aa(1), 16)) & Chr(System.Convert.ToInt32(aa(0), 16)) &
Chr(36 + 49 + System.Convert.ToInt32(aa(3) - 1, 16) + System.Convert.ToInt32(aa(2), 16) + System.Convert.ToInt32(aa(1), 16) + System.Convert.ToInt32(aa(0), 16))
sp.WriteLine(bb)
End Sub
Private Sub cmdassembleonvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdassembleonvtr.Click
On Error Resume Next
sp.WriteLine(Chr(66) & Chr(48) & Chr(32) & Chr(0) & Chr(66 + 48 + 32 + 0))
End Sub
Private Sub cmdassembleoffvtr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdassembleoffvtr.Click
On Error Resume Next
sp.WriteLine(Chr(66) & Chr(48) & Chr(0) & Chr(0) & Chr(66 + 48 + 0 + 0))
End Sub
Private Sub HScrollBarjogvtr_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBarjogvtr.Scroll
End Sub
Private Sub HScrollBarshuttlevtr_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBarshuttlevtr.Scroll
End Sub
Private Sub HScrollBarvtr_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBarvtr.Scroll
End Sub
Dim aaa, bbb, ccc, ddd As Integer
Private Sub cmd422send_Click(sender As Object, e As EventArgs) Handles cmd422send.Click
On Error Resume Next
aaa = CInt("&H" & Val(txt422send.Text))
bbb = CInt(Val("&H" & txt422send2.Text))
ddd = aaa + bbb
If ddd > 255 Then ddd = ddd Mod 256
sp.WriteLine(Chr(aaa) & Chr(bbb) & Chr(ddd))
Threading.Thread.Sleep(100)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
getresponsefornative(byteArray)
End Sub
Private Sub cmd422send3command_Click(sender As Object, e As EventArgs) Handles cmd422send3command.Click
On Error Resume Next
aaa = CInt("&H" & Val(txt422send3.Text))
bbb = CInt(Val("&H" & txt422send4.Text))
ccc = CInt(Val("&H" & txt422send5.Text))
ddd = aaa + bbb + ccc
If ddd > 255 Then ddd = ddd Mod 256
sp.WriteLine(Chr(aaa) & Chr(bbb) & Chr(ddd))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
getresponsefornative(byteArray)
End Sub
Public Function getchecksum(ByVal hexdata() As Byte) As Byte
Dim checkSum As Byte = 0
Dim isfirst As Boolean = True
For iii = 0 To hexdata.Length - 4
If isfirst Then
isfirst = False
checkSum = hexdata(iii)
End If
checkSum = checkSum Xor hexdata(iii)
Next
Return checkSum
End Function
Dim udpClient As New UdpClient
Dim iudp = 0
Public receivingUdpClient As UdpClient
Public ThreadReceive As System.Threading.Thread
Public RemoteIpEndPoint As New System.Net.IPEndPoint(System.Net.IPAddress.Any, 0)
Private Sub cmdudpsend_Click(sender As Object, e As EventArgs) Handles cmdudpsend.Click
On Error Resume Next
iudp = iudp + 1
udpClient.Send(System.Text.Encoding.ASCII.GetBytes(txtudpdata.Text), System.Text.Encoding.ASCII.GetBytes(txtudpdata.Text).Length, cmbhost.Text, txtudpport.Text)
txtudpdata.Text = "vimlesh" & iudp
End Sub
Private Sub cmdudpreceive_Click(sender As Object, e As EventArgs) Handles cmdudpreceive.Click
On Error Resume Next
Dim rport As Integer = txtudpportreceive.Text
receivingUdpClient = New System.Net.Sockets.UdpClient(rport)
NewInitialize()
sender.enabled = False
cmdstopreceive.Enabled = True
txtudpportreceive.Enabled = False
End Sub
Public Sub NewInitialize()
On Error Resume Next
ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
ThreadReceive.Start()
End Sub
Public Sub ReceiveMessages()
On Error Resume Next
Dim receiveBytes As [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint)
Dim strReturnData As String = System.Text.Encoding.ASCII.GetString(receiveBytes)
txtudprereceive.Text = strReturnData
NewInitialize()
End Sub
Private Sub cmdstopreceive_Click(sender As Object, e As EventArgs) Handles cmdstopreceive.Click
On Error Resume Next
ThreadReceive.Abort()
receivingUdpClient.Close()
sender.Enabled = False
cmdudpreceive.Enabled = True
txtudpportreceive.Enabled = True
End Sub
Private Sub cmdplaytcp_Click(sender As Object, e As EventArgs) Handles cmdplaytcp.Click
Dim aaa, bbb As Integer
aaa = 16
bbb = 1
Dim aa As String = Chr(2) & Chr(2) & Chr(aaa) & Chr(bbb) & Chr(256 - (aaa + bbb))
Dim byData As [Byte]() = System.Text.Encoding.ASCII.GetBytes(aa + vbCrLf)
m_socClient.Send(byData)
End Sub
Private Sub txt422send_TextChanged(sender As Object, e As EventArgs) Handles txt422send.TextChanged
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs)
On Error Resume Next
'sp.WriteLine(Chr(CInt("&H20")) & Chr(1) & Chr(33))
'sp.WriteLine(Chr(32) & Chr(1) & Chr(32 + 1))
Dim aaa, bbb As Integer
aaa = Val(txt422send.Text)
bbb = Val(txt422send2.Text)
sp.WriteLine(Chr(2) & Chr(2) & Chr(aaa) & Chr(bbb) & Chr(aaa + bbb))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
txt422receive.Text = Val(Hex(byteArray(0))) & " " & Val(Hex(byteArray(1))) & " " & Val(Hex(byteArray(2))) & " " & Val(Hex(byteArray(3))) & " " & Val(Hex(byteArray(4))) & " " & Val(Hex(byteArray(5))) & " " & Val(Hex(byteArray(6))) & " " & Val(Hex(byteArray(7)))
End Sub
Private Sub cmdopenport_Click(sender As Object, e As EventArgs) Handles cmdopenport.Click
On Error Resume Next
Dim aaa, bbb, ccc As Integer
aaa = 48
bbb = 1
ccc = Val(cmbportvdcp.Text)
If ccc < 0 Then ccc = 128 + Math.Abs(ccc)
' MsgBox(ccc)
Dim checksuminteger As Integer = aaa + bbb + ccc
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(4) & Chr(aaa) & Chr(bbb) & Chr(ccc) & Chr(0) & Chr(256 - checksuminteger))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
getresponse(byteArray)
End Sub
Private Sub cmdselectport_Click(sender As Object, e As EventArgs) Handles cmdselectport.Click
On Error Resume Next
Dim aaa, bbb, ccc As Integer
aaa = 32 'CInt("&HA0") '32
bbb = 34
ccc = Val(cmbportvdcp.Text)
If ccc < 0 Then ccc = 128 + Math.Abs(ccc)
Dim checksuminteger As Integer = aaa + bbb + ccc
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3) & Chr(aaa) & Chr(bbb) & Chr(ccc) & Chr(256 - checksuminteger))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
getresponse(byteArray)
End Sub
Private Sub cmdcloseport_Click(sender As Object, e As EventArgs) Handles cmdcloseport.Click
On Error Resume Next
Dim aaa, bbb, ccc As Integer
aaa = 32 ' CInt("&HA0") '32
bbb = 33
ccc = Val(cmbportvdcp.Text)
If ccc < 0 Then ccc = 128 + Math.Abs(ccc)
Dim checksuminteger As Integer = aaa + bbb + ccc
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3) & Chr(aaa) & Chr(bbb) & Chr(ccc) & Chr(256 - checksuminteger))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
getresponse(byteArray)
End Sub
Private Sub cmdvdcpplay_Click(sender As Object, e As EventArgs)
On Error Resume Next
'Dim aaa, bbb As Integer
'aaa = 16
'bbb = 1
'sp.WriteLine(Chr(2) & Chr(2) & Chr(aaa) & Chr(bbb) & Chr(256 - (aaa + bbb)))
playcommand()
End Sub
Sub getactiveid()
On Error Resume Next
clearbuffer()
Dim aaa, bbb, ccc As Integer
aaa = CInt("&HB0") '176 '48
bbb = CInt("&H07")
'ccc = 1
sp.WriteLine(Chr(2) & Chr(2) & Chr(aaa) & Chr(bbb) & Chr(256 - (aaa + bbb)))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
txtActiveID.Text = ""
For aa = 0 To byteArray.Count - 10
txtActiveID.Text = txtActiveID.Text & Chr(byteArray(6 + aa))
Next
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
On Error Resume Next
Dim aaa, bbb, ccc, ddd As Integer
aaa = CInt("&H" & t1.Text)
bbb = CInt("&H" & t2.Text)
'ccc = 1
ddd = aaa + bbb
If ddd > 255 Then ddd = ddd - 256
sp.WriteLine(Chr(2) & Chr(2) & Chr(aaa) & Chr(bbb) & Chr(256 - ddd))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
getresponse(byteArray)
End Sub
Sub getresponse(byteArray() As Byte)
txt422receive.Text = ""
For i = 0 To byteArray.Count - 1
If i = 0 Then
txt422receive.Text = Val(Hex(byteArray(i)))
Else
txt422receive.Text = txt422receive.Text & " " & Val(Hex(byteArray(i)))
End If
Next
End Sub
Sub getresponsefornative(byteArray() As Byte)
txtresponseNative.Text = ""
For i = 0 To byteArray.Count - 1
txtresponseNative.Text = txtresponseNative.Text & " " & Val(Hex(byteArray(i)))
Next
End Sub
Private Sub cmdcueclip_Click(sender As Object, e As EventArgs) Handles cmdcueclip.Click
On Error Resume Next
sp.WriteLine(Chr(32) & Chr(49) & Chr(81)) 'cue clip
End Sub
Private Sub cmdrecordvdcp_Click(sender As Object, e As EventArgs) Handles cmdrecordvdcp.Click
' On Error Resume Next
Dim aaa, bbb As Integer
aaa = CInt("&H10") '16
bbb = CInt("&H02") '2
sp.WriteLine(Chr(2) & Chr(2) & Chr(aaa) & Chr(bbb) & Chr(256 - (aaa + bbb)))
End Sub
Sub portstatus(StatusNumber As Integer)
'On Error Resume Next
lblPortStatus.Text = "Port Status " & StatusNumber
Dim aaa, bbb As Integer
aaa = 48
bbb = 5
Dim checksuminteger As Integer = aaa + bbb + StatusNumber
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3) & Chr(aaa) & Chr(bbb) & Chr(StatusNumber) & Chr(256 - checksuminteger))
Threading.Thread.Sleep(30)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
getresponse(byteArray)
getresponseerror(byteArray, StatusNumber)
End Sub
Sub getresponseerror(byteArray() As Byte, StatusNumber As Integer)
If StatusNumber = 3 Then
Dim aa As String = CBin(Val(Hex(byteArray(5))))
Do While Len(aa) < 8
aa = "0" & aa
Loop
For i = 0 To 7
dgvstatuserrovdcp.Rows(i).Cells(1).Value = Mid(aa, 8 - i, 1)
Next
aa = CBin(Val(Hex(byteArray(6))))
Do While Len(aa) < 8
aa = "0" & aa
Loop
For i = 8 To 15
dgvstatuserrovdcp.Rows(i).Cells(1).Value = Mid(aa, 16 - i, 1)
Next
aa = CBin(Val(Hex(byteArray(7))))
Do While Len(aa) < 8
aa = "0" & aa
Loop
For i = 16 To 23
dgvstatuserrovdcp.Rows(i).Cells(1).Value = Mid(aa, 24 - i, 1)
Next
ElseIf StatusNumber = 2 Then
Dim aa As String = CBin(Val(Hex(byteArray(5))))
Do While Len(aa) < 8
aa = "0" & aa
Loop
For i = 0 To 2
dgvstatuserrovdcp.Rows(i).Cells(1).Value = Mid(aa, 8 - i, 1)
Next
Else
Dim aa As String = CBin(Val(Hex(byteArray(5))))
Do While Len(aa) < 8
aa = "0" & aa
Loop
For i = 0 To 7
dgvstatuserrovdcp.Rows(i).Cells(1).Value = Mid(aa, 8 - i, 1)
Next
End If
End Sub
Sub cueclip()
Dim aaa, bbb As Integer
aaa = CInt("&HA0") 'variable length id
bbb = CInt("&H24")
Dim strclipname As String = dgv1.CurrentRow.Cells(0).Value
Dim charArray() As Char = strclipname
Dim yyy As Integer = 0
For i = 0 To (Len(strclipname) - 1)
charArray(i) = Mid(strclipname, i + 1, 1)
yyy = yyy + Decimal.op_Implicit(charArray(i))
Next
Dim checksuminteger As Integer = aaa + bbb + Len(strclipname) + yyy
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3 + Len(strclipname)) & Chr(aaa) & Chr(bbb) & Chr(Len(strclipname)) & strclipname & Chr(256 - checksuminteger))
End Sub
Private Sub cmdplayclipname_Click(sender As Object, e As EventArgs) Handles cmdplayclipname.Click
cueclip()
Threading.Thread.Sleep(500)
playcommand()
End Sub
Sub playcommand()
On Error Resume Next
sp.WriteLine(Chr(2) & Chr(2) & Chr(16) & Chr(1) & Chr(256 - 17))
Threading.Thread.Sleep(500)
getactiveid()
Threading.Thread.Sleep(500)
getSingleIdDurationfortracbar(txtActiveID.Text)
End Sub
Sub clearbuffer()
On Error Resume Next
sp.DiscardInBuffer()
sp.DiscardOutBuffer()
Threading.Thread.Sleep(100)
End Sub
Private Sub cmdGetIdDuration_Click(sender As Object, e As EventArgs) Handles cmdGetIdDuration.Click
On Error Resume Next
For aa = 0 To dgvclips.RowCount - 1
clearbuffer()
Dim aaa, bbb, ccc, ddd, eee, fff As Integer
aaa = CInt("&HB0")
bbb = CInt("&H14")
Dim strclipname As String = dgvclips.Rows(aa).Cells(0).Value
Dim charArray() As Char = strclipname
Dim yyy As Integer = 0
For i = 0 To (Len(strclipname) - 1)
charArray(i) = Mid(strclipname, i + 1, 1)
yyy = yyy + Decimal.op_Implicit(charArray(i))
Next
Dim checksuminteger As Integer = aaa + bbb + Len(strclipname) + yyy
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3 + Len(strclipname)) & Chr(aaa) & Chr(bbb) & Chr(Len(strclipname)) & strclipname & Chr(256 - checksuminteger))
Threading.Thread.Sleep(50)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
dgvclips.Rows(aa).Cells(1).Value = Format((Val(Hex(byteArray(9)))), "00") & ":" & Format((Val(Hex(byteArray(8)))), "00") & ":" & Format((Val(Hex(byteArray(7)))), "00")
Next
End Sub
Sub getSingleIdDurationfortracbar(idname As String)
clearbuffer()
Dim aaa, bbb As Integer
aaa = CInt("&HB0")
bbb = CInt("&H14")
Dim strclipname As String = idname
Dim charArray() As Char = strclipname
Dim yyy As Integer = 0
For i = 0 To (Len(strclipname) - 1)
charArray(i) = Mid(strclipname, i + 1, 1)
yyy = yyy + Decimal.op_Implicit(charArray(i))
Next
Dim checksuminteger As Integer = aaa + bbb + Len(strclipname) + yyy
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3 + Len(strclipname)) & Chr(aaa) & Chr(bbb) & Chr(Len(strclipname)) & strclipname & Chr(256 - checksuminteger))
Threading.Thread.Sleep(50)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
tbvdcp.Maximum = HMSFtoF(Format((Val(Hex(byteArray(9)))), "00") & ":" & Format((Val(Hex(byteArray(8)))), "00") & ":" & Format((Val(Hex(byteArray(7)))), "00"))
lbltbmax.Text = tbvdcp.Maximum
End Sub
Sub getSingleIdDurationforplaylist(idname As String, aa As Integer)
clearbuffer()
Dim aaa, bbb As Integer
aaa = CInt("&HB0")
bbb = CInt("&H14")
Dim strclipname As String = idname
Dim charArray() As Char = strclipname
Dim yyy As Integer = 0
For i = 0 To (Len(strclipname) - 1)
charArray(i) = Mid(strclipname, i + 1, 1)
yyy = yyy + Decimal.op_Implicit(charArray(i))
Next
Dim checksuminteger As Integer = aaa + bbb + Len(strclipname) + yyy
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3 + Len(strclipname)) & Chr(aaa) & Chr(bbb) & Chr(Len(strclipname)) & strclipname & Chr(256 - checksuminteger))
Threading.Thread.Sleep(50)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
dgv1.Rows(aa).Cells(3).Value = Format((Val(Hex(byteArray(9)))), "00") & ":" & Format((Val(Hex(byteArray(8)))), "00") & ":" & Format((Val(Hex(byteArray(7)))), "00")
End Sub
Sub getRemaingDuration()
On Error Resume Next
clearbuffer()
Dim aaa, bbb, ccc, ddd, eee, fff As Integer
aaa = CInt("&H30")
bbb = CInt("&H06")
If rdoRemainduration.Checked Then
ccc = 0
ElseIf rdoPlayedDuration.Checked Then
ccc = 2
Else
ccc = 1
End If
Dim checksuminteger As Integer = aaa + bbb + ccc
If checksuminteger > 256 Then
checksuminteger = checksuminteger Mod 256
End If
sp.WriteLine(Chr(2) & Chr(3) & Chr(aaa) & Chr(bbb) & Chr(ccc) & Chr(256 - checksuminteger))
Threading.Thread.Sleep(50)
Dim bb As String = sp.ReadExisting
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(bb)
lblRemainingDuration.Text = Format((Val(Hex(byteArray(8)))), "00") & ":" & Format((Val(Hex(byteArray(7)))), "00") & ":" & Format((Val(Hex(byteArray(6)))), "00") & ":" & Format((Val(Hex(byteArray(5)))), "00")
lblCurrentFrame.Text = tbvdcp.Maximum - HMSFtoF(lblRemainingDuration.Text)
tbvdcp.Value = lblCurrentFrame.Text
End Sub
Private Sub tmrRemainingDuration_Tick(sender As Object, e As EventArgs) Handles tmrRemainingDuration.Tick
On Error Resume Next
getRemaingDuration()
End Sub
Private Sub frmVDCPController_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GetSerialPortNames()
initialisedatafordgvcuepointsvtr()
initialisedgvporterror3()
openport()
With dgv1
.Rows.Add(10)
.Item(0, 0).Value = "kabhi_kabhi"
.Item(0, 1).Value = "dolby"
.Item(0, 2).Value = "abc"
.Item(0, 3).Value = "test"
.Item(0, 4).Value = "abcdefgh"
.Item(0, 5).Value = "test"
.Item(0, 6).Value = "abcdefghi"
.Item(2, 0).Value = 1
.Item(2, 1).Value = 0
.Item(2, 2).Value = 1
.Item(2, 3).Value = 0
.Item(2, 4).Value = 1
.Item(2, 5).Value = 1
.Item(2, 6).Value = 0
.Item(3, 0).Value = "00:04:20"
.Item(3, 1).Value = "01:04:20"
.Item(3, 2).Value = "00:08:40"
.Item(3, 3).Value = "00:14:20"
.Item(3, 4).Value = "00:24:35"
.Item(3, 5).Value = "00:14:50"
.Item(3, 6).Value = "00:13:17"
End With
With dgvclips
.Rows.Add(6)
.Item(0, 0).Value = "kabhi_kabhi"
.Item(0, 1).Value = "2"
.Item(1, 1).Value = "00:04:20"
.Item(0, 2).Value = "abc"
.Item(1, 2).Value = "02:01:20"
End With
tmrRemainingDuration.Enabled = True
End Sub
Sub initialisedgvporterror3()
With dgvstatuserrovdcp
.Rows.Clear()
.Rows.Add(24)
.Item(0, 0).Value = "SYSTEM ERROR"
.Item(0, 1).Value = "ILLEGAL VALUE"
.Item(0, 2).Value = "INVALID PORT"
.Item(0, 3).Value = "WRONG PORT TYPE"
.Item(0, 4).Value = "COMMAND QUEUE FULL"
.Item(0, 5).Value = "DISK FULL"
.Item(0, 6).Value = "CMD WHILE BUSY"
.Item(0, 7).Value = "NOTSUPPORTED"
.Item(0, 8).Value = "INVALID ID"
.Item(0, 9).Value = "ID NOTFOUND"
.Item(0, 10).Value = "ID ALREADY EXISTS"
.Item(0, 11).Value = "ID STILL RECORDING"
.Item(0, 12).Value = "ID STILL PLAYING"
.Item(0, 13).Value = "ID NOT TRANS-FERRED"
.Item(0, 14).Value = "ID TRANS-FERRED"
.Item(0, 15).Value = "ID DELETE PROTECTED"
.Item(0, 16).Value = "NOT IN CUE/INIT STATE"
.Item(0, 17).Value = "CUE NOT DONE"
.Item(0, 18).Value = "PORT NOT IDLE"
.Item(0, 19).Value = "PORT PLAYING /ACTIVE"
.Item(0, 20).Value = "PORT NOT ACTIVE"
.Item(0, 21).Value = "CUE OR OPERATION FAILED"
.Item(0, 22).Value = "NETWORK ERROR"
.Item(0, 23).Value = "SYSTEM REBOOTED"
End With
End Sub
Sub initialisedgvporterror2()
With dgvstatuserrovdcp
.Rows.Clear()
.Rows.Add(24)
.Item(0, 0).Value = "PORTDOWN"
.Item(0, 1).Value = "IDs ADDED"
.Item(0, 2).Value = "IDs DELETED"
End With
End Sub
Sub initialisedgvporterror1()
With dgvstatuserrovdcp
.Rows.Clear()
.Rows.Add(24)
.Item(0, 0).Value = "IDLE"
.Item(0, 1).Value = "CUE/INIT"
.Item(0, 2).Value = "PLAY OR RECORD"
.Item(0, 3).Value = "STILL"
.Item(0, 4).Value = "JOG"
.Item(0, 5).Value = "VARIABLE PLAY"
.Item(0, 6).Value = "PORT BUSY"
.Item(0, 7).Value = "CUE/INITDONE"
End With
End Sub
Private Sub dgvclips_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvclips.CellContentDoubleClick
End Sub
Private Sub dgvclips_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvclips.CellContentClick
End Sub
Private MouseDownPos As Point
Private MouseIsDown As Boolean = False
Private Sub dgvclips_MouseMove(sender As Object, e As MouseEventArgs) Handles dgvclips.MouseMove
On Error Resume Next
If e.Button = MouseButtons.Left Then
Dim dx = e.X - MouseDownPos.X
Dim dy = e.Y - MouseDownPos.Y
If Math.Abs(dx) >= SystemInformation.DoubleClickSize.Width OrElse
Math.Abs(dy) >= SystemInformation.DoubleClickSize.Height Then
If e.Button = Windows.Forms.MouseButtons.Right Then
cmsdgvclips.Show(MousePosition)
Else
Dim cellX, cellY As Integer
Dim grvScreenLocation As Point = dgvclips.PointToScreen(dgvclips.Location)
Dim tempX As Integer = DataGridView.MousePosition.X - grvScreenLocation.X + dgvclips.Left
Dim tempY As Integer = DataGridView.MousePosition.Y - grvScreenLocation.Y + dgvclips.Top
Dim hit As DataGridView.HitTestInfo = dgvclips.HitTest(tempX, tempY)
cellX = hit.RowIndex
cellY = hit.ColumnIndex
dgvclips.CurrentCell = dgvclips.Rows(cellX).Cells(0)
Dim datatocopy As String = dgvclips.CurrentRow.Cells(0).Value & Chr(2) & dgvclips.CurrentRow.Cells(1).Value
If MouseIsDown = True And dgv1.Cursor <> System.Windows.Forms.Cursors.SizeWE Then
dgvclips.DoDragDrop(datatocopy, DragDropEffects.Copy)
MouseIsDown = False
End If
End If
End If
End If
End Sub
Private Sub dgvclips_MouseDown(sender As Object, e As MouseEventArgs) Handles dgvclips.MouseDown
On Error Resume Next
MouseDownPos = e.Location
If dgvclips.Cursor = System.Windows.Forms.Cursors.SizeWE Then
MouseIsDown = False
Else
MouseIsDown = True
End If
End Sub
Private Sub lblRemainingDuration_Click(sender As Object, e As EventArgs)
End Sub
Sub nextclipofplaylist()
On Error Resume Next
If HMSFtoF(lblRemainingDuration.Text) < 60 Then
20:
Dim i As Integer
i = dgv1.CurrentRow.Index
If i = (dgv1.Rows.Count - 1) Then
dgv1.CurrentCell = dgv1.Rows(0).Cells(0)
Else
dgv1.CurrentCell = dgv1.Rows(i + 1).Cells(0)
End If
If dgv1.CurrentRow.Cells(0).Value = "" Then GoTo 20
cueclip()
Threading.Thread.Sleep(1000)
playcommand()