spc-kiosk-pb/Agent/OLEDevice/DeviceMsr.cs
2019-06-16 14:12:09 +09:00

185 lines
5.7 KiB
C#

using System;
using System.Text;
using System.Threading;
using Cosmos.UserFrame;
using Cosmos.Common;
//using Microsoft.PointOfService;
using System.ComponentModel;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : Msr 제어
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.OLEDevice
{
/// <summary>
/// Msr 제어 CLASS
/// </summary>
public class DeviceMsr : IMsrUs
{
/// <summary>
/// StateServer Object (StateServer 객체)
/// </summary>
public StateServer StateObject = (StateServer)StateServer.GetInstance();
/// <summary>
/// Device 상태 정보 객체
/// </summary>
public DeviceStatus devStatus = new DeviceStatus();
///// <summary>
///// Pos for .Net Msr 객체
///// </summary>
//private Msr msr = null;
///// <summary>
///// Pos for .Net의 Device 정보를 가져오기 위한 객체
///// </summary>
//private PosExplorer posExplorer = null;
private string m_sTrackData1 = string.Empty;
private string m_sTrackData2 = string.Empty;
private string m_sTrackData3 = string.Empty;
/// <summary>
/// 이벤트 비동기 발생을 위한 대리자
/// </summary>
private BackgroundWorker bw = null;
private int m_nErrorCount = 0;
/// <summary>
/// 생성자
/// </summary>
public DeviceMsr()
{
try
{
//posExplorer = new PosExplorer();
devStatus = (DeviceStatus)StateObject.DEVICE;
DeviceStatusInit();
bw = new BackgroundWorker();
m_nErrorCount = 0;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
"DevicePosPrinter.DeviceMsr()", ex.Message);
}
}
/// <summary>
/// 장비의 Event 발생 Enable 상태 설정
/// <para>True:사용가능, False:사용불가능</para>
/// </summary>
public bool DeviceEnabled
{
get
{
return false;
}
set
{
try
{
bool bRet = SetDeviceEnabled(value);
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
"DeviceMsr.DeviceEnabled()", ex.Message);
}
}
}
/// <summary>
/// 장비의 Event 발생 Enable 상태 설정
/// <para>True:사용가능, False:사용불가능</para>
/// </summary>
private bool SetDeviceEnabled(bool bEnable)
{
bool bRet = false;
try
{
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
"DeviceMsr.SetDeviceEnabled()", ex.Message);
devStatus.Msr.Status = "DEVICE ENABLED FAIL";
}
return bRet;
}
/// <summary>
/// 디바이스 Open시 처리함수
/// </summary>
/// <param name="sDeviceType">장비종류(ex- "Msr","PosPrinter","Scanner"...)</param>
/// <param name="sLogicalName">레지스트리 항목(ex- "DefaultMsr","DefaultPosPrinter","DefaultScanner"...)</param>
/// <returns></returns>
public bool OpenDevice(string sDeviceType, string sLogicalName)
{
bool bRet = false;
try
{
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
"DeviceMsr.OpenDevice()", ex.Message);
devStatus.Msr.Open = false;
devStatus.Msr.Status = "DEVICE OPEN EXCEPTION";
return bRet;
}
return bRet;
}
/// <summary>
/// Msr StateServer 정보 초기화
/// </summary>
private void DeviceStatusInit()
{
devStatus.Msr.Track1Data = "";
devStatus.Msr.Track2Data = "";
devStatus.Msr.Track3Data = "";
devStatus.Msr.DeviceName = "";
devStatus.Msr.Status = "";
devStatus.Msr.Open = false;
}
/// <summary>
/// 디바이스 Close시 처리함수</para>
/// </summary>
/// <returns></returns>
public bool CloseDevice()
{
bool bRet = false;
try
{
devStatus.Msr.Status = "CLOSE";
devStatus.Msr.Open = false;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
"DeviceMsr.CloseDevice()", ex.Message);
devStatus.Msr.Status = "CLOSE EXCEPTION";
}
return bRet;
}
}
}