aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml
blob: 9bb995bd88eba7f07c5e26801312d6a6b0f5c076 (plain)
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
<UserControl x:Class="Tango.MachineStudio.Synchronization.Views.RemoteSynchronizationView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:providers="clr-namespace:Tango.MachineStudio.Synchronization.AutoComplete"
             xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:synchronization="clr-namespace:Tango.Synchronization;assembly=Tango.Synchronization"
             xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
             xmlns:global="clr-namespace:Tango.MachineStudio.Synchronization"
             
             xmlns:local="clr-namespace:Tango.MachineStudio.Synchronization.Views"
             xmlns:fa="http://schemas.fontawesome.io/icons/"
             mc:Ignorable="d" 
             d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.RemoteSynchronizationViewVM}">
    <UserControl.Resources>

        <providers:MachinesProvider x:Key="MachinesProvider"></providers:MachinesProvider>
        
        <VisualBrush x:Key="badgeBackground">
            <VisualBrush.Visual>
                <Border>
                    <Path Stretch="Fill" RenderTransformOrigin="0.5,0.5">
                        <Path.RenderTransform>
                            <ScaleTransform ScaleX="-1"></ScaleTransform>
                        </Path.RenderTransform>
                        <Path.Fill>
                            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                <GradientStop Color="#EEEEEE" Offset="0.4" />
                                <GradientStop Color="White" Offset="1"/>
                            </LinearGradientBrush>
                        </Path.Fill>
                        <Path.Data>
                            <PathGeometry Figures="M 53.868 43.913 H 19.511 c -0.444 0 -0.875 -0.151 -1.221 -0.428 L 0.734 29.439 c -0.978 -0.783 -0.978 -2.271 0 -3.053 L 18.29 12.341 c 0.347 -0.277 0.777 -0.428 1.221 -0.428 h 34.356 c 1.081 0 1.958 0.877 1.958 1.958 v 28.084 c 0 1.081 -0.876 1.958 -1.957 1.958 z" FillRule="NonZero"/>
                        </Path.Data>
                    </Path>
                </Border>
            </VisualBrush.Visual>
        </VisualBrush>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid>
            <StackPanel Orientation="Horizontal" Margin="20">
                <Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Margin="0 5 0 0" VerticalAlignment="Center" Command="{Binding BackCommand}">
                    <materialDesign:PackIcon Kind="ArrowLeft" Foreground="#303030" ToolTip="Back" VerticalAlignment="Center" Width="40" Height="40"></materialDesign:PackIcon>
                </Button>
                <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="30">Local Database Synchronization</TextBlock>
            </StackPanel>
        </Grid>
        <Grid Grid.Row="1">
            <Grid Margin="20">
                <GroupBox Header="Compare &amp; Synchronize">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="57*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MaxWidth="250" />
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>

                            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Margin="20 0 0 0">
                                <Image Source="../Images/remote-db.png"  Width="100" Margin="10" Opacity="0.8" HorizontalAlignment="Left" RenderOptions.BitmapScalingMode="Fant"></Image>
                                <TextBlock Background="{StaticResource badgeBackground}" Padding="5" Width="200" FontSize="14" HorizontalAlignment="Left">Remote Database</TextBlock>
                                <StackPanel Orientation="Horizontal" Margin="0 5 0 0">
                                    <fa:ImageAwesome Icon="Key" Width="16" Height="16"></fa:ImageAwesome>
                                    <autoComplete:AutoCompleteTextBox Margin="5 0 0 0" Width="170" materialDesign:HintAssist.Hint="Enter machine serial number" DisplayMember="SerialNumber" Provider="{StaticResource ResourceKey=MachinesProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                                        <autoComplete:AutoCompleteTextBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding SerialNumber}"></TextBlock>
                                            </DataTemplate>
                                        </autoComplete:AutoCompleteTextBox.ItemTemplate>
                                        <autoComplete:AutoCompleteTextBox.LoadingContent>
                                            <TextBlock Text="Loading..." Margin="5" FontSize="14" />
                                        </autoComplete:AutoCompleteTextBox.LoadingContent>
                                    </autoComplete:AutoCompleteTextBox>
                                </StackPanel>
                            </StackPanel>

                            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="1" Margin="20 0 0 0">
                                <Image Source="../Images/sqlite.png"  Width="80" Margin="10" Opacity="0.8" HorizontalAlignment="Left" RenderOptions.BitmapScalingMode="Fant"></Image>
                                <TextBlock Background="{StaticResource badgeBackground}" Padding="5" Width="200" FontSize="14" HorizontalAlignment="Left">SQLite Database</TextBlock>
                                <StackPanel Orientation="Horizontal" Margin="0 5 0 0">
                                    <TextBox IsReadOnly="True" Width="130" BorderBrush="#4E4E4E" Text="{Binding SlaveDBName}" ToolTip="{Binding SlaveDBFile}"></TextBox>
                                    <Button Margin="5 0 0 0" Cursor="Hand" VerticalAlignment="Center" Style="{DynamicResource MetroCircleButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding BrowseSlaveDBCommand}" ToolTip="Browse for slave database file">
                                        <fa:ImageAwesome Icon="FolderOpen" Width="24" Foreground="Gray"></fa:ImageAwesome>
                                    </Button>
                                </StackPanel>
                            </StackPanel>
                        </Grid>

                        <Button Margin="20 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Left" Command="{Binding CompareCommand}">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMPARE</TextBlock>
                                <fa:ImageAwesome Icon="LongArrowRight" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
                            </StackPanel>
                        </Button>

                        <Grid Grid.Column="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="205*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Margin="10 5 0 0" FontSize="14">Differences</TextBlock>
                            <ListBox Margin="10" Background="#F1F1F1" Grid.Row="1" ItemsSource="{Binding Differences}" SelectedItem="{Binding SelectedDifference,Mode=TwoWay}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Border Padding="10">
                                            <StackPanel Orientation="Horizontal">
                                                <fa:ImageAwesome Icon="Cog" Width="20" Height="20" Foreground="Gray"></fa:ImageAwesome>
                                                <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Text="{Binding Description}">
                                                    <TextBlock.Style>
                                                        <Style TargetType="TextBlock">
                                                            <Setter Property="Foreground" Value="Red"></Setter>
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding Action}" Value="ReplaceTableDataInSlave">
                                                                    <Setter Property="Foreground" Value="#404040"></Setter>
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </TextBlock.Style>
                                                </TextBlock>
                                            </StackPanel>
                                        </Border>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Grid>

                        <Grid Grid.Row="1" Grid.Column="1">
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                                <Button Margin="10 10" Grid.Row="1" Width="240" Height="40" Background="#FF4F4F" BorderBrush="#FF4F4F" HorizontalAlignment="Right" Command="{Binding CleanCommand}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">CLEAN SQLITE DATABASE</TextBlock>
                                        <fa:ImageAwesome Icon="TrashOutline" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
                                    </StackPanel>
                                </Button>
                                <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitCommand}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT</TextBlock>
                                        <fa:ImageAwesome Icon="Bolt" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
                                    </StackPanel>
                                </Button>
                                <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitAllCommand}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT ALL</TextBlock>
                                        <fa:ImageAwesome Icon="SortAmountAsc" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
                                    </StackPanel>
                                </Button>
                            </StackPanel>
                        </Grid>
                    </Grid>
                </GroupBox>
            </Grid>

          
        </Grid>
    </Grid>
