Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
dca3b51906
3 files changed
+27
-5
No files matched your search
@@ -8,7 +8,7 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
||||||
<Grid>
|
<Grid>
|
||||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="190,10,0,0" x:Name="comboBoxCOM" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20"/>
|
<ComboBox HorizontalAlignment="Left" Height="30" Margin="190,10,0,0" x:Name="comboBoxCOM" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20" IsEditable="True" IsReadOnly="True"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="90,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="80" FontSize="25"/>
|
<TextBlock HorizontalAlignment="Left" Height="30" Margin="90,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="80" FontSize="25"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -26,6 +26,7 @@ namespace DyeingComputer.View
|
|||||||
// 获取所有可用串口端口,并添加到comboBoxCOM
|
// 获取所有可用串口端口,并添加到comboBoxCOM
|
||||||
string[] ports = System.IO.Ports.SerialPort.GetPortNames();
|
string[] ports = System.IO.Ports.SerialPort.GetPortNames();
|
||||||
comboBoxCOM.ItemsSource = ports;
|
comboBoxCOM.ItemsSource = ports;
|
||||||
|
comboBoxCOM.Text = Configini.IniReadvalue("SYS", "COM");
|
||||||
}
|
}
|
||||||
//调用配置文件
|
//调用配置文件
|
||||||
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ namespace DyeingComputer.ViewModel
|
|||||||
|
|
||||||
public class MainWindowViewModel : ViewModelBase
|
public class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
||||||
|
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel()
|
||||||
{
|
{
|
||||||
WorkNumder = "----------";
|
WorkNumder = "----------";
|
||||||
@@ -118,7 +120,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件
|
||||||
{
|
{
|
||||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
Work_Temp = "130" + " ℃";
|
Work_Temp = Selet_dtm("1002") + " ℃";
|
||||||
Work_Numder = WorkNumder.ToString();
|
Work_Numder = WorkNumder.ToString();
|
||||||
// Status_Str = "qweqeqwqqfwfqef";
|
// Status_Str = "qweqeqwqqfwfqef";
|
||||||
|
|
||||||
@@ -137,7 +139,6 @@ namespace DyeingComputer.ViewModel
|
|||||||
|
|
||||||
public static SerialPort port = new SerialPort();//创建串口
|
public static SerialPort port = new SerialPort();//创建串口
|
||||||
static ModbusFactory factory = new ModbusFactory();
|
static ModbusFactory factory = new ModbusFactory();
|
||||||
|
|
||||||
// Create Modbus Master
|
// Create Modbus Master
|
||||||
static IModbusMaster master = factory.CreateRtuMaster(port);
|
static IModbusMaster master = factory.CreateRtuMaster(port);
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
port.PortName = "COM5";
|
port.PortName = Configini.IniReadvalue("SYS", "COM");
|
||||||
port.BaudRate = 115200;//配置
|
port.BaudRate = 115200;//配置
|
||||||
port.DataBits = 8;
|
port.DataBits = 8;
|
||||||
port.Parity = Parity.None;
|
port.Parity = Parity.None;
|
||||||
@@ -181,6 +182,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
LogGing.LogGingDATA(ex.Message);
|
||||||
Name_err = "PLC"+Properties.Resources.Connectionlost;
|
Name_err = "PLC"+Properties.Resources.Connectionlost;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -206,13 +208,32 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
SYSData_A = ToObservableCollection<DATA_A>(dt_a);
|
SYSData_A = ToObservableCollection<DATA_A>(dt_a);
|
||||||
SYSData_D = ToObservableCollection<DATA_D>(dt_d);
|
SYSData_D = ToObservableCollection<DATA_D>(dt_d);
|
||||||
SYSData_M = ToObservableCollection<DATA_M>(dt_m);
|
SYSData_M = ToObservableCollection<DATA_M>(dt_m);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int Selet_dtm(string key)//M寄存器
|
||||||
|
{
|
||||||
|
DataRow[] arrRows = dt_m.Select("ID=" + key);
|
||||||
|
int index = Convert.ToInt16(arrRows[0]["Value"].ToString());
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
private bool selet_dtd(string key)//D寄存器
|
||||||
|
{
|
||||||
|
DataRow[] arrRows = dt_d.Select("ID=" + key);
|
||||||
|
bool index = Convert.ToBoolean(arrRows[0]["DIO"].ToString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private int selet_dta(string key)//A寄存器
|
||||||
|
{
|
||||||
|
DataRow[] arrRows = dt_a.Select("ID=" + key);
|
||||||
|
int index = Convert.ToInt16(arrRows[0]["AIO"].ToString());
|
||||||
|
return index;
|
||||||
|
}
|
||||||
void updata_dtm(string key,int Value)//更新M寄存器
|
void updata_dtm(string key,int Value)//更新M寄存器
|
||||||
{
|
{
|
||||||
DataRow[] arrRows = dt_m.Select("ID="+key);
|
DataRow[] arrRows = dt_m.Select("ID="+key);
|
||||||
|
|||||||
Reference in new issue
Block a user