@@ -22,22 +22,33 @@ public partial class CalibrationSettingWindow : Window
2222 {
2323
2424 private CalibrationSettingItem CalibrationSetting = new CalibrationSettingItem ( ) ;
25+ private WristRotationFixSettingItem WristRotationFixSetting = new WristRotationFixSettingItem ( ) ;
2526
2627 public CalibrationSettingWindow ( )
2728 {
2829 InitializeComponent ( ) ;
29- DataContext = CalibrationSetting ;
30+
31+ OverrideBodyHeightGroupBox . DataContext = CalibrationSetting ;
32+ PelvisOffsetGroupBox . DataContext = CalibrationSetting ;
33+ WristRotationFixSettingGroupBox . DataContext = WristRotationFixSetting ;
3034 }
3135
3236 bool disablePropertyChanged = false ;
33- private async void FreeOffset_PropertyChanged ( object sender , System . ComponentModel . PropertyChangedEventArgs e )
37+ private async void CalibrationSetting_PropertyChanged ( object sender , System . ComponentModel . PropertyChangedEventArgs e )
3438 {
3539 if ( disablePropertyChanged ) return ;
3640 await Globals . Client ? . SendCommandAsync ( CalibrationSetting . ConvertToPipeCommands ( ) ) ;
3741 }
3842
43+ private async void WristRotationFixSetting_PropertyChanged ( object sender , System . ComponentModel . PropertyChangedEventArgs e )
44+ {
45+ if ( disablePropertyChanged ) return ;
46+ await Globals . Client ? . SendCommandAsync ( WristRotationFixSetting . ConvertToPipeCommands ( ) ) ;
47+ }
48+
3949 private async void Window_Loaded ( object sender , RoutedEventArgs e )
4050 {
51+ // CalibrationSetting読み込み
4152 await Globals . Client . SendCommandWaitAsync ( new PipeCommands . GetCalibrationSetting ( ) , d =>
4253 {
4354 var ret = ( PipeCommands . SetCalibrationSetting ) d ;
@@ -47,14 +58,29 @@ await Globals.Client.SendCommandWaitAsync(new PipeCommands.GetCalibrationSetting
4758 disablePropertyChanged = false ;
4859 } ) ;
4960 } ) ;
50- CalibrationSetting . PropertyChanged += FreeOffset_PropertyChanged ;
61+
62+ // WristRotationFixSetting読み込み
63+ await Globals . Client . SendCommandWaitAsync ( new PipeCommands . GetWristRotationFixSetting ( ) , d =>
64+ {
65+ var ret = ( PipeCommands . SetWristRotationFixSetting ) d ;
66+ Dispatcher . Invoke ( ( ) => {
67+ disablePropertyChanged = true ;
68+ WristRotationFixSetting . SetFromPipeCommands ( ret ) ;
69+ disablePropertyChanged = false ;
70+ } ) ;
71+ } ) ;
72+
73+ CalibrationSetting . PropertyChanged += CalibrationSetting_PropertyChanged ;
74+ WristRotationFixSetting . PropertyChanged += WristRotationFixSetting_PropertyChanged ;
5175 }
5276
5377 private void Window_Unloaded ( object sender , RoutedEventArgs e )
5478 {
55- CalibrationSetting . PropertyChanged -= FreeOffset_PropertyChanged ;
79+ CalibrationSetting . PropertyChanged -= CalibrationSetting_PropertyChanged ;
80+ WristRotationFixSetting . PropertyChanged -= WristRotationFixSetting_PropertyChanged ;
5681 }
5782 }
83+
5884 public class CalibrationSettingItem : ViewModelBase
5985 {
6086 public bool EnableOverrideBodyHeight { get => Getter < bool > ( ) ; set => Setter ( value ) ; }
@@ -88,4 +114,50 @@ public void SetFromPipeCommands(PipeCommands.SetCalibrationSetting CalibrationSe
88114 PelvisOffsetAdjustZ = CalibrationSetting . PelvisOffsetAdjustZ ;
89115 }
90116 }
117+
118+ public class WristRotationFixSettingItem : ViewModelBase
119+ {
120+ public int UpperArmWeight { get => Getter < int > ( ) ; set => Setter ( value ) ; }
121+ public int ForearmWeight { get => Getter < int > ( ) ; set => Setter ( value ) ; }
122+ public int SmoothingTime { get => Getter < int > ( ) ; set => Setter ( value ) ; }
123+ public int MaxAccumulatedTwist { get => Getter < int > ( ) ; set => Setter ( value ) ; }
124+
125+ public float UpperArmWeightPercent
126+ {
127+ get => Getter < float > ( ) ;
128+ set { UpperArmWeight = Convert . ToInt32 ( value * 10 ) ; Setter ( value ) ; }
129+ }
130+ public float ForearmWeightPercent
131+ {
132+ get => Getter < float > ( ) ;
133+ set { ForearmWeight = Convert . ToInt32 ( value * 10 ) ; Setter ( value ) ; }
134+ }
135+ public float SmoothingTimeSeconds
136+ {
137+ get => Getter < float > ( ) ;
138+ set { SmoothingTime = Convert . ToInt32 ( value * 1000 ) ; Setter ( value ) ; }
139+ }
140+
141+ public PipeCommands . SetWristRotationFixSetting ConvertToPipeCommands ( )
142+ {
143+ return new PipeCommands . SetWristRotationFixSetting
144+ {
145+ UpperArmWeight = UpperArmWeight ,
146+ ForearmWeight = ForearmWeight ,
147+ SmoothingTime = SmoothingTime ,
148+ MaxAccumulatedTwist = MaxAccumulatedTwist ,
149+ } ;
150+ }
151+
152+ public void SetFromPipeCommands ( PipeCommands . SetWristRotationFixSetting WristRotationFixSetting )
153+ {
154+ UpperArmWeightPercent = WristRotationFixSetting . UpperArmWeight / 10f ;
155+ ForearmWeightPercent = WristRotationFixSetting . ForearmWeight / 10f ;
156+ SmoothingTimeSeconds = WristRotationFixSetting . SmoothingTime / 1000f ;
157+ MaxAccumulatedTwist = WristRotationFixSetting . MaxAccumulatedTwist ;
158+ UpperArmWeight = WristRotationFixSetting . UpperArmWeight ;
159+ ForearmWeight = WristRotationFixSetting . ForearmWeight ;
160+ SmoothingTime = WristRotationFixSetting . SmoothingTime ;
161+ }
162+ }
91163}
0 commit comments