</UserControl>
pan>Motor_i].pulleyradius = request->pulleyradius; MotorsCfg[Motor_i].configword = request->configword; if(MotorDriverResponse[Motor_i].DriverType == CombinrdMotDriver) { MotorsCfg[Motor_i].directionthreadwize = request->directionthreadwize ^ 1;//PowerSTEP01 } else { MotorsCfg[Motor_i].directionthreadwize = request->directionthreadwize;//L6470 + L6472 } MotorsCfg[Motor_i].kvalhold = request->kvalhold; MotorsCfg[Motor_i].kvalrun = request->kvalrun; MotorsCfg[Motor_i].kvalacc = request->kvalacc; MotorsCfg[Motor_i].kvaldec = request->kvaldec; MotorsCfg[Motor_i].overcurrentthreshold = request->overcurrentthreshold; MotorsCfg[Motor_i].stallthreshold = request->stallthreshold; MotorsCfg[Motor_i].thermalcompensationfactor = request->thermalcompensationfactor; MotorsCfg[Motor_i].lowspeedoptimization = request->lowspeedoptimization; MotorsCfg[Motor_i].stslp = request->stslp; MotorsCfg[Motor_i].intspd = request->intspd; MotorsCfg[Motor_i].fnslpacc = request->fnslpacc; MotorsCfg[Motor_i].fnslpdec = request->fnslpdec; MotorsCfg[Motor_i].fsspd = request->fsspd; MotorsCfg[Motor_i].gatecfg1 = request->gatecfg1; MotorsCfg[Motor_i].gatecfg2 = request->gatecfg2; MotorsCfg[Motor_i].tvalhold = request->tvalhold; MotorsCfg[Motor_i].tvalrun = request->tvalrun ; MotorsCfg[Motor_i].tvalacc = request->tvalacc ; MotorsCfg[Motor_i].tvaldec = request->tvaldec ; MotorsCfg[Motor_i].tfast = request->tfast ; MotorsCfg[Motor_i].tonmin = request->tonmin ; MotorsCfg[Motor_i].toffmin = request->toffmin ; status = MotorConfig( Motor_i, &MotorsCfg[Motor_i]); if ((Motor_i >= HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1)&&(Motor_i <= HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_8)) { IDS_Dispenser_Init(Motor_i-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1); } // if (Motor_i == MOTOR_RDRIVING) // ThreadInitialTestStub(request); } return status; } uint32_t MotorPidRequestMessage(HardwarePidControl* request) { int Motor_i,i; int temp; for (i=0;i<MAX_THREAD_MOTORS_NUM;i++) { if (ThreadMotorIdToControlId[i] == request->hardwarepidcontroltype) { Motor_i = i; break; } } memcpy (&MotorsControl[Motor_i],request,sizeof(HardwarePidControl)); if (MotorsControl[Motor_i].pvinputfilterfactormode > MAX_CONTROL_SAMPLES) MotorsControl[Motor_i].pvinputfilterfactormode = MAX_CONTROL_SAMPLES; #ifdef TEST_LONGER_PID_THREAD MotorsControl[Motor_i].pvinputfilterfactormode = 10; //test longer control #endif for (i = 0;i < (int)MotorsControl[Motor_i].pvinputfilterfactormode; i++) { MotorSamples[Motor_i][i] = 0; //reset the samples value for control beginning MotorSpeedSamples[Motor_i][i] = 0; } NormalizedErrorCoEfficient[Motor_i] = (2*PI*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].armlength); temp = 1<<(DancersCfg[ThreadMotorIdToDancerId[Motor_i]].resolutionbits); temp=(NORMAL_COEF_DIVIDER*(temp-1)*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].maximalmovementmm); NormalizedErrorCoEfficient[Motor_i] = NormalizedErrorCoEfficient[Motor_i] / temp; // uint32_t MotorSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES]; temp = 1<<(DancersCfg[ThreadMotorIdToDancerId[Motor_i]].resolutionbits); temp = (temp*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].maximalmovementmm*3/2); DancerStopActivityLimit[Motor_i] = temp/(2*PI*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].armlength); return OK; } char DancerConfigPath[50] = "0://SysInfo//DancCfg.cfg"; uint32_t StoreDancerConfigMessage() { uint32_t status = OK; // FRESULT Fresult = FR_OK; HardwareConfiguration DancerConfig; HardwareDancer Dancers[MAX_SYSTEM_DANCERS]; // uint8_t* response_buffer; // size_t response_size = 0; int Dancer_i; hardware_configuration__init(&DancerConfig); DancerConfig.dancers = (HardwareDancer**)my_malloc(sizeof(HardwareDancer*)*MAX_SYSTEM_DANCERS); for (Dancer_i = 0; Dancer_i < MAX_SYSTEM_DANCERS; Dancer_i++) { hardware_dancer__init(&Dancers[Dancer_i]); DancerConfig.dancers[Dancer_i] = &Dancers[Dancer_i]; Dancers[Dancer_i].has_zeropoint = true; Dancers[Dancer_i].hardwaredancertype = Dancer_i; Dancers[Dancer_i].has_hardwaredancertype = true; DancerConfig.dancers[Dancer_i]->zeropoint=Control_Read_Dancer_Position(Dancer_i,0,0); DancerConfig.n_dancers++; DancersCfg[Dancer_i].zeropoint = DancerConfig.dancers[Dancer_i]->zeropoint; } status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_0,DancersCfg[0].zeropoint); status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_1,DancersCfg[1].zeropoint); status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_2,DancersCfg[2].zeropoint); Report("~~~~~~Store eeprom 0",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg[1].zeropoint,RpWarning,(int)DancersCfg[2].zeropoint,0); /* response_buffer = my_malloc(hardware_configuration__get_packed_size(&DancerConfig)); if (response_buffer) { response_size = hardware_configuration__pack(&DancerConfig, response_buffer); } Fresult = FileWrite(response_buffer,response_size,DancerConfigPath,BIOS_WAIT_FOREVER); EraseFlashSection(DANCERS_MAP_IN_FLASH,1024); for (Dancer_i = 0; Dancer_i < MAX_SYSTEM_DANCERS; Dancer_i++) { ReadAppAndProgram(DANCERS_MAP_IN_FLASH, sizeof(Dancers), Dancers); } my_free(response_buffer); */ return status; } uint32_t LoadDancerConfigMessage() { uint32_t status = OK; MCU_E2PromRead(EEPROM_STORAGE_DANCER_0,&DancersCfg[0].zeropoint); MCU_E2PromRead(EEPROM_STORAGE_DANCER_1,&DancersCfg[1].zeropoint); MCU_E2PromRead(EEPROM_STORAGE_DANCER_2,&DancersCfg[2].zeropoint); status |= Report("Dancer 0 Store data eeprom ",__FILE__,__LINE__,0,RpWarning,(int)DancersCfg[0].zeropoint,0); status |= Report("Dancer 1 Store data eeprom ",__FILE__,__LINE__,1,RpWarning,(int)DancersCfg[1].zeropoint,0); status |= Report("Dancer 2 Store data eeprom ",__FILE__,__LINE__,2,RpWarning,(int)DancersCfg[2].zeropoint,0); return status; } uint32_t DancerConfigMessage(HardwareDancer * request) { uint32_t status = PASSED; int Dancer_i; Dancer_i = request->hardwaredancertype; if (Dancer_i<MAX_SYSTEM_DANCERS ) { memcpy (&DancersCfg[Dancer_i],request,sizeof(HardwareDancer)); return status; } else return Dancer_i; } uint32_t ThreadConfigBreakSensor(void *request) { HardwareBreakSensor *SensorCfg = (HardwareBreakSensor*)request; if (SensorCfg) { BreakSensorenabled = SensorCfg->enabled; if (SensorCfg->debouncetimemilli) { BreakSensordebouncetimemilli = SensorCfg->debouncetimemilli; } return OK; } return ERROR; } uint32_t thread_init(void) { //memset (MotorsCfg,0,sizeof(MotorsCfg)); //memset (&InternalWinderCfg,0,sizeof(InternalWinderConfigStruc)); return OK; } void ThreadSetBreakSensorLimit(int limit) { if (limit) BreakSensordebouncetimemilli = limit; }