你好可爱的社区!
我正在使用带有 HP RP 7800 零售系统的 HP 2x20 集成显示器,并决定使用它并编写一些小程序让它学习编码。
SDK 提供的示例工具可以完美运行。
首先,我使用 Microsoft.IO.Ports 和简单的函数编写了一个简单的程序,如下所示:
SerialPort COM3 = new SerialPort("COM3", 9600, Parity.None, 8);
COM3.Open();
COM3.Write(Clear); // string Clear = "\x1B\x40" - hex value of a control character for the display
COM3.Write("Hello community");
它实际上工作正常,但我没有设法应用 HP 手册中提供的一些控制字符,因此我决定继续使用 .NET 的 POS。
所以现在直奔主题。我编写了一个具有基本功能和按钮的 C# 程序。
using Microsoft.PointOfService;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
LineDisplay lineDisplay;
PosExplorer explorer;
public Form1()
{
InitializeComponent();
try
{
explorer = new PosExplorer(this);
DeviceCollection devColl = explorer.GetDevices(DeviceType.LineDisplay); // is this line the problem?
//DeviceCollection devColl = explorer.GetDevice("LineDisplay", "HPLCM220Display"); // this one shows errors so I couldnt use it instead of the line above
if (devColl == null || devColl.Count <= 0)
{
MessageBox.Show("Device not found");
return;
}
lineDisplay = (LineDisplay)explorer.CreateInstance(devColl[0]);
lineDisplay.Open();
lineDisplay.Claim(10000);
lineDisplay.DeviceEnabled = true;
lineDisplay.DisplayText("Hello World.!");
lineDisplay.DisplayTextAt(1, 0, "Hey MSDN");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
private void btn_Clear_Click(object sender, EventArgs e)
{
lineDisplay.ClearText();
}
private void btn_SendText_Click(object sender, EventArgs e)
{
lineDisplay.DisplayText(textBox1.Text);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//this.textBox1.TextChanged -= textBox1_TextChanged;
}
}
}
当我启动它时,它会显示一个 LineDisplay Simulator,可以清除它并且可以更改文本,但真正的显示甚至不显示任何内容或被清除。
所以问题是:如何让我的应用程序在我的显示器而不是模拟器上显示文本。调试并没有真正帮助我。我注意到的是,在 AUTOS 中它在 LineDisplay Value 中显示 Microsoft.PointOfService.DeviceSimulators.LineDisplaySimulator 所以它以某种方式使用了 DeviceSimulators 但我不知道如何以及为什么..
我将 POS 用于 .net 文档,但遗憾的是没有成功 https://msdn.microsoft.com/en-us/library/microsoft.pointofservice.linedisplay(v=winembedded.11).aspx
我认为它以某种方式存在 - 设备收集线
DeviceCollection devColl = explorer.GetDevices(DeviceType.LineDisplay);
//DeviceCollection devColl = explorer.GetDevice("LineDisplay", "HPLCM220Display");
但是如果我使用注释行而不是第一个 une 它会显示错误:
Error CS0029 Cannot implicitly convert type 'Microsoft.PointOfService.DeviceInfo' to 'Microsoft.PointOfService.DeviceCollection' WindowsFormsApplication14 C:\Users\admin\Documents\Visual Studio 2015\Projects\WindowsFormsApplication14\WindowsFormsApplication14\Form1.cs 27 Active
我试图寻找 CS0029 的解决方案,但不幸的是我未能找到与我的问题的任何联系。
我从来没有编程过任何东西,所以我是一个新手,代码很糟糕,但我正在努力学习,所以如果有人这么好心地阐明这个问题,我将非常感激:)