fyf 2 years ago
parent
commit
8593acc280
2 changed files with 18 additions and 10 deletions
  1. +1
    -1
      WpfTest/MainWindow.xaml
  2. +17
    -9
      WpfTest/MainWindow.xaml.cs

+ 1
- 1
WpfTest/MainWindow.xaml View File

@@ -7,6 +7,6 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<TextBox x:Name="textwb" Background="Black" Foreground="#FFC000FB" TextWrapping="Wrap" AcceptsReturn="True" ></TextBox>
</Grid>
</Window>

+ 17
- 9
WpfTest/MainWindow.xaml.cs View File

@@ -106,15 +106,15 @@ namespace WpfTest

public void Send(ScreenDeviceType screen)
{
SendScreenDataModel sendScreenData = new SendScreenDataModel();

List<ORDER_STATUS> oRDER_STATUS = new List<ORDER_STATUS>() { ORDER_STATUS.WAIT, ORDER_STATUS.COOKING, ORDER_STATUS.COMPLETED_COOK, ORDER_STATUS.COMPLETED_TAKE, ORDER_STATUS.ERR_NOT_REPLY_WHEN_COOKING };
List<string> name_s = new List<string>() { "担担面", "鸡蛋面", "火鸡面", "扬州炒饭", "回锅肉盖饭" };
List<string> name_XM = new List<string>() { "张三", "李四", "王五", "王麻子", "二狗子" };

int k = new Random().Next(0, 5);
int M = new Random().Next(0, 5);
if (screen == ScreenDeviceType.大炒)
{
SendScreenDataModel sendScreenData = new SendScreenDataModel();
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMaxWok
{
@@ -167,11 +167,9 @@ namespace WpfTest
MaxWok_OrderCount_2 = new Random().Next(0, 100),
MaxWok_ErrorOrderCount_2 = new Random().Next(0, 100),
};
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(screen), JsonConvert.SerializeObject(sendScreenData));
}
else if (screen == ScreenDeviceType.小炒)
{
SendScreenDataModel sendScreenData = new SendScreenDataModel();
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMinWok
{
@@ -224,11 +222,9 @@ namespace WpfTest
MinWok_OrderCount_2 = new Random().Next(0, 100),
MinWok_ErrorOrderCount_2 = new Random().Next(0, 100),
};
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(screen), JsonConvert.SerializeObject(sendScreenData));
}
else if (screen == ScreenDeviceType.煮面机)
{
SendScreenDataModel sendScreenData = new SendScreenDataModel();
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMorkS
{
@@ -276,11 +272,9 @@ namespace WpfTest
},
};
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(screen), JsonConvert.SerializeObject(sendScreenData));
}
else if (screen == ScreenDeviceType.分餐机)
{
SendScreenDataModel sendScreenData = new SendScreenDataModel();
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelSplitMeals
{
@@ -331,8 +325,22 @@ namespace WpfTest
SplitMeals_CookType_6 = new List<string>() { "担担面", "鸡蛋面", "火鸡面" },

};
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(screen), JsonConvert.SerializeObject(sendScreenData));
}

string message = JsonConvert.SerializeObject(sendScreenData);
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(screen), message);

System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{
if (textwb.Text.Length > 100000)
{
textwb.Text = "";
}
string text = $"{ScreenTOPIC.GetInstance.GetTopic(screen)} {message}\n";
textwb.Text += text;
}));

}
}
}

Loading…
Cancel
Save