Sonjiwon 3 лет назад
Родитель
Сommit
1279050149

+ 0 - 3
InkjetScale/InkjetScale.Common/Enums.cs

@@ -9,10 +9,7 @@ namespace InkjetScale.Common
     public enum eCommand
     public enum eCommand
     {
     {
         S, //안정적인 값 받기
         S, //안정적인 값 받기
-        SI, //안정화 여부 상관없이 무게 출력
-        SIR,  //안정적인 값 계속 받기(근데 계속 안줌)
         Z, //영점 잡기(한 번에 잘 안 잡힘)
         Z, //영점 잡기(한 번에 잘 안 잡힘)
-        ZI, //즉각적인 ZERO 적용
         T, //Tare
         T, //Tare
         C, //모든 Command 취소
         C, //모든 Command 취소
 
 

+ 1 - 0
InkjetScale/InkjetScale.Common/Events/PubSubEvents.cs

@@ -9,4 +9,5 @@ namespace InkjetScale.Common.Events
 {
 {
     public class SerialConnectEvent : PubSubEvent<SerialEventArgs> { };
     public class SerialConnectEvent : PubSubEvent<SerialEventArgs> { };
     public class ViewLogEvent : PubSubEvent<ViewLogArgs> { };
     public class ViewLogEvent : PubSubEvent<ViewLogArgs> { };
+    public class SystemExitEvent : PubSubEvent<bool> { };
 }
 }

+ 17 - 0
InkjetScale/InkjetScale.GUI.LogViews/InkjetScale.GUI.LogViews.csproj

@@ -32,6 +32,15 @@
     <ErrorReport>prompt</ErrorReport>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Remote_LAB|AnyCPU'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\Remote_LAB\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <LangVersion>7.3</LangVersion>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
     <Reference Include="MaterialDesignColors, Version=2.0.6.0, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
     <Reference Include="MaterialDesignColors, Version=2.0.6.0, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
       <HintPath>..\packages\MaterialDesignColors.2.0.6\lib\net452\MaterialDesignColors.dll</HintPath>
       <HintPath>..\packages\MaterialDesignColors.2.0.6\lib\net452\MaterialDesignColors.dll</HintPath>
@@ -80,12 +89,20 @@
   <ItemGroup>
   <ItemGroup>
     <Compile Include="LogViewModule.cs" />
     <Compile Include="LogViewModule.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Views\RegisteredWeightView.xaml.cs">
+      <DependentUpon>RegisteredWeightView.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\RegisteredWeightViewModel.cs" />
     <Compile Include="Views\ScaleLogView.xaml.cs">
     <Compile Include="Views\ScaleLogView.xaml.cs">
       <DependentUpon>ScaleLogView.xaml</DependentUpon>
       <DependentUpon>ScaleLogView.xaml</DependentUpon>
     </Compile>
     </Compile>
     <Compile Include="Views\ScaleLogViewModel.cs" />
     <Compile Include="Views\ScaleLogViewModel.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <Page Include="Views\RegisteredWeightView.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\ScaleLogView.xaml">
     <Page Include="Views\ScaleLogView.xaml">
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>

+ 12 - 0
InkjetScale/InkjetScale.GUI.LogViews/Views/RegisteredWeightView.xaml

@@ -0,0 +1,12 @@
+<UserControl x:Class="InkjetScale.GUI.LogViews.Views.RegisteredWeightView"
+             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:local="clr-namespace:InkjetScale.GUI.LogViews.Views"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+            
+    </Grid>
+</UserControl>

+ 28 - 0
InkjetScale/InkjetScale.GUI.LogViews/Views/RegisteredWeightView.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace InkjetScale.GUI.LogViews.Views
+{
+    /// <summary>
+    /// RegisteredWeightView.xaml에 대한 상호 작용 논리
+    /// </summary>
+    public partial class RegisteredWeightView : UserControl
+    {
+        public RegisteredWeightView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 12 - 0
InkjetScale/InkjetScale.GUI.LogViews/Views/RegisteredWeightViewModel.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace InkjetScale.GUI.LogViews.Views
+{
+    internal class RegisteredWeightViewModel
+    {
+    }
+}

+ 3 - 3
InkjetScale/InkjetScale.GUI.LogViews/Views/ScaleLogView.xaml

@@ -31,11 +31,11 @@
                 <DataGrid Margin="0 8 0 0" ItemsSource="{Binding MeasurementList}" CanUserSortColumns="True" CanUserAddRows="False" AutoGenerateColumns="False" 
                 <DataGrid Margin="0 8 0 0" ItemsSource="{Binding MeasurementList}" CanUserSortColumns="True" CanUserAddRows="False" AutoGenerateColumns="False" 
                                       materialDesign:DataGridAssist.CellPadding="13 8 8 8" materialDesign:DataGridAssist.ColumnHeaderPadding="8" IsReadOnly="True" Background="LightBlue">
                                       materialDesign:DataGridAssist.CellPadding="13 8 8 8" materialDesign:DataGridAssist.ColumnHeaderPadding="8" IsReadOnly="True" Background="LightBlue">
                     <DataGrid.Columns>
                     <DataGrid.Columns>
-                        <DataGridTextColumn Binding="{Binding Head}" Header="  Head" Width="*" FontSize="10"
+                        <DataGridTextColumn Binding="{Binding Head}" Header="  Head" Width="*" FontSize="13"
                                             EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
                                             EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
-                        <DataGridTextColumn Binding="{Binding Weight}" Header="  Weight" FontSize="10"
+                        <DataGridTextColumn Binding="{Binding Weight}" Header="  Weight(mg)" FontSize="13"
                                         EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" Width="*" />
                                         EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" Width="*" />
-                        <DataGridTextColumn Binding="{Binding pl}" Header="  pl" Width="*" FontSize="10"
+                        <DataGridTextColumn Binding="{Binding pl}" Header="  pl" Width="*" FontSize="13"
                                             EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
                                             EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
                     </DataGrid.Columns>
                     </DataGrid.Columns>
                 </DataGrid>
                 </DataGrid>

+ 1 - 2
InkjetScale/InkjetScale.GUI.LogViews/Views/ScaleLogViewModel.cs

@@ -1,5 +1,4 @@
 using InkjetScale.Common.Events;
 using InkjetScale.Common.Events;
-using InkjetScale.Common.Model;
 using Prism.Commands;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Mvvm;
@@ -27,7 +26,7 @@ namespace InkjetScale.GUI.LogViews.Views
             this.eventAggregator = eventAggregator;
             this.eventAggregator = eventAggregator;
 
 
             MeasurementList = new ObservableCollection<ViewLogArgs>();
             MeasurementList = new ObservableCollection<ViewLogArgs>();
-            this.eventAggregator.GetEvent<ViewLogEvent>().Subscribe(ViewLogSubEvent);
+            this.eventAggregator.GetEvent<ViewLogEvent>().Subscribe(ViewLogSubEvent, ThreadOption.UIThread);
         }
         }
 
 
         private void ExecuteClear()
         private void ExecuteClear()

+ 121 - 88
InkjetScale/InkjetScale.GUI.MainViews/Views/ScaleMainView.xaml

@@ -34,134 +34,119 @@
                 <ContentControl Content="{Binding ControlView}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5"/>
                 <ContentControl Content="{Binding ControlView}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5"/>
             </Grid>
             </Grid>
 
 
-            <Grid Grid.Row="1">
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="1.5*"/>
-                    <RowDefinition Height="*"/>
-                </Grid.RowDefinitions>
 
 
-                <Grid Grid.Row="0">
-
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition/>
-                        <ColumnDefinition/>
-                    </Grid.ColumnDefinitions>
-
-                    <Grid Grid.Column="0">
+        </Grid>
 
 
-                        <Border BorderBrush="#0075ce" CornerRadius="5" BorderThickness="2" Margin="5"  >
-                            <materialDesign:Card Background="LightBlue" Foreground="{DynamicResource PrimaryHueLightForegroundBrush}" Padding="8">
-                                <Grid>
+        <Grid Grid.Column="1">
 
 
-                                    <Grid.RowDefinitions>
-                                        <RowDefinition Height="*"/>
-                                        <RowDefinition Height="6"/>
-                                        <RowDefinition Height="*"/>
-                                    </Grid.RowDefinitions>
 
 
-                                    <Grid Grid.Row="0">
-                                        <TextBlock Text="Head" FontSize="25" Foreground="Black" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                    </Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition/>
+                <ColumnDefinition/>
+            </Grid.ColumnDefinitions>
 
 
-                                    <Separator Grid.Row="1"/>
+            <Grid Grid.Column="0">
 
 
-                                    <Grid Grid.Row="2">
-                                        <ComboBox ItemsSource="{Binding HeadList}" SelectedItem="{Binding SelectedHead}" FontSize="25" Width="auto" HorizontalAlignment="Center"/>
-                                    </Grid>
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="*"/>
+                    <RowDefinition Height="0.5*"/>
+                    <RowDefinition Height="*"/>
+                    <RowDefinition Height="*"/>
+                    <RowDefinition Height="*"/>
+                    <RowDefinition Height="0.5*"/>
+                </Grid.RowDefinitions>
 
 
+                <Grid Grid.Row="0">
+                    <Border BorderBrush="#0075ce" CornerRadius="5" BorderThickness="2" Margin="5"  >
+                        <materialDesign:Card Background="LightBlue" Foreground="{DynamicResource PrimaryHueLightForegroundBrush}" Padding="8">
+                            <Grid>
+
+                                <Grid.RowDefinitions>
+                                    <RowDefinition Height="*"/>
+                                    <RowDefinition Height="6"/>
+                                    <RowDefinition Height="*"/>
+                                </Grid.RowDefinitions>
+
+                                <Grid Grid.Row="0">
+                                    <TextBlock Text="Head" FontSize="25" Foreground="Black" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                 </Grid>
                                 </Grid>
-                            </materialDesign:Card>
-                        </Border>
-                    </Grid>
-
-                    <Grid Grid.Column="1">
 
 
-                        <Border BorderBrush="#0075ce" CornerRadius="5" BorderThickness="2" Margin="5" >
-                            <materialDesign:Card Background="LightBlue" Foreground="{DynamicResource PrimaryHueLightForegroundBrush}" Padding="8">
-                                <Grid>
-
-                                    <Grid.RowDefinitions>
-                                        <RowDefinition Height="*"/>
-                                        <RowDefinition Height="6"/>
-                                        <RowDefinition Height="*"/>
-                                    </Grid.RowDefinitions>
-
-                                    <Grid Grid.Row="0">
-                                        <Button Style="{StaticResource MaterialDesignRaisedButton}" Command="{Binding SendCommand}"  
-                                                HorizontalAlignment="Center" VerticalAlignment="Center" Background="{x:Null}" BorderThickness="0" >
-                                            <TextBlock Text="Command" FontSize="25" Foreground="Black" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Button>
-                                    </Grid>
-
-                                    <Separator Grid.Row="1"/>
-
-                                    <Grid Grid.Row="2">
-                                        <ComboBox ItemsSource="{Binding CommandList}" SelectedItem="{Binding SelectedCommand}" FontSize="25" Width="auto" HorizontalAlignment="Center"/>
-                                    </Grid>
+                                <Separator Grid.Row="1"/>
 
 
+                                <Grid Grid.Row="2">
+                                    <ComboBox ItemsSource="{Binding HeadList}" SelectedItem="{Binding SelectedHead}" FontSize="25" Width="auto" HorizontalAlignment="Center"/>
                                 </Grid>
                                 </Grid>
-                                
-                            </materialDesign:Card>
-                            
-                        </Border>
-                        
-                    </Grid>
 
 
+                            </Grid>
+                        </materialDesign:Card>
+                    </Border>
                 </Grid>
                 </Grid>
 
 
                 <Grid Grid.Row="1">
                 <Grid Grid.Row="1">
 
 
-                    
-                    
+                    <Border CornerRadius="10" Background="LightBlue" BorderBrush="#0075ce" Padding="5" BorderThickness="2" Margin="5">
 
 
-                </Grid>
-                
-            </Grid>
+                        <Grid>
 
 
-        </Grid>
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition/>
+                                <ColumnDefinition/>
+                            </Grid.ColumnDefinitions>
 
 
-        <Grid Grid.Column="1">
+                            <Grid Grid.Row="0" Grid.Column="0">
+                                <TextBlock Text="Drop Count" Foreground="Black" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center" />
+                            </Grid>
 
 
+                            <Grid Grid.Row="0" Grid.Column="1">
+                                <TextBox Text="{Binding DropCount, FallbackValue=2000}" Foreground="Black" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center" />
+                            </Grid>
 
 
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition/>
-                <ColumnDefinition/>
-            </Grid.ColumnDefinitions>
+                        </Grid>
 
 
-            <Grid Grid.Column="0">
+                    </Border>
 
 
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="*"/>
-                    <RowDefinition Height="*"/>
-                    <RowDefinition Height="3*"/>
-                </Grid.RowDefinitions>
+                </Grid>
 
 
-                <Grid Grid.Row="0" >
+                <Grid Grid.Row="2" >
 
 
                     <Border CornerRadius="10" Background="LightBlue" BorderBrush="#0075ce" Padding="5" BorderThickness="2" Margin="5">
                     <Border CornerRadius="10" Background="LightBlue" BorderBrush="#0075ce" Padding="5" BorderThickness="2" Margin="5">
                         
                         
                         <Grid>
                         <Grid>
                             
                             
                             <Grid.RowDefinitions>
                             <Grid.RowDefinitions>
-                                <RowDefinition/>
-                                <RowDefinition/>
+                                <RowDefinition Height="*"/>
+                                <RowDefinition Height="*"/>
                             </Grid.RowDefinitions>
                             </Grid.RowDefinitions>
 
 
                             <Grid Grid.Row="0">
                             <Grid Grid.Row="0">
+                                                                
                                 <Grid.ColumnDefinitions>
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition/>
                                     <ColumnDefinition/>
                                     <ColumnDefinition/>
                                     <ColumnDefinition/>
+                                    <ColumnDefinition/>
                                 </Grid.ColumnDefinitions>
                                 </Grid.ColumnDefinitions>
 
 
-                                <Grid Grid.Column="0">
-                                    <Button Style="{StaticResource MaterialDesignRaisedButton}" Content="Zero" Command="{Binding RunCommand}" CommandParameter="Z"
-                                HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="100"/>
+
+                                <Grid Grid.Column="0" Grid.Row ="0">
+                                    <!--<Button Style="{StaticResource MaterialDesignRaisedButton}" Content="Zero" Command="{Binding RunCommand}" CommandParameter="Z"
+                                            HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="100"/>-->
+                                    <Button Style="{StaticResource MaterialDesignRaisedButton}" Content="Reset" Command="{Binding RunCommand}" CommandParameter="C"   
+                                            HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="100"/>
                                 </Grid>
                                 </Grid>
 
 
-                                <Grid Grid.Column="1">
+                                <Grid Grid.Column="1" Grid.Row ="0">
                                     <Button Style="{StaticResource MaterialDesignRaisedButton}" Content="Measure" Command="{Binding RunCommand}" CommandParameter="S"   
                                     <Button Style="{StaticResource MaterialDesignRaisedButton}" Content="Measure" Command="{Binding RunCommand}" CommandParameter="S"   
-                                HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="100"/>
+                                            HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="100"/>
+                                </Grid>
+
+                                <Grid Grid.Column="2" Grid.Row ="0">
+                                    <Button Style="{StaticResource MaterialDesignRaisedButton}" Content="Zero(T)" Command="{Binding RunCommand}" CommandParameter="T"   
+                                            HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="100"/>
+                                </Grid>
+
+                                <Grid Grid.Column="2" Grid.Row ="1">
                                 </Grid>
                                 </Grid>
+
                             </Grid>
                             </Grid>
 
 
                             <Grid Grid.Row="1">
                             <Grid Grid.Row="1">
@@ -184,8 +169,7 @@
                     
                     
                 </Grid>
                 </Grid>
 
 
-
-                <Grid Grid.Row="1" >
+                <Grid Grid.Row="3" >
 
 
                     <Border CornerRadius="10" Background="LightBlue" BorderBrush="#0075ce" Padding="5" BorderThickness="2" Margin="5">
                     <Border CornerRadius="10" Background="LightBlue" BorderBrush="#0075ce" Padding="5" BorderThickness="2" Margin="5">
 
 
@@ -231,6 +215,55 @@
 
 
                 </Grid>
                 </Grid>
 
 
+                <Grid Grid.Row="4">
+
+                    <Border CornerRadius="10" Background="LightBlue" BorderBrush="#0075ce" Padding="5" BorderThickness="2" Margin="5">
+
+                        <Grid>
+
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition/>
+                                <ColumnDefinition/>
+                            </Grid.ColumnDefinitions>
+
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="*"/>
+                                <RowDefinition Height="*"/>
+                            </Grid.RowDefinitions>
+
+                            <Grid Grid.Row="0" Grid.Column="0">
+                                <TextBlock Text="Tare(mg)" Foreground="Black" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center" />
+                            </Grid>
+
+                            <Grid Grid.Row="0" Grid.Column="1">
+                                <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
+                                    <materialDesign:PackIcon Kind="Brightness1" Width="25" Height="35" Foreground="LimeGreen"  
+                                                 Visibility="{c:Binding IsTareStable , Converter={StaticResource BooleanToVisibilityConverter}}" />
+                                    <materialDesign:PackIcon Kind="Brightness1" Width="25" Height="35" Foreground="Red"
+                                                 Visibility="{c:Binding !IsTareStable , Converter={StaticResource BooleanToVisibilityConverter}}"/>
+                                </StackPanel>
+                                <TextBlock Text="{Binding TareWeight, FallbackValue=0.00}" Foreground="Black" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center" />
+                            </Grid>
+
+                            <Grid Grid.Row="1" Grid.Column="0">
+
+                                <TextBlock Grid.Column="0" Text="Receive" Foreground="Black" FontSize="20" Width="auto"
+                                   HorizontalAlignment="Center" VerticalAlignment="Center" />
+
+                            </Grid>
+
+                            <Grid Grid.Row="1" Grid.Column="1">
+                                <TextBlock Grid.Column="1" Text="{Binding TareReceiveMsg}" Foreground="Black" FontSize="20" Width="auto"
+                                   HorizontalAlignment="Center" VerticalAlignment="Center" />
+                            </Grid>
+
+                        </Grid>
+
+                    </Border>
+
+                </Grid>
+
+
             </Grid>
             </Grid>
 
 
             <Grid Grid.Column="1" Margin="5">
             <Grid Grid.Column="1" Margin="5">

+ 105 - 37
InkjetScale/InkjetScale.GUI.MainViews/Views/ScaleMainViewModel.cs

@@ -17,6 +17,7 @@ using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Windows.Input;
 using System.Windows.Input;
+using System.Windows.Threading;
 
 
 namespace InkjetScale.GUI.MainViews.Views
 namespace InkjetScale.GUI.MainViews.Views
 {
 {
@@ -24,24 +25,36 @@ namespace InkjetScale.GUI.MainViews.Views
     {
     {
         
         
         #region Property
         #region Property
-        private eCommand commandName = eCommand.S;
-        public eCommand CommandName { get => this.commandName; set => SetProperty(ref this.commandName, value); }
+        private eCommand selectedCommand;
+        public eCommand SelectedCommand { get => this.selectedCommand; set => SetProperty(ref this.selectedCommand, value); }
 
 
         private eHeadList selectedHead;
         private eHeadList selectedHead;
         public eHeadList SelectedHead { get => this.selectedHead; set => SetProperty(ref this.selectedHead, value); }
         public eHeadList SelectedHead { get => this.selectedHead; set => SetProperty(ref this.selectedHead, value); }
-
+        
         private bool isStable;
         private bool isStable;
         public bool IsStable { get => this.isStable; set => SetProperty(ref this.isStable, value); }
         public bool IsStable { get => this.isStable; set => SetProperty(ref this.isStable, value); }
 
 
+        private bool isTareStable;
+        public bool IsTareStable { get => this.isTareStable; set => SetProperty(ref this.isTareStable, value); }
+
         private string weightValue;
         private string weightValue;
         public string WeightValue { get => this.weightValue; set => SetProperty(ref this.weightValue, value); }
         public string WeightValue { get => this.weightValue; set => SetProperty(ref this.weightValue, value); }
-
+        
         private string receiveMsg;
         private string receiveMsg;
         public string ReceiveMsg { get => this.receiveMsg; set => SetProperty(ref this.receiveMsg, value); }
         public string ReceiveMsg { get => this.receiveMsg; set => SetProperty(ref this.receiveMsg, value); }
 
 
+        private string tareReceiveMsg;
+        public string TareReceiveMsg { get => this.tareReceiveMsg; set => SetProperty(ref this.tareReceiveMsg, value); }
+
         private string plValue;
         private string plValue;
         public string PlValue { get => this.plValue; set => SetProperty(ref this.plValue, value); }
         public string PlValue { get => this.plValue; set => SetProperty(ref this.plValue, value); }
 
 
+        private string tareWeight;
+        public string TareWeight { get => this.tareWeight; set => SetProperty(ref this.tareWeight, value); }
+
+        private string dropCount;
+        public string DropCount { get => this.dropCount; set => SetProperty(ref this.dropCount, value); }
+
         private ScaleControlView controlView;
         private ScaleControlView controlView;
         public ScaleControlView ControlView { get => this.controlView; set => SetProperty(ref this.controlView, value); }
         public ScaleControlView ControlView { get => this.controlView; set => SetProperty(ref this.controlView, value); }
 
 
@@ -58,12 +71,13 @@ namespace InkjetScale.GUI.MainViews.Views
 
 
         SerialPort scale = new SerialPort();
         SerialPort scale = new SerialPort();
 
 
-        public ICommand SendCommand { get; set; }
         public ICommand RunCommand { get; set; }
         public ICommand RunCommand { get; set; }
+
         IEventAggregator ea = null;
         IEventAggregator ea = null;
         IContainerProvider provider = null;
         IContainerProvider provider = null;
 
 
         string Command = null;
         string Command = null;
+        Thread scaleThread = null;
 
 
         public ScaleMainViewModel(IEventAggregator eventAggregator, IContainerProvider proVider)
         public ScaleMainViewModel(IEventAggregator eventAggregator, IContainerProvider proVider)
         {
         {
@@ -73,33 +87,51 @@ namespace InkjetScale.GUI.MainViews.Views
             this.ea = eventAggregator;
             this.ea = eventAggregator;
             this.provider = proVider;
             this.provider = proVider;
 
 
-            this.SendCommand = new DelegateCommand(ExecuteSend);
             this.RunCommand = new DelegateCommand<string>(ExecuteRun);
             this.RunCommand = new DelegateCommand<string>(ExecuteRun);
+
+            scaleThread = new Thread(GetScaleInfo);
+            this.ea.GetEvent<SystemExitEvent>().Subscribe(SystemExitSubEvent, ThreadOption.UIThread);
         }
         }
 
 
-        
+        private void SystemExitSubEvent(bool isExit)
+        {
+            if (isExit)
+            {
+                isThreadUse = false;
+                scale.Close();
+                scaleThread.Join();
+            }
+        }
 
 
-        #region Execute
-        private void ExecuteSend()
+        bool isThreadUse = true;
+        private void GetScaleInfo()
         {
         {
-            if (!scale.IsOpen)
-                return;
-            if (SelectedHead < 0)
-                return;
+            while(scale.IsOpen)
+            {
+                Thread.Sleep(500);
+                if (!isThreadUse)
+                    continue;
+                else
+                {
+                    Command = "S";
+                    scale.Write(Command + Environment.NewLine);
+                }
 
 
-            Command = CommandName.ToString();            
-            scale.Write(Command + Environment.NewLine);
+            }
         }
         }
 
 
+        #region Execute
+
         private void ExecuteRun(string command)
         private void ExecuteRun(string command)
         {
         {
             if (!scale.IsOpen)
             if (!scale.IsOpen)
                 return;
                 return;
-            if (SelectedHead < 0)
-                return;
+
+            if (scaleThread.IsAlive)
+                isThreadUse = false;
 
 
             if (command != null)
             if (command != null)
-            {
+            {                
                 Command = command;
                 Command = command;
                 scale.Write(Command + Environment.NewLine); // command 보낼 때 \r\n 또는 Environment.NesLine 붙여서 보내야함
                 scale.Write(Command + Environment.NewLine); // command 보낼 때 \r\n 또는 Environment.NesLine 붙여서 보내야함
             }
             }
@@ -114,7 +146,7 @@ namespace InkjetScale.GUI.MainViews.Views
         {
         {
             if(!isInit)
             if(!isInit)
             {
             {
-
+                DropCount = "2000"; 
                 this.ControlView = this.provider.Resolve<ScaleControlView>();
                 this.ControlView = this.provider.Resolve<ScaleControlView>();
                 this.LogView = this.provider.Resolve<ScaleLogView>();
                 this.LogView = this.provider.Resolve<ScaleLogView>();
 
 
@@ -130,6 +162,10 @@ namespace InkjetScale.GUI.MainViews.Views
 
 
                 OpenSerialPort();
                 OpenSerialPort();
 
 
+                this.SelectedHead = this.HeadList[(int)eHeadList.HeadPack1Head1 -1];
+
+                scaleThread.Start();
+
             }
             }
 
 
         }
         }
@@ -154,15 +190,13 @@ namespace InkjetScale.GUI.MainViews.Views
         {
         {
             Thread.Sleep(50);
             Thread.Sleep(50);
 
 
-            ReceiveMsg = String.Empty;
-            WeightValue = String.Empty;
             byte[] ReceiveByte = new byte[28];
             byte[] ReceiveByte = new byte[28];
             int num = this.scale.Read(ReceiveByte, 0, 28);
             int num = this.scale.Read(ReceiveByte, 0, 28);
 
 
             try
             try
             {
             {
-                bool isNum;
                 char c;
                 char c;
+                bool isNum;
                 int val;
                 int val;
                 
                 
                 switch (Command) 
                 switch (Command) 
@@ -170,6 +204,9 @@ namespace InkjetScale.GUI.MainViews.Views
                     case "S": //-> S S      3.14 mg \r\n 
                     case "S": //-> S S      3.14 mg \r\n 
                         {
                         {
 
 
+                            ReceiveMsg = String.Empty;
+                            WeightValue = String.Empty;
+
                             for (int index = 0; index < num; index++)
                             for (int index = 0; index < num; index++)
                             {
                             {
                                 c = Convert.ToChar((object)ReceiveByte[index]); // Char 변환
                                 c = Convert.ToChar((object)ReceiveByte[index]); // Char 변환
@@ -178,13 +215,10 @@ namespace InkjetScale.GUI.MainViews.Views
                                 isNum = int.TryParse(c.ToString(), out val); //숫자인지 문자인지 확인 할 변수
                                 isNum = int.TryParse(c.ToString(), out val); //숫자인지 문자인지 확인 할 변수
                                 if (isNum)
                                 if (isNum)
                                     WeightValue += c;
                                     WeightValue += c;
-                                else
-                                {
-                                    if (c == ' ' || c.ToString() == Command || c == '\r' || c == '\n')
-                                        continue;
-
+                                else if (c == '-' || c == '.')
                                     WeightValue += c;
                                     WeightValue += c;
-                                }
+                                else
+                                    continue;
 
 
                             }
                             }
 
 
@@ -195,36 +229,67 @@ namespace InkjetScale.GUI.MainViews.Views
                             else
                             else
                                 IsStable = false;
                                 IsStable = false;
                             
                             
-                            var mgVal = WeightValue.Substring(0, (WeightValue.Length - 5));
+                            var mgValue = double.Parse(WeightValue);
                             var nozzle = 1024;
                             var nozzle = 1024;
-                            var drops = 100;
-                            PlValue = $"{ScaleMath.GetPl(double.Parse(mgVal), nozzle, drops)}";
+                            var drops = int.Parse(DropCount);
+                            PlValue = $"{ScaleMath.GetPl(mgValue, nozzle, drops)}";
+
+                            if (!isThreadUse)
+                                ViewLogPubEvent(SelectedHead, mgValue, double.Parse(PlValue));
 
 
-                            ViewLogPubEvent(SelectedHead, double.Parse(WeightValue), double.Parse(mgVal));
                             break;
                             break;
                         }
                         }
 
 
                     case "Z": //-> Z A \r\n
                     case "Z": //-> Z A \r\n
                         {
                         {
+                            ReceiveMsg = String.Empty;
                             for (int index = 0; index < num; index++)
                             for (int index = 0; index < num; index++)
                             {
                             {
                                 c = Convert.ToChar((object)ReceiveByte[index]); // Char 변환
                                 c = Convert.ToChar((object)ReceiveByte[index]); // Char 변환
 
 
-                                if (c == ' ' || c == '\r' || c == '\n')
-                                    continue;
-                                else
+                                if (c == 'Z' || c == 'A')
                                     ReceiveMsg += c;
                                     ReceiveMsg += c;
+                                else
+                                    continue;
                             }
                             }
 
 
                             if (ReceiveMsg == "ZA") 
                             if (ReceiveMsg == "ZA") 
                             {
                             {
-                                ReceiveMsg = "Zero Complete";
-                                scale.Write("S" + Environment.NewLine);
+                                ReceiveMsg = "Zero!";
                             }
                             }
 
 
                             break;
                             break;
                         }
                         }
 
 
+                    case "T":
+                        {
+                            TareReceiveMsg = String.Empty;
+                            TareWeight = String.Empty;
+
+                            for (int index = 0; index < num; index++)
+                            {
+                                c = Convert.ToChar((object)ReceiveByte[index]); // Char 변환
+                                TareReceiveMsg += c;
+
+                                isNum = int.TryParse(c.ToString(), out val); //숫자인지 문자인지 확인 할 변수
+                                if (isNum)
+                                    TareWeight += c;
+                                else if (c == '-' || c == '.')
+                                    TareWeight += c;
+                                else
+                                    continue;
+                            }
+
+                            var splitMsg = TareReceiveMsg.Split(' ');
+                            var stableParam = splitMsg[1];
+                            if (stableParam == "S" || stableParam == "M")
+                                IsTareStable = true;
+                            else
+                                IsTareStable = false;
+
+                            break;
+                        }
+
                     default:
                     default:
                         {
                         {
                             ReceiveMsg = "Wrong Command!";
                             ReceiveMsg = "Wrong Command!";
@@ -233,6 +298,9 @@ namespace InkjetScale.GUI.MainViews.Views
 
 
                 }
                 }
 
 
+                if (!isThreadUse)
+                    isThreadUse = true;
+
             }
             }
 
 
             catch
             catch

+ 2 - 11
InkjetScale/InkjetScale.sln

@@ -23,8 +23,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkjetScale.Common", "Inkje
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkjetScale.BusinessLogic.Admin", "InkjetScale.BusinessLogic.Admin\InkjetScale.BusinessLogic.Admin.csproj", "{3DDA8868-7FC0-4014-AA47-9375E608BD0C}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkjetScale.BusinessLogic.Admin", "InkjetScale.BusinessLogic.Admin\InkjetScale.BusinessLogic.Admin.csproj", "{3DDA8868-7FC0-4014-AA47-9375E608BD0C}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkjetScale.BusinessLogic.ScaleCore", "InkjetScale.BusinessLogic.ScaleCore\InkjetScale.BusinessLogic.ScaleCore.csproj", "{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkjetScale.GUI.LogViews", "InkjetScale.GUI.LogViews\InkjetScale.GUI.LogViews.csproj", "{799D6601-8F88-4C27-8952-7760BAE9DA0C}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkjetScale.GUI.LogViews", "InkjetScale.GUI.LogViews\InkjetScale.GUI.LogViews.csproj", "{799D6601-8F88-4C27-8952-7760BAE9DA0C}"
 EndProject
 EndProject
 Global
 Global
@@ -70,18 +68,12 @@ Global
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C}.Release|Any CPU.Build.0 = Release|Any CPU
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C}.Release|Any CPU.Build.0 = Release|Any CPU
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C}.Remote_LAB|Any CPU.ActiveCfg = Remote_LAB|Any CPU
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C}.Remote_LAB|Any CPU.ActiveCfg = Remote_LAB|Any CPU
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C}.Remote_LAB|Any CPU.Build.0 = Remote_LAB|Any CPU
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C}.Remote_LAB|Any CPU.Build.0 = Remote_LAB|Any CPU
-		{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}.Release|Any CPU.Build.0 = Release|Any CPU
-		{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}.Remote_LAB|Any CPU.ActiveCfg = Remote_LAB|Any CPU
-		{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}.Remote_LAB|Any CPU.Build.0 = Remote_LAB|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Release|Any CPU.Build.0 = Release|Any CPU
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Release|Any CPU.Build.0 = Release|Any CPU
-		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Remote_LAB|Any CPU.ActiveCfg = Release|Any CPU
-		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Remote_LAB|Any CPU.Build.0 = Release|Any CPU
+		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Remote_LAB|Any CPU.ActiveCfg = Remote_LAB|Any CPU
+		{799D6601-8F88-4C27-8952-7760BAE9DA0C}.Remote_LAB|Any CPU.Build.0 = Remote_LAB|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE
@@ -93,7 +85,6 @@ Global
 		{74C4EB8F-0A6F-47A0-AFDA-158FB056C0C1} = {96A2A34C-DFF8-484E-A6BC-349EEC2B8C76}
 		{74C4EB8F-0A6F-47A0-AFDA-158FB056C0C1} = {96A2A34C-DFF8-484E-A6BC-349EEC2B8C76}
 		{BC7536F1-00FA-4970-8460-22B63D280108} = {6EDF61B6-2F29-413F-B76E-D360900B056D}
 		{BC7536F1-00FA-4970-8460-22B63D280108} = {6EDF61B6-2F29-413F-B76E-D360900B056D}
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C} = {96A2A34C-DFF8-484E-A6BC-349EEC2B8C76}
 		{3DDA8868-7FC0-4014-AA47-9375E608BD0C} = {96A2A34C-DFF8-484E-A6BC-349EEC2B8C76}
-		{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C} = {96A2A34C-DFF8-484E-A6BC-349EEC2B8C76}
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C} = {27AC19C6-C633-4862-A69E-42681B82C011}
 		{799D6601-8F88-4C27-8952-7760BAE9DA0C} = {27AC19C6-C633-4862-A69E-42681B82C011}
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	GlobalSection(ExtensibilityGlobals) = postSolution

+ 0 - 5
InkjetScale/InkjetScale/InkjetScale.csproj

@@ -104,7 +104,6 @@
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     </ApplicationDefinition>
-    <Compile Include="InkjetScaleCore.cs" />
     <Compile Include="ShellViewModel.cs">
     <Compile Include="ShellViewModel.cs">
       <DependentUpon>Shell.xaml</DependentUpon>
       <DependentUpon>Shell.xaml</DependentUpon>
     </Compile>
     </Compile>
@@ -153,10 +152,6 @@
       <Project>{3DDA8868-7FC0-4014-AA47-9375E608BD0C}</Project>
       <Project>{3DDA8868-7FC0-4014-AA47-9375E608BD0C}</Project>
       <Name>InkjetScale.BusinessLogic.Admin</Name>
       <Name>InkjetScale.BusinessLogic.Admin</Name>
     </ProjectReference>
     </ProjectReference>
-    <ProjectReference Include="..\InkjetScale.BusinessLogic.ScaleCore\InkjetScale.BusinessLogic.ScaleCore.csproj">
-      <Project>{307E7E0E-EE1E-4A2C-BD58-818AEF9F8B5C}</Project>
-      <Name>InkjetScale.BusinessLogic.ScaleCore</Name>
-    </ProjectReference>
     <ProjectReference Include="..\InkjetScale.Common\InkjetScale.Common.csproj">
     <ProjectReference Include="..\InkjetScale.Common\InkjetScale.Common.csproj">
       <Project>{bc7536f1-00fa-4970-8460-22b63d280108}</Project>
       <Project>{bc7536f1-00fa-4970-8460-22b63d280108}</Project>
       <Name>InkjetScale.Common</Name>
       <Name>InkjetScale.Common</Name>

+ 0 - 106
InkjetScale/InkjetScale/InkjetScaleCore.cs

@@ -1,106 +0,0 @@
-using InkjetScale.BusinessLogic.ScaleCore;
-using Prism.Events;
-using System;
-using System.Collections.Generic;
-using System.IO.Ports;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace InkjetScale
-{
-    public class InkjetScaleCore : ScaleCoreBase
-    {
-        public InkjetScaleCore(IEventAggregator eventAggregator) : base(eventAggregator)
-        {
-
-        }
-
-        public override void SerialDataReceived(object sender, SerialDataReceivedEventArgs e)
-        {
-            //Thread.Sleep(50);
-
-            //string ReceiveMsg = String.Empty;
-            //string ReceiveVal = String.Empty;
-            //byte[] ReceiveByte = new byte[28];
-            //int num = this.scale.Read(ReceiveByte, 0, 28);
-
-            //try
-            //{
-            //    bool isNum;
-            //    char s;
-            //    int val;
-
-            //    switch (Command)
-            //    {
-            //        case "S":
-            //            {
-            //                if (Convert.ToChar((object)ReceiveByte[2]) != 'S')
-            //                    ReceiveVal = "Not Stable";
-
-            //                for (int index = 0; index < num; index++)
-            //                {
-            //                    s = Convert.ToChar((object)ReceiveByte[index]); // Char 변환
-            //                    ReceiveMsg += s;
-
-            //                    isNum = int.TryParse(s.ToString(), out val); //숫자인지 문자인지 확인 할 변수
-            //                    if (isNum)
-            //                        ReceiveVal += s;
-            //                    else
-            //                    {
-            //                        if (s == ' ' || s.ToString() == Command || s == '\r' || s == '\n')
-            //                            continue;
-
-            //                        ReceiveVal += s;
-            //                    }
-
-            //                }
-
-            //                var mgVal = ReceiveVal.Substring(0, (ReceiveVal.Length - 5));
-            //                var nozzle = 1024;
-            //                var drops = 100;
-            //                PlVal = $"{ScaleMath.GetPl(double.Parse(mgVal), nozzle, drops)}pl";
-            //                break;
-            //            }
-
-            //        case "Z":
-            //            {
-            //                for (int index = 0; index < num; index++)
-            //                {
-            //                    s = Convert.ToChar((object)ReceiveByte[index]); // Char 변환
-
-            //                    if (s == ' ' || s == '\r' || s == '\n')
-            //                        continue;
-            //                    else
-            //                        ReceiveMsg += s;
-            //                }
-
-            //                if (ReceiveMsg == "ZA")
-            //                    ReceiveMsg = "Zero Complete";
-
-            //                break;
-            //            }
-
-            //        default:
-            //            {
-            //                ReceiveMsg = "Wrong Command!";
-            //                break;
-            //            }
-
-            //    }
-
-            //}
-
-            //catch
-            //{
-            //}
-        }
-
-        public override void Dispose()
-        {
-            base.Dispose();
-        }
-
-    }
-}

+ 7 - 0
InkjetScale/InkjetScale/ShellViewModel.cs

@@ -165,8 +165,15 @@ namespace InkjetScale
         private void ExecuteExit()
         private void ExecuteExit()
         {
         {
             Systemtimer.Stop();
             Systemtimer.Stop();
+            SystemExitPubEvent();
             App.Current.Shutdown();
             App.Current.Shutdown();
         }
         }
+
+        private void SystemExitPubEvent()
+        {
+            this.eventAggregator.GetEvent<SystemExitEvent>().Publish(true);
+        }
+
         private void ExecuteNavigate(string view)
         private void ExecuteNavigate(string view)
         {
         {
             if (!string.IsNullOrEmpty(view))
             if (!string.IsNullOrEmpty(view))