@@ -8,8 +8,15 @@ namespace OC.OfficeLite;
88[ PluginIoType ( IoType . Struct ) ]
99public class OfficeLite : PluginBase
1010{
11- private const uint DATA_SIZE_FROM_KRC = 1160 ;
12- private const uint DATA_SIZE_TO_KRC = 1040 ;
11+ /// <summary>
12+ /// Output[1024] + Axis[48] + Position[24] + Tool[24] + Base[24]
13+ /// </summary>
14+ private const uint DATA_SIZE_FROM_KRC = 1144 ;
15+
16+ /// <summary>
17+ /// Input[1024]
18+ /// </summary>
19+ private const uint DATA_SIZE_TO_KRC = 1024 ;
1320
1421 [ PluginParameter ( "IP Address of the\n OfficeLite VM" ) ]
1522 private readonly string _iPAddress = "192.168.0.1" ;
@@ -29,14 +36,17 @@ public class OfficeLite : PluginBase
2936 protected override bool OnSave ( )
3037 {
3138 InputStructure . AddVariable ( "Input" , TcType . Byte , 1024 ) ;
32- InputStructure . AddVariable ( "StandardSafety" , TcType . Dword ) ;
39+ // InputStructure.AddVariable("StandardSafety", TcType.Dword);
3340
3441 OutputStructure . AddVariable ( "Output" , TcType . Byte , 1024 ) ;
3542 OutputStructure . AddVariable ( "Axis" , TcType . Real , 12 ) ;
36- OutputStructure . AddVariable ( "StandardSafety" , TcType . Dword ) ;
37- OutputStructure . AddVariable ( "Sop1" , TcType . Dword ) ;
38- OutputStructure . AddVariable ( "Sop2" , TcType . Dword ) ;
39- OutputStructure . AddVariable ( "Reserve" , TcType . Dword ) ;
43+ //OutputStructure.AddVariable("Position", TcType.Real, 6);
44+ //OutputStructure.AddVariable("Tool", TcType.Real, 6);
45+ //OutputStructure.AddVariable("Base", TcType.Real, 6);
46+ //OutputStructure.AddVariable("StandardSafety", TcType.Dword);
47+ //OutputStructure.AddVariable("Sop1", TcType.Dword);
48+ //OutputStructure.AddVariable("Sop2", TcType.Dword);
49+ //OutputStructure.AddVariable("Reserve", TcType.Dword);
4050
4151 return true ;
4252 }
@@ -63,24 +73,12 @@ protected override void OnUpdate()
6373 {
6474 try
6575 {
66- Array . Copy ( InputBuffer , _sendData , 1028 ) ;
67-
68- if ( _interpolationTime == 0 )
69- {
70- Array . Copy ( _receiveData , 0 , OutputBuffer , 0 , 1072 ) ;
71- Array . Copy ( _receiveData , 1144 , OutputBuffer , 1072 , 16 ) ;
72- return ;
73- }
76+ Array . Copy ( InputBuffer , 0 , _sendData , 0 , 1024 ) ;
77+ //Array.Copy(InputBuffer, 1024, _sendData, 1024, 4);
7478
7579 Array . Copy ( _receiveData , 0 , OutputBuffer , 0 , 1024 ) ;
76- for ( var i = 0 ; i < 12 ; i ++ )
77- {
78- var offset = 1024 + i * 4 ;
79- var rawValue = BitConverter . ToSingle ( _receiveData , offset ) ;
80- var interpolatedValue = BitConverter . GetBytes ( ( float ) _interpolator [ i ] . Calculate ( rawValue ) ) ;
81- Array . Copy ( interpolatedValue , 0 , OutputBuffer , offset , 4 ) ;
82- }
83- Array . Copy ( _receiveData , 1144 , OutputBuffer , 1072 , 16 ) ;
80+ AxisCopy ( ) ;
81+ //Array.Copy(_receiveData, 1144, OutputBuffer, 1072, 16);
8482 }
8583 catch ( Exception e )
8684 {
@@ -89,6 +87,23 @@ protected override void OnUpdate()
8987 }
9088 }
9189
90+ private void AxisCopy ( )
91+ {
92+ if ( _interpolationTime == 0 )
93+ {
94+ Array . Copy ( _receiveData , 1024 , OutputBuffer , 1024 , 48 ) ;
95+ return ;
96+ }
97+
98+ for ( var i = 0 ; i < 12 ; i ++ )
99+ {
100+ var offset = 1024 + i * 4 ;
101+ var rawValue = BitConverter . ToSingle ( _receiveData , offset ) ;
102+ var interpolatedValue = BitConverter . GetBytes ( ( float ) _interpolator [ i ] . Calculate ( rawValue ) ) ;
103+ Array . Copy ( interpolatedValue , 0 , OutputBuffer , offset , 4 ) ;
104+ }
105+ }
106+
92107 protected override void OnStop ( )
93108 {
94109 try
0 commit comments