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; using GSG.NET.Logging; using OHVConnector; namespace OHVProtocolClient { /// /// MainWindow.xaml에 대한 상호 작용 논리 /// public partial class MainWindow : Window { static Logger logger = Logger.GetLogger("Client"); public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { string basePath = AppDomain.CurrentDomain.BaseDirectory; LogUtils.Configure(basePath + "/log4net.xml"); var cn = new Manager(); cn.Config = new Config() { ID = "V0001" }; cn.Connect(true); cn.OnRecd += Cn_OnRecd; cn.OnContd += Cn_OnContd; cn.OnDiscontd += Cn_OnDiscontd; cn.OnLog += Cn_OnLog; cn.OnT3Timeout += Cn_OnT3Timeout; cn.OnSent += Cn_OnSent; } private void Cn_OnSent(OCSMessage msg) { logger.I("[Send] : " + msg.LogFormat()); } private void Cn_OnT3Timeout(OCSMessage msg) { logger.E($"[T3TimeOut] - {msg.LogFormat()}"); } private void Cn_OnLog(string id, string log) { logger.I(log); } private void Cn_OnDiscontd(string id, Exception e) { this.lblState.Background = Brushes.Gray; } private void Cn_OnContd(string id) { this.lblState.Background = Brushes.Green; } private void Cn_OnRecd(OCSMessage msg) { logger.I("[Received] : " + msg.LogFormat()); } } }