11238 lines
528 KiB
C#
11238 lines
528 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Net.Sockets;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
using SmartX;
|
|
using ITC81DB_0H.DialogForms;
|
|
|
|
namespace ITC81DB_0H.Forms
|
|
{
|
|
public partial class FormMain : Form
|
|
{
|
|
#region Field
|
|
private SmartSplash SmartSplashProgramLoad;
|
|
public bool IsCommunicationLogOpen;
|
|
public bool IsErrorLogOpen;
|
|
private int CommunicationCheckCount;
|
|
public bool IsBootingComplete;
|
|
public int BufferSmartUart; // Buffer size 정의
|
|
public int ContinuousNGCount;
|
|
public int ProductCount; // 품목 수량 카운트
|
|
public bool IsBuzzerOnDataSend;
|
|
public bool IsLampOnDataSend;
|
|
public int CountingOutput1Count; // CountingOutput1 개수
|
|
public int CountingOutput2Count; // CountingOutput2 개수
|
|
public bool FlagThreadMessage1; // 플레그 쓰레드 메시지 23
|
|
public bool IsCurrentKeyKorean;
|
|
public int SensorDetectingTime;
|
|
public double OverloadWeight;
|
|
|
|
#region 통신관련
|
|
// OPT2
|
|
private SerialOPT2 CurrentOPT2COM1;
|
|
private SerialOPT2 CurrentOPT2COM3;
|
|
private SerialOPT2 CurrentOPT2COM4;
|
|
private SerialOPT2 CurrentOPT2Ethernet;
|
|
private delegate void SerialOPT2COM1_Delegate();
|
|
private delegate void SerialOPT2COM3_Delegate();
|
|
private delegate void SerialOPT2COM4_Delegate();
|
|
private delegate void SerialOPT2Ethernet_Delegate();
|
|
// 현재 MACSA 통신 프로토콜 저장
|
|
private byte[] CurrentMACSACOM1;
|
|
private byte[] CurrentMACSACOM3;
|
|
private byte[] CurrentMACSACOM4;
|
|
private byte[] CurrentMACSAEthernet;
|
|
// MACSA 통신 프로토콜 1회 재전송 여부
|
|
private bool IsMACSARetransmissionCOM1;
|
|
private bool IsMACSARetransmissionCOM3;
|
|
private bool IsMACSARetransmissionCOM4;
|
|
private bool IsMACSARetransmissionEthernet;
|
|
|
|
// 통신설정 - 전송 지연시간
|
|
public Queue<object> QueueCOM1;
|
|
public Queue<object> QueueCOM3;
|
|
public Queue<object> QueueCOM4;
|
|
public Queue<object> QueueEthernet;
|
|
|
|
// OPC
|
|
private static int TotalBytes = 48; // 전체 bytes
|
|
#endregion
|
|
|
|
// 로그온 색상
|
|
public Color ColorLogOff;
|
|
public Color ColorLogOn;
|
|
|
|
// 파일 위치
|
|
private string m_PathFlashDiskFolder; // 프로그램 실행 폴더
|
|
private string m_PathLaunchFolder; // 프로그램 실행 폴더
|
|
private string m_PathDataBackupFolder; // 데이터 백업 폴더
|
|
private string m_PathFlashDiskSystemFile1Folder; // 시스템 파일1 폴더
|
|
private string m_PathFlashDiskSystemFile2Folder; // 시스템 파일2 폴더
|
|
private string m_PathSDCardSystemFileFolder; // 시스템 파일 폴더
|
|
private string m_PathSDCardSystemFile1Folder; // 시스템 파일1 폴더
|
|
private string m_PathSDCardSystemFile2Folder; // 시스템 파일2 폴더
|
|
private string m_PathSDCardSystemFileBackupFolder; // 시스템 파일 백업 폴더
|
|
private string m_PathSDCardRemoveFileFolder; // RemoveFile 폴더
|
|
|
|
// 현재 선택 된 품목
|
|
//public ProductItem CurrentProductItem;
|
|
// JudgmentSet
|
|
//public JudgmentSetItem CurrentJudgmentSetItem;
|
|
// 중량 데이터
|
|
//public WeightData CurrentWeightData;
|
|
|
|
// 시스템 상태
|
|
private SystemStatus m_CurrentSystemStatus;
|
|
// System Configuration1
|
|
public SystemConfigurationItem1 SystemConfig1;
|
|
// System Configuration2
|
|
public SystemConfigurationItem2 SystemConfig2;
|
|
// 중량 조정 설정값
|
|
public CalibrationItem CurrentCalibrationItem;
|
|
// 현재 피드백 값
|
|
public FeedbackItem CurrentFeedbackItem;
|
|
// 시스템파라미터1
|
|
public SystemParameter1 CurrentSystemParameter1;
|
|
// 시스템파라미터2
|
|
public SystemParameter2 CurrentSystemParameter2;
|
|
// 시스템파라미터3
|
|
public SystemParameter3 CurrentSystemParameter3;
|
|
// 시스템파라미터4
|
|
public SystemParameter4 CurrentSystemParameter4;
|
|
// BLDC 파라미터
|
|
public BLDCMotorParameter BLDCParameter;
|
|
|
|
// 시스템정보 파라미터
|
|
public SystemInformation2 SystemInfo2;
|
|
public SystemInformation3 SystemInfo3;
|
|
|
|
// Form
|
|
public FormMainDisplay ChildFormMainDisplay;
|
|
public FormMenu ChildFormMenu;
|
|
|
|
// IO Test Input 데이터 취합
|
|
private Collection<string> CollectionIOTest_InputData;
|
|
// IO Test Input 그래프 데이터
|
|
private Collection<string> CollectionIOTestGraphData;
|
|
// 판정설정 그래프 데이터
|
|
private Collection<int> CollectionGraphData;
|
|
// 업데이트 메인보드
|
|
public UpdateForMainBoard UpdateForMain;
|
|
|
|
// User
|
|
public User CurrentUser;
|
|
// UserGroup
|
|
public UserGroup CurrentUserGroup;
|
|
// Bacode
|
|
public Barcode CurrentBarcode;
|
|
// 품목설정 데이터
|
|
public Collection<ProductItem> CollectionProductItem;
|
|
// 판정설정 데이터
|
|
private Collection<JudgmentSetItem> CollectionJudgmentItem;
|
|
// Count 데이터
|
|
public Collection<WeightData> CollectionWeightData;
|
|
// 종근당 중량 데이터 버퍼
|
|
private Collection<DataBackupOPT1> CollectionBufferWeightData;
|
|
// 리젝데이터
|
|
private JudgmentResult CurrentJudgmentResult;
|
|
|
|
// HM Handshake를 위한 함수
|
|
private int HMCOM1_Step;
|
|
private int HMCOM3_Step;
|
|
private int HMCOM4_Step;
|
|
private int HMEthernet_Step;
|
|
|
|
// Ethernet
|
|
private bool IsEthernetThreadStop;
|
|
private bool IsEthernetTransferData;
|
|
|
|
public object EthernetTransferData;
|
|
|
|
private TcpClient EthernetTcpClient;
|
|
|
|
private NetworkStream EthernetNetStream;
|
|
private StreamReader EthernetStmReader;
|
|
private StreamWriter EthernetStmWriter;
|
|
|
|
private delegate void TransferDataCollbaack(string strtext);
|
|
private delegate void TextStatusCallback(string strtext);
|
|
private delegate void UIControlCallback(bool bEnable);
|
|
private delegate void UIServerStatusCallback(bool bEnable);
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public FormMain()
|
|
{
|
|
InitializeComponent();
|
|
|
|
// 프로그램 로딩 이미지
|
|
this.SmartSplashProgramLoad = new SmartX.SmartSplash();
|
|
this.SmartSplashProgramLoad.CenterPosition = true;
|
|
this.SmartSplashProgramLoad.AnimationInterval = 100;
|
|
this.SmartSplashProgramLoad.LoadingImagePathname = "SmartLoading3";
|
|
this.SmartSplashProgramLoad.Start();
|
|
}
|
|
#endregion
|
|
|
|
#region Property
|
|
public string PathFlashDiskFolder
|
|
{
|
|
get { return this.m_PathFlashDiskFolder; }
|
|
set { this.m_PathFlashDiskFolder = value; }
|
|
}
|
|
public string PathLaunchFolder
|
|
{
|
|
get { return this.m_PathLaunchFolder; }
|
|
set { this.m_PathLaunchFolder = value; }
|
|
}
|
|
public string PathDataBackupFolder
|
|
{
|
|
get { return this.m_PathDataBackupFolder; }
|
|
set { this.m_PathDataBackupFolder = value; }
|
|
}
|
|
public string PathFlashDiskSystemFile1Folder
|
|
{
|
|
get { return this.m_PathFlashDiskSystemFile1Folder; }
|
|
set { this.m_PathFlashDiskSystemFile1Folder = value; }
|
|
}
|
|
public string PathFlashDiskSystemFile2Folder
|
|
{
|
|
get { return this.m_PathFlashDiskSystemFile2Folder; }
|
|
set { this.m_PathFlashDiskSystemFile2Folder = value; }
|
|
}
|
|
public string PathSDCardSystemFileFolder
|
|
{
|
|
get { return this.m_PathSDCardSystemFileFolder; }
|
|
set { this.m_PathSDCardSystemFileFolder = value; }
|
|
}
|
|
public string PathSDCardSystemFile1Folder
|
|
{
|
|
get { return this.m_PathSDCardSystemFile1Folder; }
|
|
set { this.m_PathSDCardSystemFile1Folder = value; }
|
|
}
|
|
public string PathSDCardSystemFile2Folder
|
|
{
|
|
get { return this.m_PathSDCardSystemFile2Folder; }
|
|
set { this.m_PathSDCardSystemFile2Folder = value; }
|
|
}
|
|
public string PathSDCardSystemFileBackupFolder
|
|
{
|
|
get { return m_PathSDCardSystemFileBackupFolder; }
|
|
set { m_PathSDCardSystemFileBackupFolder = value; }
|
|
}
|
|
public string PathSDCardRemoveFileFolder
|
|
{
|
|
get { return m_PathSDCardRemoveFileFolder; }
|
|
set { m_PathSDCardRemoveFileFolder = value; }
|
|
}
|
|
|
|
public SystemStatus CurrentSystemStatus
|
|
{
|
|
get { return this.m_CurrentSystemStatus; }
|
|
private set { this.m_CurrentSystemStatus = value; }
|
|
}
|
|
|
|
public ProductItem CurrentProductItem
|
|
{
|
|
get { return this.CollectionProductItem[this.SystemConfig1.ProductNumber - 1]; }
|
|
set { this.CollectionProductItem[this.SystemConfig1.ProductNumber - 1] = value; }
|
|
}
|
|
public JudgmentSetItem CurrentJudgmentSetItem
|
|
{
|
|
get { return this.CollectionJudgmentItem[this.SystemConfig1.ProductNumber - 1]; }
|
|
set { this.CollectionJudgmentItem[this.SystemConfig1.ProductNumber - 1] = value; }
|
|
}
|
|
public WeightData CurrentWeightData
|
|
{
|
|
get { return this.CollectionWeightData[this.SystemConfig1.ProductNumber - 1]; }
|
|
set { this.CollectionWeightData[this.SystemConfig1.ProductNumber - 1] = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Method
|
|
private void DefaultSetting1()
|
|
{
|
|
this.IsCommunicationLogOpen = false;
|
|
this.IsErrorLogOpen = false;
|
|
this.CommunicationCheckCount = 0;
|
|
this.IsBootingComplete = false;
|
|
this.BufferSmartUart = 1000000; // 1MB
|
|
this.ContinuousNGCount = 0;
|
|
this.ProductCount = 1000;
|
|
this.IsBuzzerOnDataSend = false;
|
|
this.IsLampOnDataSend = false;
|
|
this.HMCOM1_Step = 0;
|
|
this.HMCOM3_Step = 0;
|
|
this.HMCOM4_Step = 0;
|
|
this.HMEthernet_Step = 0;
|
|
this.CountingOutput1Count = 0;
|
|
this.CountingOutput2Count = 0;
|
|
this.FlagThreadMessage1 = false;
|
|
this.IsCurrentKeyKorean = false;
|
|
this.OverloadWeight = 700.00;
|
|
|
|
#region 통신관련
|
|
this.CurrentOPT2COM1 = new SerialOPT2();
|
|
this.CurrentOPT2COM3 = new SerialOPT2();
|
|
this.CurrentOPT2COM4 = new SerialOPT2();
|
|
this.CurrentOPT2Ethernet = new SerialOPT2();
|
|
|
|
this.IsMACSARetransmissionCOM1 = false;
|
|
this.IsMACSARetransmissionCOM3 = false;
|
|
this.IsMACSARetransmissionCOM4 = false;
|
|
this.IsMACSARetransmissionEthernet = false;
|
|
|
|
this.QueueCOM1 = new Queue<object>();
|
|
this.QueueCOM3 = new Queue<object>();
|
|
this.QueueCOM4 = new Queue<object>();
|
|
this.QueueEthernet = new Queue<object>();
|
|
#endregion
|
|
|
|
this.ColorLogOff = Color.Red;
|
|
this.ColorLogOn = Color.Lime;
|
|
|
|
this.PathFlashDiskFolder = "Flash Disk\\";
|
|
this.PathLaunchFolder = "SD Card\\";
|
|
this.PathFlashDiskSystemFile1Folder = this.PathFlashDiskFolder + "SystemFile1\\";
|
|
this.PathFlashDiskSystemFile2Folder = this.PathFlashDiskFolder + "SystemFile2\\";
|
|
this.PathSDCardSystemFileFolder = this.PathLaunchFolder + "SystemFile\\";
|
|
this.PathSDCardSystemFile1Folder = this.PathLaunchFolder + "SystemFile1\\";
|
|
this.PathSDCardSystemFile2Folder = this.PathLaunchFolder + "SystemFile2\\";
|
|
this.PathDataBackupFolder = this.PathLaunchFolder + "DataBackup\\";
|
|
this.PathSDCardSystemFileBackupFolder = this.PathLaunchFolder + "SystemFileBackup\\";
|
|
this.PathSDCardRemoveFileFolder = this.PathLaunchFolder + "RemoveFile\\";
|
|
|
|
this.CollectionIOTest_InputData = new Collection<string>();
|
|
this.CollectionIOTest_InputData.Clear();
|
|
for (int i = 0; i < 8; i++)
|
|
this.CollectionIOTest_InputData.Add("0");
|
|
|
|
this.CollectionIOTestGraphData = new Collection<string>();
|
|
this.CollectionIOTestGraphData.Clear();
|
|
for (int i = 0; i < 500; i++)
|
|
this.CollectionIOTestGraphData.Add("0");
|
|
|
|
this.CollectionGraphData = new Collection<int>();
|
|
this.CollectionGraphData.Clear();
|
|
for (int i = 0; i < 300; i++)
|
|
this.CollectionGraphData.Add(0);
|
|
|
|
this.SystemConfig1 = new SystemConfigurationItem1();
|
|
this.SystemConfig2 = new SystemConfigurationItem2();
|
|
this.CurrentCalibrationItem = new CalibrationItem();
|
|
this.CurrentFeedbackItem = new FeedbackItem();
|
|
this.CurrentSystemStatus = new SystemStatus();
|
|
this.CurrentSystemParameter1 = new SystemParameter1();
|
|
this.CurrentSystemParameter2 = new SystemParameter2();
|
|
this.CurrentSystemParameter3 = new SystemParameter3();
|
|
this.CurrentSystemParameter4 = new SystemParameter4();
|
|
this.BLDCParameter = new BLDCMotorParameter();
|
|
//this.CurrentAutoZeroItem = new SystemParameter4();
|
|
this.SystemInfo2 = new SystemInformation2();
|
|
this.SystemInfo3 = new SystemInformation3();
|
|
this.CurrentUser = new User();
|
|
this.CurrentUserGroup = new UserGroup();
|
|
this.CollectionBufferWeightData = new Collection<DataBackupOPT1>();
|
|
this.UpdateForMain = new UpdateForMainBoard();
|
|
|
|
this.CollectionProductItem = new Collection<ProductItem>();
|
|
this.CollectionJudgmentItem = new Collection<JudgmentSetItem>();
|
|
this.CollectionWeightData = new Collection<WeightData>();
|
|
|
|
this.CurrentJudgmentResult = new JudgmentResult();
|
|
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
this.CollectionProductItem.Add(new ProductItem());
|
|
this.CollectionJudgmentItem.Add(new JudgmentSetItem());
|
|
this.CollectionWeightData.Add(new WeightData());
|
|
}
|
|
|
|
//this.CurrentAutoZeroItem.Initialization();
|
|
|
|
// SystemFile1, 2 폴더 생성 + 기존 SystemFile 폴더에서 파일 이동 후 삭제
|
|
DirectoryInfo pathSDCardSystemFileFolder = new DirectoryInfo(this.PathSDCardSystemFileFolder);
|
|
DirectoryInfo pathSDCardSystemFile1Folder = new DirectoryInfo(this.PathSDCardSystemFile1Folder);
|
|
DirectoryInfo pathSDCardSystemFile2Folder = new DirectoryInfo(this.PathSDCardSystemFile2Folder);
|
|
FileInfo[] files;
|
|
if (pathSDCardSystemFile1Folder.Exists == false)
|
|
{
|
|
pathSDCardSystemFile1Folder.Create();
|
|
if (pathSDCardSystemFileFolder.Exists == true)
|
|
{
|
|
files = pathSDCardSystemFileFolder.GetFiles();
|
|
foreach (FileInfo subFile in files)
|
|
{
|
|
if (subFile.Name != "ProductItem.int" && subFile.Name != "JudgmentSetItem.int" && subFile.Name != "counterItem.int")
|
|
subFile.MoveTo(this.PathSDCardSystemFile1Folder + subFile.Name);
|
|
}
|
|
}
|
|
}
|
|
if (pathSDCardSystemFile2Folder.Exists == false)
|
|
{
|
|
pathSDCardSystemFile2Folder.Create();
|
|
if (pathSDCardSystemFileFolder.Exists == true)
|
|
{
|
|
files = pathSDCardSystemFileFolder.GetFiles();
|
|
foreach (FileInfo subFile in files)
|
|
{
|
|
if (subFile.Name == "ProductItem.int" || subFile.Name == "JudgmentSetItem.int" || subFile.Name == "counterItem.int")
|
|
subFile.MoveTo(this.PathSDCardSystemFile2Folder + subFile.Name);
|
|
}
|
|
}
|
|
}
|
|
if (pathSDCardSystemFileFolder.Exists == true)
|
|
{
|
|
files = pathSDCardSystemFileFolder.GetFiles();
|
|
if (files.Length == 0)
|
|
pathSDCardSystemFileFolder.Delete();
|
|
}
|
|
|
|
// DataBackup 폴더 생성
|
|
if (Directory.Exists(this.PathDataBackupFolder) == false)
|
|
Directory.CreateDirectory(this.PathDataBackupFolder);
|
|
}
|
|
private void DefaultSetting2()
|
|
{
|
|
// 바코드
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
this.CurrentBarcode = new Barcode(this.CollectionProductItem, this.ProductCount);
|
|
|
|
if (this.CollectionProductItem[0].Name != BarcodeStatus.NoRead.ToString() || this.CollectionProductItem[0].LotNo != BarcodeStatus.NoRead.ToString())
|
|
{
|
|
this.CollectionProductItem[0].Name = BarcodeStatus.NoRead.ToString();
|
|
this.CollectionProductItem[0].LotNo = BarcodeStatus.NoRead.ToString();
|
|
this.SaveProductFile(this.CollectionProductItem[0], 0);
|
|
}
|
|
|
|
if (this.CollectionProductItem[1].Name != BarcodeStatus.NoMatch.ToString() || this.CollectionProductItem[1].LotNo != BarcodeStatus.NoMatch.ToString())
|
|
{
|
|
this.CollectionProductItem[1].Name = BarcodeStatus.NoMatch.ToString();
|
|
this.CollectionProductItem[1].LotNo = BarcodeStatus.NoMatch.ToString();
|
|
this.SaveProductFile(this.CollectionProductItem[1], 1);
|
|
}
|
|
|
|
// 통신 포트 설정
|
|
if (this.smartSerialPort3.IsOpen == true)
|
|
this.smartSerialPort3.Close();
|
|
|
|
// STXANDETX
|
|
this.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.STXANDETX);
|
|
|
|
this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
|
|
this.smartSerialPort3.Open();
|
|
}
|
|
|
|
// 이더넷
|
|
if (this.SystemConfig2.EthernetOperationMode == 1)
|
|
{
|
|
try
|
|
{
|
|
if (string.Compare(this.smartConfigs.IPSettings.DeviceIP, "0.0.0.0") != 0)
|
|
this.EthernetServerStart();
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
else if (this.SystemConfig2.EthernetOperationMode == 2)
|
|
{
|
|
this.EthernetClientDisconnect();
|
|
}
|
|
}
|
|
private void CreateForm()
|
|
{
|
|
this.ChildFormMainDisplay = new FormMainDisplay(this);
|
|
this.ChildFormMenu = new FormMenu(this);
|
|
|
|
this.smartForm.MainForm = this;
|
|
|
|
this.smartForm.AddChildForm(this.ChildFormMainDisplay);
|
|
this.smartForm.AddChildForm(this.ChildFormMenu);
|
|
}
|
|
|
|
public void OnExternalInputBuzzerSignal(bool bValue, bool flagValue)
|
|
{
|
|
if (bValue == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOnContinuousEnable, CommunicationID.MainBoard);
|
|
else
|
|
this.TransferData(CommunicationCommand.BuzzerOnContinuousDisable, CommunicationID.MainBoard);
|
|
|
|
if(flagValue == true)
|
|
this.IsBuzzerOnDataSend = true;
|
|
else
|
|
this.IsBuzzerOnDataSend = false;
|
|
}
|
|
public void OnExternalInputLampSignal(bool bValue, bool flagValue)
|
|
{
|
|
if (bValue == true)
|
|
this.TransferData(CommunicationCommand.LampOnContinuousEnable, CommunicationID.MainBoard);
|
|
else
|
|
this.TransferData(CommunicationCommand.LampOnContinuousDisable, CommunicationID.MainBoard);
|
|
|
|
if(flagValue == true)
|
|
this.IsLampOnDataSend = true;
|
|
else
|
|
this.IsLampOnDataSend = false;
|
|
}
|
|
private void ConverterAlarm(WeightData data, string alarm)
|
|
{
|
|
string sValue1 = "", sValue2 = "", sValue3 = "";
|
|
bool flagAlarm = false;
|
|
|
|
if (alarm.Length != 3)
|
|
return;
|
|
|
|
sValue1 = Convert.ToString(Convert.ToInt16(alarm.Substring(0, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
|
|
sValue2 = Convert.ToString(Convert.ToInt16(alarm.Substring(1, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
|
|
sValue3 = Convert.ToString(Convert.ToInt16(alarm.Substring(2, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
|
|
|
|
// 알람 12-외부에러
|
|
if (sValue3[0] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 알람 11-
|
|
if (sValue3[1] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 알람 10-
|
|
if (sValue3[2] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 알람 9-인버터에러
|
|
if (sValue3[3] == '0')
|
|
data.IsInverterError = false;
|
|
else
|
|
data.IsInverterError = true;
|
|
|
|
// 알람 8-
|
|
if (sValue2[0] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 알람 7-리젝터 동작 감지(배출확인)
|
|
if (sValue2[1] == '0')
|
|
{
|
|
data.IsSorterError = false;
|
|
}
|
|
else
|
|
{
|
|
data.IsSorterError = true;
|
|
flagAlarm = true;
|
|
}
|
|
// 알람 6-적체센서 에러
|
|
if (sValue2[2] == '0')
|
|
{
|
|
data.IsStackUpSensorError = false;
|
|
}
|
|
else
|
|
{
|
|
data.IsStackUpSensorError = true;
|
|
flagAlarm = true;
|
|
|
|
if(this.CurrentSystemParameter1.PI7 != 2) // 스토퍼 사용 시, 컨베어 미정지
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
}
|
|
// 알람 5-공압에러
|
|
if (sValue2[3] == '0')
|
|
{
|
|
data.IsPressureSensingError = false;
|
|
}
|
|
else
|
|
{
|
|
data.IsPressureSensingError = true;
|
|
flagAlarm = true;
|
|
}
|
|
|
|
// 알람 4-Emergency
|
|
if (sValue1[0] == '0')
|
|
{
|
|
data.IsEmergencyStop = false;
|
|
}
|
|
else
|
|
{
|
|
data.IsEmergencyStop = true;
|
|
flagAlarm = true;
|
|
}
|
|
|
|
// 알람 3-도어인터록
|
|
if (sValue1[1] == '0')
|
|
{
|
|
data.IsDoorInterlock = false;
|
|
}
|
|
else
|
|
{
|
|
data.IsDoorInterlock = true;
|
|
flagAlarm = true;
|
|
}
|
|
|
|
// 알람 2-셀 에러
|
|
if (sValue1[2] == '0')
|
|
data.IsLoadCellError = false;
|
|
else
|
|
data.IsLoadCellError = true;
|
|
|
|
// 알람 1-입력센서 에러
|
|
if (sValue1[3] == '0')
|
|
data.IsEntrySensorError = false;
|
|
else
|
|
data.IsEntrySensorError = true;
|
|
|
|
if (flagAlarm == true)
|
|
{
|
|
if (this.SystemConfig1.IsExternalInputLamp == true && this.IsLampOnDataSend == false)
|
|
this.OnExternalInputLampSignal(true, true);
|
|
if (this.SystemConfig1.IsExternalInputBuzzer == true && this.IsBuzzerOnDataSend == false)
|
|
this.OnExternalInputBuzzerSignal(true, true);
|
|
}
|
|
}
|
|
private void ConverterResult(string alarm)
|
|
{
|
|
string sValue1 = "", sValue2 = "", sValue3 = "", sValue4 = "";
|
|
|
|
if (alarm.Length != 4)
|
|
return;
|
|
|
|
this.CurrentJudgmentResult.Initialize();
|
|
|
|
sValue1 = Convert.ToString(Convert.ToInt16(alarm.Substring(0, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
|
|
sValue2 = Convert.ToString(Convert.ToInt16(alarm.Substring(1, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
|
|
sValue3 = Convert.ToString(Convert.ToInt16(alarm.Substring(2, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
|
|
sValue4 = Convert.ToString(Convert.ToInt16(alarm.Substring(3, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
|
|
|
|
// 판정 16-
|
|
if (sValue4[0] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 15-
|
|
if (sValue4[1] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 14-
|
|
if (sValue4[2] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 13-리젝터 동작 상태
|
|
if (this.CurrentSystemParameter1.PI8 == 1)
|
|
{
|
|
if (sValue4[3] == '0')
|
|
this.CurrentJudgmentResult.CurrentRejectData = DataStore.JudgmentResult.OK;
|
|
else
|
|
this.CurrentJudgmentResult.CurrentRejectData = DataStore.JudgmentResult.NG;
|
|
}
|
|
|
|
// 판정 12-
|
|
if (sValue3[0] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 11-
|
|
if (sValue3[1] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 10-
|
|
if (sValue3[2] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 9-
|
|
if (this.CurrentSystemParameter1.PI8 == 1)
|
|
{
|
|
if (sValue3[3] == '0')
|
|
this.CurrentJudgmentResult.PreviousRejectData = DataStore.JudgmentResult.OK;
|
|
else
|
|
this.CurrentJudgmentResult.PreviousRejectData = DataStore.JudgmentResult.NG;
|
|
}
|
|
|
|
// 판정 8-
|
|
if (sValue2[0] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 7-
|
|
if (sValue2[1] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 6-
|
|
if (sValue2[2] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 5-
|
|
if (sValue2[3] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
|
|
// 판정 4-
|
|
if (sValue1[0] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 3-
|
|
if (sValue1[1] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 2-
|
|
if (sValue1[2] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
// 판정 1-
|
|
if (sValue1[3] == '0')
|
|
{ }
|
|
else
|
|
{ }
|
|
}
|
|
private void BarcodeProductChange(Barcode barcode)
|
|
{
|
|
int productNo = 0;
|
|
BarcodeStatus status = BarcodeStatus.None;
|
|
|
|
status = barcode.GetData(ref productNo);
|
|
// 품목변환
|
|
this.TransferProductParameter(productNo);
|
|
|
|
if (status == BarcodeStatus.NoRead || status == BarcodeStatus.NoMatch)
|
|
{
|
|
// 기타NG 전송(메인에서 NG 처리할수있도록)
|
|
this.TransferData(CommunicationCommand.JudgmentExternalNG, CommunicationID.MainBoard);
|
|
}
|
|
|
|
this.ChildFormMainDisplay.UpdateBarcodeDisplay(this.CurrentBarcode);
|
|
}
|
|
private void UpdateCountData(WeightData wData)
|
|
{
|
|
if (this.SystemConfig1.ProductNumber == wData.BoardProductNumber)
|
|
{
|
|
if (wData.ExNGCount != wData.BoardExNGCount)
|
|
this.CurrentWeightData.ExNGCount = wData.BoardExNGCount;
|
|
|
|
if (wData.OverCount != wData.BoardOverCount)
|
|
this.CurrentWeightData.OverCount = wData.BoardOverCount;
|
|
|
|
if (wData.PassCount != wData.BoardPassCount)
|
|
this.CurrentWeightData.PassCount = wData.BoardPassCount;
|
|
|
|
if (wData.UnderCount != wData.BoardUnderCount)
|
|
this.CurrentWeightData.UnderCount = wData.BoardUnderCount;
|
|
|
|
if (wData.StartTime.Year == 1111)
|
|
{
|
|
wData.StartTime = DateTime.Now;
|
|
this.CurrentWeightData.StartTime = wData.StartTime;
|
|
}
|
|
if (wData.StopTime.Year == 1111)
|
|
{
|
|
wData.StopTime = DateTime.Now;
|
|
this.CurrentWeightData.StopTime = wData.StopTime;
|
|
}
|
|
|
|
this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
|
|
}
|
|
}
|
|
|
|
private void StartThreadMessage1()
|
|
{
|
|
if (this.smartThread.State != SmartThread.ThreadState.Running)
|
|
{
|
|
this.smartThread.Start();
|
|
this.FlagThreadMessage1 = false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set Mode
|
|
/// </summary>
|
|
/// <param name="mode"></param>
|
|
public void SetDisplayMode(DataStore.DisplayMode mode)
|
|
{
|
|
if (this.CurrentSystemStatus.CurrentMode == mode)
|
|
return;
|
|
else
|
|
this.CurrentSystemStatus.CurrentMode = mode;
|
|
|
|
switch (mode)
|
|
{
|
|
case DataStore.DisplayMode.Normal:
|
|
this.TransferData(CommunicationCommand.ModeNormal, CommunicationID.MainBoard);
|
|
break;
|
|
case DataStore.DisplayMode.Menu:
|
|
this.TransferData(CommunicationCommand.ModeMenu, CommunicationID.MainBoard);
|
|
break;
|
|
case DataStore.DisplayMode.Calibration:
|
|
this.TransferData(CommunicationCommand.ModeCalibration, CommunicationID.MainBoard);
|
|
break;
|
|
case DataStore.DisplayMode.SystemSetting:
|
|
this.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.MainBoard);
|
|
break;
|
|
case DataStore.DisplayMode.IOTest:
|
|
this.TransferData(CommunicationCommand.ModeIOTest, CommunicationID.MainBoard);
|
|
break;
|
|
case DataStore.DisplayMode.Bypass:
|
|
this.TransferData(CommunicationCommand.ModeBypass, CommunicationID.MainBoard);
|
|
break;
|
|
case DataStore.DisplayMode.EquipmentTest:
|
|
this.TransferData(CommunicationCommand.ModeEquipmentTest, CommunicationID.MainBoard);
|
|
break;
|
|
case DataStore.DisplayMode.SorterTest:
|
|
this.TransferData(CommunicationCommand.ModeRejectorTest, CommunicationID.MainBoard);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Set User
|
|
/// </summary>
|
|
/// <param name="user"></param>
|
|
public void SetUser(DataStore.UserGroup user)
|
|
{
|
|
if (this.CurrentSystemStatus.CurrentUserPasswordType.Group != user)
|
|
this.CurrentSystemStatus.CurrentUserPasswordType.Group = user;
|
|
}
|
|
|
|
private void RetryUpdateForMain(UpdateForMainBoard update)
|
|
{
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard,
|
|
CommunicationAddress._1651_UpdateForMain, Helper.StringZeroFillDigits4(update.Index.ToString()), update.SendData);
|
|
|
|
this.smartTimerUpdate.Start();
|
|
}
|
|
public void SendUpdateForMain(byte[] datas)
|
|
{
|
|
int count = 0;
|
|
|
|
if (datas.Length == 0)
|
|
return;
|
|
|
|
count = datas.Length / 100;
|
|
|
|
if (count != 0)
|
|
{
|
|
this.UpdateForMain.SendData = new byte[100];
|
|
for (int i = 0; i < 100; i++)
|
|
this.UpdateForMain.SendData[i] = datas[i];
|
|
}
|
|
else
|
|
{
|
|
this.UpdateForMain.SendData = new byte[datas.Length];
|
|
for (int i = 0; i < datas.Length; i++)
|
|
this.UpdateForMain.SendData[i] = datas[i];
|
|
|
|
this.UpdateForMain.IsLastData = true;
|
|
}
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard,
|
|
CommunicationAddress._1651_UpdateForMain, Helper.StringZeroFillDigits4(this.UpdateForMain.Index.ToString()), this.UpdateForMain.SendData);
|
|
|
|
if (this.UpdateForMain.ProgressBar1 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
else if (this.UpdateForMain.ProgressBar2 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
else if (this.UpdateForMain.ProgressBar3 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
else if (this.UpdateForMain.ProgressBar4 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
else if (this.UpdateForMain.ProgressBar5 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
else if (this.UpdateForMain.ProgressBar6 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
else if (this.UpdateForMain.ProgressBar7 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
else if (this.UpdateForMain.ProgressBar8 == count)
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
|
|
|
|
this.smartTimerUpdate.Start();
|
|
}
|
|
|
|
public void PrintingHeadLine()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM1Mode == 3)
|
|
{
|
|
this.TransferSerialCOM1("\n--------------------------------");
|
|
this.TransferSerialCOM1(" NO GRADE WEIGHT COUNT");
|
|
this.TransferSerialCOM1("\n--------------------------------");
|
|
}
|
|
if (this.SystemConfig1.SerialCOM3Mode == 3)
|
|
{
|
|
this.TransferSerialCOM3("\n--------------------------------");
|
|
this.TransferSerialCOM3(" NO GRADE WEIGHT COUNT");
|
|
this.TransferSerialCOM3("\n--------------------------------");
|
|
}
|
|
if (this.SystemConfig1.SerialCOM4Mode == 3)
|
|
{
|
|
this.TransferSerialCOM4("\n--------------------------------");
|
|
this.TransferSerialCOM4(" NO GRADE WEIGHT COUNT");
|
|
this.TransferSerialCOM4("\n--------------------------------");
|
|
}
|
|
}
|
|
public void PrintingWeight(WeightData data, ProductItem pItem)
|
|
{
|
|
string value = "";
|
|
|
|
if (this.SystemConfig1.SerialCOM1Mode == 3)
|
|
{
|
|
#region CH1(COM1)
|
|
this.TransferSerialCOM1("\n################################");
|
|
this.TransferSerialCOM1("\n TOTAL PRINT ");
|
|
this.TransferSerialCOM1("\n################################");
|
|
this.TransferSerialCOM1(string.Format("\nPART = {0}", pItem.Number));
|
|
this.TransferSerialCOM1(string.Format("\nSTART = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
this.TransferSerialCOM1(string.Format("\nEND = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nUNDER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n COUNT = {0}", data.UnderCount));
|
|
this.TransferSerialCOM1(string.Format("\n TOTAL.W = {0}kg", data.UnderSumWeightKG));
|
|
this.TransferSerialCOM1(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.UnderAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n RATIO = {0}%", data.UnderRatio));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nPASS = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n COUNT = {0}", data.PassCount));
|
|
this.TransferSerialCOM1(string.Format("\n TOTAL.W = {0}kg", data.PassSumWeightKG));
|
|
this.TransferSerialCOM1(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n RATIO = {0}%", data.PassRatio));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nOVER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n COUNT = {0}", data.OverCount));
|
|
this.TransferSerialCOM1(string.Format("\n TOTAL.W = {0}kg", data.OverSumWeightKG));
|
|
this.TransferSerialCOM1(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.OverAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n RATIO = {0}%", data.OverRatio));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nTARE = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n\nFaulty = {0}", data.TotalUnderOverCount));
|
|
this.TransferSerialCOM1(string.Format("\n\nOther.F = {0}", data.ExNGCount));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));
|
|
|
|
this.TransferSerialCOM1("\n################################\n\n\n\n");
|
|
#endregion
|
|
}
|
|
else if (this.SystemConfig1.SerialCOM3Mode == 3)
|
|
{
|
|
#region CH2(COM3)
|
|
this.TransferSerialCOM3("\n################################");
|
|
this.TransferSerialCOM3("\n TOTAL PRINT ");
|
|
this.TransferSerialCOM3("\n################################");
|
|
this.TransferSerialCOM3(string.Format("\nPART = {0}", pItem.Number));
|
|
this.TransferSerialCOM3(string.Format("\nSTART = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
this.TransferSerialCOM3(string.Format("\nEND = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nUNDER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n COUNT = {0}", data.UnderCount));
|
|
this.TransferSerialCOM3(string.Format("\n TOTAL.W = {0}kg", data.UnderSumWeightKG));
|
|
this.TransferSerialCOM3(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.UnderAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n RATIO = {0}%", data.UnderRatio));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nPASS = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n COUNT = {0}", data.PassCount));
|
|
this.TransferSerialCOM3(string.Format("\n TOTAL.W = {0}kg", data.PassSumWeightKG));
|
|
this.TransferSerialCOM3(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n RATIO = {0}%", data.PassRatio));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nOVER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n COUNT = {0}", data.OverCount));
|
|
this.TransferSerialCOM3(string.Format("\n TOTAL.W = {0}kg", data.OverSumWeightKG));
|
|
this.TransferSerialCOM3(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.OverAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n RATIO = {0}%", data.OverRatio));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nTARE = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n\nFaulty = {0}", data.TotalUnderOverCount));
|
|
this.TransferSerialCOM3(string.Format("\n\nOther.F = {0}", data.ExNGCount));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));
|
|
|
|
this.TransferSerialCOM3("\n################################\n\n\n\n");
|
|
#endregion
|
|
}
|
|
else if (this.SystemConfig1.SerialCOM4Mode == 3)
|
|
{
|
|
#region CH3(COM4)
|
|
this.TransferSerialCOM4("\n################################");
|
|
this.TransferSerialCOM4("\n TOTAL PRINT ");
|
|
this.TransferSerialCOM4("\n################################");
|
|
this.TransferSerialCOM4(string.Format("\nPART = {0}", pItem.Number));
|
|
this.TransferSerialCOM4(string.Format("\nSTART = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
this.TransferSerialCOM4(string.Format("\nEND = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nUNDER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n COUNT = {0}", data.UnderCount));
|
|
this.TransferSerialCOM4(string.Format("\n TOTAL.W = {0}kg", data.UnderSumWeightKG));
|
|
this.TransferSerialCOM4(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.UnderAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n RATIO = {0}%", data.UnderRatio));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nPASS = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n COUNT = {0}", data.PassCount));
|
|
this.TransferSerialCOM4(string.Format("\n TOTAL.W = {0}kg", data.PassSumWeightKG));
|
|
this.TransferSerialCOM4(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n RATIO = {0}%", data.PassRatio));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nOVER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n COUNT = {0}", data.OverCount));
|
|
this.TransferSerialCOM4(string.Format("\n TOTAL.W = {0}kg", data.OverSumWeightKG));
|
|
this.TransferSerialCOM4(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.OverAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n RATIO = {0}%", data.OverRatio));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nTARE = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n\nFaulty = {0}", data.TotalUnderOverCount));
|
|
this.TransferSerialCOM4(string.Format("\n\nOther.F = {0}", data.ExNGCount));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));
|
|
|
|
this.TransferSerialCOM4("\n################################\n\n\n\n");
|
|
#endregion
|
|
}
|
|
}
|
|
public void PrintingWeight2(WeightData data, ProductItem pItem)
|
|
{
|
|
string value = "";
|
|
|
|
if (this.SystemConfig1.SerialCOM1Mode == 3)
|
|
{
|
|
#region CH1(COM1)
|
|
this.TransferSerialCOM1("\n################################");
|
|
this.TransferSerialCOM1("\n TOTAL PRINT ");
|
|
this.TransferSerialCOM1("\n################################");
|
|
this.TransferSerialCOM1(string.Format("\nPART NAME = {0}", pItem.Name));
|
|
this.TransferSerialCOM1(string.Format("\nPART No. = {0}", pItem.Number));
|
|
this.TransferSerialCOM1(string.Format("\nLOT No. = {0}", pItem.LotNo));
|
|
this.TransferSerialCOM1(string.Format("\nSTART = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm")));
|
|
this.TransferSerialCOM1(string.Format("\nEND = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm")));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nUNDER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n COUNT = {0}", data.UnderCount));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nPASS = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n COUNT = {0}", data.PassCount));
|
|
this.TransferSerialCOM1(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nOVER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM1(string.Format("\n COUNT = {0}", data.OverCount));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nTARE = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
|
|
this.TransferSerialCOM1(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));
|
|
|
|
this.TransferSerialCOM1("\n################################\n\n\n\n");
|
|
#endregion
|
|
}
|
|
else if (this.SystemConfig1.SerialCOM3Mode == 3)
|
|
{
|
|
#region CH2(COM3)
|
|
this.TransferSerialCOM3("\n################################");
|
|
this.TransferSerialCOM3("\n TOTAL PRINT ");
|
|
this.TransferSerialCOM3("\n################################");
|
|
this.TransferSerialCOM3(string.Format("\nPART NAME = {0}", pItem.Name));
|
|
this.TransferSerialCOM3(string.Format("\nPART No. = {0}", pItem.Number));
|
|
this.TransferSerialCOM3(string.Format("\nLOT No. = {0}", pItem.LotNo));
|
|
this.TransferSerialCOM3(string.Format("\nSTART = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm")));
|
|
this.TransferSerialCOM3(string.Format("\nEND = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm")));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nUNDER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n COUNT = {0}", data.UnderCount));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nPASS = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n COUNT = {0}", data.PassCount));
|
|
this.TransferSerialCOM3(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nOVER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM3(string.Format("\n COUNT = {0}", data.OverCount));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nTARE = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
|
|
this.TransferSerialCOM3(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));
|
|
|
|
this.TransferSerialCOM3("\n################################\n\n\n\n");
|
|
#endregion
|
|
}
|
|
else if (this.SystemConfig1.SerialCOM4Mode == 3)
|
|
{
|
|
#region CH3(COM4)
|
|
this.TransferSerialCOM4("\n################################");
|
|
this.TransferSerialCOM4("\n TOTAL PRINT ");
|
|
this.TransferSerialCOM4("\n################################");
|
|
this.TransferSerialCOM4(string.Format("\nPART NAME = {0}", pItem.Name));
|
|
this.TransferSerialCOM4(string.Format("\nPART No. = {0}", pItem.Number));
|
|
this.TransferSerialCOM4(string.Format("\nLOT No. = {0}", pItem.LotNo));
|
|
this.TransferSerialCOM4(string.Format("\nSTART = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm")));
|
|
this.TransferSerialCOM4(string.Format("\nEND = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm")));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nUNDER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n COUNT = {0}", data.UnderCount));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nPASS = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n COUNT = {0}", data.PassCount));
|
|
this.TransferSerialCOM4(string.Format("\n AVG = {0}{1}",
|
|
Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nOVER = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
this.TransferSerialCOM4(string.Format("\n COUNT = {0}", data.OverCount));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nTARE = {0}{1}",
|
|
Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
|
|
this.TransferSerialCOM4(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));
|
|
|
|
this.TransferSerialCOM4("\n################################\n\n\n\n");
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
// 피드백 데이터(피드백 편차 변경 X)
|
|
public void UpdateFeedbackData(ProductItem item, SystemParameter2 parameter)
|
|
{
|
|
if (this.ChildFormMainDisplay.MainDisplayFeedback.IsUsingFeedback() == true)
|
|
{
|
|
int temp = 0;
|
|
string feedbackValue = "";
|
|
|
|
if (parameter.OPT1IsWeightSetting == "1")
|
|
{
|
|
temp = item.PassRangeInt + this.CurrentFeedbackItem.OverRangeDeviationInt;
|
|
if (temp <= 0)
|
|
{
|
|
parameter.OPT1OverRange = "0";
|
|
this.UpdateFeedbackDeviation(this.CurrentProductItem, this.CurrentSystemParameter2);
|
|
}
|
|
else
|
|
parameter.OPT1OverRange = (item.PassRangeInt + this.CurrentFeedbackItem.OverRangeDeviationInt).ToString();
|
|
|
|
temp = item.PassRangeInt + this.CurrentFeedbackItem.UnderRangeDeviationInt;
|
|
if (temp <= 0)
|
|
{
|
|
parameter.OPT1UnderRange = "0";
|
|
this.UpdateFeedbackDeviation(this.CurrentProductItem, this.CurrentSystemParameter2);
|
|
}
|
|
else
|
|
parameter.OPT1UnderRange = (item.PassRangeInt + this.CurrentFeedbackItem.UnderRangeDeviationInt).ToString();
|
|
}
|
|
else
|
|
{
|
|
parameter.OPT1OverRange = item.OverRange;
|
|
parameter.OPT1UnderRange = item.UnderRange;
|
|
}
|
|
|
|
if (parameter.OPT1OverRangeInt < item.PassRangeInt)
|
|
parameter.OPT1OverRange = item.PassRange;
|
|
|
|
this.SaveSystemParameter2File(parameter);
|
|
feedbackValue = Helper.StringZeroFillDigits7(parameter.OPT1OverRange);
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OPT1OverRange, feedbackValue);
|
|
feedbackValue = Helper.StringZeroFillDigits7(parameter.OPT1UnderRange);
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OPT1UnderRange, feedbackValue);
|
|
}
|
|
|
|
this.ChildFormMainDisplay.MainDisplayFeedback.DisplayRefresh(this.CurrentSystemStatus);
|
|
}
|
|
public void UpdateFeedbackDeviation(ProductItem item, SystemParameter2 parameter)
|
|
{
|
|
string sValue = "";
|
|
|
|
sValue = this.ChildFormMainDisplay.MainDisplayFeedback.CaculateDeviation(parameter.OPT1OverRangeInt);
|
|
this.CurrentFeedbackItem.OverRangeDeviation = sValue;
|
|
|
|
sValue = this.ChildFormMainDisplay.MainDisplayFeedback.CaculateDeviation(parameter.OPT1UnderRangeInt);
|
|
this.CurrentFeedbackItem.UnderRangeDeviation = sValue;
|
|
|
|
this.ChildFormMainDisplay.MainDisplayFeedback.DisplayRefresh(this.CurrentSystemStatus);
|
|
}
|
|
|
|
#region Uart Communication
|
|
private void OpenSmartUartLink()
|
|
{
|
|
string fullPath = "";
|
|
DateTime dt = DateTime.Now;
|
|
|
|
try
|
|
{
|
|
if (this.smartSerialPort2.IsOpen == false)
|
|
this.smartSerialPort2.Open();
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
#region Test 용 통신 로그
|
|
fullPath = this.PathDataBackupFolder + "Communicationlog.txt";
|
|
this.smartFileCommunicationLog.FilePathName = fullPath;
|
|
//this.smartFileCommunicationLog.Open();
|
|
//this.IsCommunicationLogOpen = true;
|
|
#endregion
|
|
|
|
#region Error Check 용 통신 로그
|
|
fullPath = this.PathDataBackupFolder + string.Format("{0:yyMMdd}_", dt) + this.SystemConfig1.UsbID + "_Checklog.txt";
|
|
this.smartFileCheckLog.FilePathName = fullPath;
|
|
// CheckLog
|
|
//this.smartFileCheckLog.Open();
|
|
//this.IsErrorLogOpen = true;
|
|
#endregion
|
|
}
|
|
public void CloseSmartUartLink()
|
|
{
|
|
this.smartSerialPort2.Close();
|
|
}
|
|
|
|
private bool SizeCheck(string cmd, string strTemp)
|
|
{
|
|
bool ret = false;
|
|
string dataSize = "";
|
|
int size = 0;
|
|
|
|
if (strTemp == null || strTemp.Length == 0)
|
|
{
|
|
ret = false;
|
|
return ret;
|
|
}
|
|
|
|
try
|
|
{
|
|
if (cmd == "P")
|
|
dataSize = strTemp.Substring(14, strTemp.Length - 16);
|
|
else // "S"
|
|
dataSize = strTemp.Substring(10, strTemp.Length - 12);
|
|
|
|
size = int.Parse(strTemp.Substring(6, 4).Trim());
|
|
}
|
|
catch
|
|
{
|
|
ret = false;
|
|
return ret;
|
|
}
|
|
|
|
if (dataSize.Length == size)
|
|
ret = true;
|
|
else
|
|
ret = false;
|
|
|
|
return ret;
|
|
}
|
|
private bool ChksumCheck(string strTemp)
|
|
{
|
|
bool ret = false;
|
|
string chkSum = "", dataChksum = "";
|
|
|
|
if (strTemp == null || strTemp.Length == 0)
|
|
ret = false;
|
|
else
|
|
{
|
|
chkSum = strTemp.Substring(strTemp.Length - 2, 2);
|
|
dataChksum = this.Checksumcalculator(strTemp.Substring(0, strTemp.Length - 2));
|
|
|
|
if (chkSum == dataChksum)
|
|
ret = true;
|
|
else
|
|
ret = false;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
private string Checksumcalculator(string strTemp)
|
|
{
|
|
string chkSum = "";
|
|
byte[] temp;
|
|
int value = 0, first = 0, second = 0;
|
|
char char1, char2;
|
|
|
|
if (strTemp == null || strTemp.Length == 0)
|
|
chkSum = "cc";
|
|
else
|
|
{
|
|
temp = new UTF8Encoding().GetBytes(strTemp);
|
|
|
|
for (int i = 0; i < temp.Length; i++)
|
|
value += temp[i];
|
|
|
|
first = (value & 0x00f0) >> 4;
|
|
if (first > 9)
|
|
char1 = (char)(first + 0x37);
|
|
else
|
|
char1 = (char)(first + 0x30);
|
|
|
|
second = value & 0x000f;
|
|
if (second > 9)
|
|
char2 = (char)(second + 0x37);
|
|
else
|
|
char2 = (char)(second + 0x30);
|
|
|
|
chkSum = char1.ToString() + char2.ToString();
|
|
}
|
|
|
|
return chkSum;
|
|
}
|
|
private string Checksumcalculator(byte[] strTemp)
|
|
{
|
|
string chkSum = "";
|
|
byte[] temp;
|
|
int value = 0, first = 0, second = 0;
|
|
char char1, char2;
|
|
|
|
if (strTemp == null || strTemp.Length == 0)
|
|
chkSum = "cc";
|
|
else
|
|
{
|
|
temp = strTemp;
|
|
|
|
for (int i = 0; i < temp.Length; i++)
|
|
value += temp[i];
|
|
|
|
first = (value & 0x00f0) >> 4;
|
|
if (first > 9)
|
|
char1 = (char)(first + 0x37);
|
|
else
|
|
char1 = (char)(first + 0x30);
|
|
|
|
second = value & 0x000f;
|
|
if (second > 9)
|
|
char2 = (char)(second + 0x37);
|
|
else
|
|
char2 = (char)(second + 0x30);
|
|
|
|
chkSum = char1.ToString() + char2.ToString();
|
|
}
|
|
|
|
return chkSum;
|
|
}
|
|
private void SetCollectionForStringToByte(ref Collection<byte> collection, string value)
|
|
{
|
|
byte[] byteData;
|
|
|
|
if (collection == null)
|
|
return;
|
|
|
|
byteData = Encoding.UTF8.GetBytes(value);
|
|
for (int i = 0; i < byteData.Length; i++)
|
|
collection.Add(byteData[i]);
|
|
}
|
|
|
|
private void ChecklogPrint(string receiveData, WeightData weight)
|
|
{
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass
|
|
|| weight.JudgmentStatus == DataStore.JudgmentStatus.Over
|
|
|| weight.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
int tempWeight = 0;
|
|
bool sign = false;
|
|
string removeMinus = "";
|
|
if (weight.WeightString.StartsWith("-") == true)
|
|
{
|
|
removeMinus = weight.WeightString.Replace("-", "");
|
|
sign = true;
|
|
tempWeight = int.Parse(removeMinus);
|
|
}
|
|
else
|
|
tempWeight = int.Parse(weight.WeightString);
|
|
|
|
if (sign == true)
|
|
tempWeight *= -1;
|
|
|
|
bool tempFlag = false;
|
|
|
|
if (this.CurrentProductItem.OverRangeInt >= tempWeight && this.CurrentProductItem.UnderRangeInt <= tempWeight
|
|
&& weight.JudgmentStatus != DataStore.JudgmentStatus.Pass)
|
|
tempFlag = true;
|
|
|
|
if (this.CurrentProductItem.OverRangeInt < tempWeight && weight.JudgmentStatus != DataStore.JudgmentStatus.Over)
|
|
tempFlag = true;
|
|
|
|
if (this.CurrentProductItem.UnderRangeInt > tempWeight && weight.JudgmentStatus != DataStore.JudgmentStatus.Under)
|
|
tempFlag = true;
|
|
|
|
if (tempFlag == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Check ({0:yyyy-MM-dd HH:mm:ss}): {1},{2},{3}", DateTime.Now, receiveData, this.CurrentProductItem.UnderRange, this.CurrentProductItem.OverRange));
|
|
}
|
|
}
|
|
|
|
public int TransferData(string command, string id)
|
|
{
|
|
int ret = 0;
|
|
string chkSum = "cc";
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append(command);
|
|
sb.Append(id);
|
|
|
|
chkSum = this.Checksumcalculator(sb.ToString());
|
|
|
|
sb.Append(chkSum);
|
|
|
|
if (this.smartSerialPort2.IsOpen == true)
|
|
this.smartSerialPort2.WriteFrame(sb.ToString(), SmartSerialPort.CODETYPES.ASCIICODE);
|
|
|
|
// 통신 확인 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));
|
|
|
|
// 에러체크
|
|
if (this.IsErrorLogOpen == true && sb.ToString().StartsWith("Sr") == false)
|
|
this.smartFileCheckLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));
|
|
|
|
return ret;
|
|
}
|
|
public int TransferDataStream(string command, string id, string address, string data)
|
|
{
|
|
int ret = 0;
|
|
string chkSum = "cc";
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append(command);
|
|
sb.Append(id);
|
|
sb.Append(Helper.StringZeroFillDigits4(data.Length.ToString()));
|
|
sb.Append(address);
|
|
sb.Append(data);
|
|
|
|
chkSum = this.Checksumcalculator(sb.ToString());
|
|
|
|
sb.Append(chkSum);
|
|
|
|
if (this.smartSerialPort2.IsOpen == true)
|
|
this.smartSerialPort2.WriteFrame(sb.ToString(), SmartSerialPort.CODETYPES.ASCIICODE);
|
|
|
|
// 통신 확인 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));
|
|
|
|
// 에러체크
|
|
if (this.IsErrorLogOpen == true && sb.ToString().StartsWith("Pr") == false)
|
|
this.smartFileCheckLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));
|
|
|
|
return ret;
|
|
}
|
|
public int TransferDataStream(string command, string id, string address, string index, byte[] datas)
|
|
{
|
|
int ret = 0, count = 0;
|
|
byte[] byteData;
|
|
string chkSum = "cc";
|
|
Collection<byte> byteCollection = new Collection<byte>();
|
|
|
|
// command;
|
|
this.SetCollectionForStringToByte(ref byteCollection, command);
|
|
|
|
// id;
|
|
this.SetCollectionForStringToByte(ref byteCollection, id);
|
|
|
|
// data Length
|
|
count = datas.Length + index.Length;
|
|
this.SetCollectionForStringToByte(ref byteCollection, Helper.StringZeroFillDigits4(count.ToString()));
|
|
|
|
// address
|
|
this.SetCollectionForStringToByte(ref byteCollection, address);
|
|
|
|
// index
|
|
this.SetCollectionForStringToByte(ref byteCollection, index);
|
|
|
|
// datas
|
|
for (int i = 0; i < datas.Length; i++)
|
|
byteCollection.Add(datas[i]);
|
|
|
|
// chkSum
|
|
byteData = new byte[byteCollection.Count];
|
|
for (int i = 0; i < byteCollection.Count; i++)
|
|
byteData[i] = byteCollection[i];
|
|
chkSum = this.Checksumcalculator(byteData);
|
|
this.SetCollectionForStringToByte(ref byteCollection, chkSum);
|
|
|
|
// collection -> byte[]
|
|
byteData = new byte[byteCollection.Count];
|
|
for (int i = 0; i < byteCollection.Count; i++)
|
|
byteData[i] = byteCollection[i];
|
|
|
|
if (this.smartSerialPort2.IsOpen == true)
|
|
this.smartSerialPort2.WriteFrame(byteData);
|
|
|
|
// 통신 확인 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
{
|
|
string log = "";
|
|
|
|
for (int i = 0; i < byteCollection.Count; i++)
|
|
log += byteCollection[i].ToString("X2");
|
|
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, log));
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
private void ReceiveData()
|
|
{
|
|
int ret = 0;
|
|
string strTemp = "";
|
|
byte[] readByte;
|
|
|
|
SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;
|
|
|
|
try
|
|
{
|
|
receiveDataState = this.smartSerialPort2.ReadQueue(out readByte);
|
|
strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ((receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY) || (receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.FAILDATA))
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
switch (strTemp[0])
|
|
{
|
|
case 'C':
|
|
if ((ret = this.ReceiveCommandC(strTemp)) != 0)
|
|
return;
|
|
break;
|
|
case 'P':
|
|
if ((ret = this.ReceiveCommandP(strTemp)) != 0)
|
|
return;
|
|
break;
|
|
case 'S':
|
|
if ((ret = this.ReceiveCommandS(strTemp)) != 0)
|
|
return;
|
|
break;
|
|
case 'T':
|
|
if ((ret = this.ReceiveCommandT(strTemp)) != 0)
|
|
return;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
private int ReceiveCommandC(string strTemp)
|
|
{
|
|
int ret = 0;
|
|
string cmd = "";
|
|
|
|
if (this.ChksumCheck(strTemp) == false)
|
|
{
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Command Data CHKSUM Error", DateTime.Now, strTemp));
|
|
return ret = -1;
|
|
}
|
|
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
|
|
// 에러체크
|
|
if (this.IsErrorLogOpen == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
|
|
cmd = strTemp.Substring(0, 3);
|
|
|
|
switch (cmd)
|
|
{
|
|
case "CI0":
|
|
#region Main Board Booted
|
|
if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
|
|
{
|
|
this.CurrentSystemStatus.Equipment = DataStore.EquipmentStatus.Stop;
|
|
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
// 생산속도 Clear
|
|
this.CollectionWeightData[i].ProductionSpeed = 0;
|
|
// 정지 시간 저장
|
|
this.CollectionWeightData[i].StopTime = DateTime.Now;
|
|
this.CollectionWeightData[i].IsStart = false;
|
|
}
|
|
this.SaveCounterFile(this.CollectionWeightData);
|
|
}
|
|
else
|
|
{
|
|
// 생산속도 Clear
|
|
this.CurrentWeightData.ProductionSpeed = 0;
|
|
this.CurrentWeightData.IsStart = false;
|
|
|
|
// 정지 시간 저장
|
|
this.CurrentWeightData.StopTime = DateTime.Now;
|
|
this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);
|
|
}
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
|
|
}
|
|
// Write SystemParameter1
|
|
this.TransferParameter1();
|
|
#endregion
|
|
break;
|
|
case "CBI":
|
|
#region 공장초기화완료
|
|
if (this.ChildFormMenu != null)
|
|
this.ChildFormMenu.CenterEquipInitialize.UpdateDisplayMainBoardInitialization();
|
|
#endregion
|
|
break;
|
|
case "CBS":
|
|
#region 운전
|
|
this.CurrentSystemStatus.Equipment = DataStore.EquipmentStatus.Start;
|
|
|
|
// OPT1(액트라 - 안리쯔 금속검출기)
|
|
if (this.SystemConfig1.SerialCOM1Mode == 14)
|
|
this.TransferSerialCOM1(this.Transfer_14_OPT1("12"));
|
|
if (this.SystemConfig1.SerialCOM3Mode == 14)
|
|
this.TransferSerialCOM3(this.Transfer_14_OPT1("12"));
|
|
if (this.SystemConfig1.SerialCOM4Mode == 14)
|
|
this.TransferSerialCOM4(this.Transfer_14_OPT1("12"));
|
|
|
|
// 바코드
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
// STXANDETX
|
|
this.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.STXANDETX);
|
|
|
|
#region 바코드 사용
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
// 운전시 중량 0 으로 Clear
|
|
this.CollectionWeightData[i].Weight = 0.0;
|
|
|
|
// 운전 시간 저장
|
|
// 1번 품번 카운트가 0 이면 모든 품번 적용
|
|
if (this.CollectionWeightData[0].TotalCount == 0)
|
|
this.CollectionWeightData[i].StartTime = DateTime.Now;
|
|
}
|
|
|
|
this.SaveCounterFile(this.CollectionWeightData);
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 바코드 미사용
|
|
// 운전시 중량 0 으로 Clear
|
|
this.CurrentWeightData.Weight = 0.0;
|
|
|
|
// 운전 시간 저장
|
|
if (this.CurrentWeightData.TotalCount == 0)
|
|
{
|
|
this.CurrentWeightData.StartTime = DateTime.Now;
|
|
this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
// 이더넷
|
|
if (this.SystemConfig2.EthernetOperationMode == 2)
|
|
this.EthernetClientConnect();
|
|
|
|
if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
|
|
{
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
|
|
}
|
|
else
|
|
{
|
|
if (this.ChildFormMenu != null)
|
|
this.ChildFormMenu.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
|
|
}
|
|
|
|
this.IsLampOnDataSend = false;
|
|
this.IsBuzzerOnDataSend = false;
|
|
|
|
if (this.ChildFormMainDisplay.MainDisplayFeedback.IsUsingFeedback() == true)
|
|
this.ChildFormMainDisplay.MainDisplayFeedback.ItemChangeEnable(false);
|
|
#endregion
|
|
break;
|
|
case "CBT":
|
|
#region 정지
|
|
this.CurrentSystemStatus.Equipment = DataStore.EquipmentStatus.Stop;
|
|
|
|
// OPT1(액트라 - 안리쯔 금속검출기)
|
|
if (this.SystemConfig1.SerialCOM1Mode == 14)
|
|
this.TransferSerialCOM1(this.Transfer_14_OPT1("13"));
|
|
if (this.SystemConfig1.SerialCOM3Mode == 14)
|
|
this.TransferSerialCOM3(this.Transfer_14_OPT1("13"));
|
|
if (this.SystemConfig1.SerialCOM4Mode == 14)
|
|
this.TransferSerialCOM4(this.Transfer_14_OPT1("13"));
|
|
|
|
// 바코드
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
// 생산속도 Clear
|
|
this.CollectionWeightData[i].ProductionSpeed = 0;
|
|
// 정지 시간 저장
|
|
this.CollectionWeightData[i].StopTime = DateTime.Now;
|
|
}
|
|
|
|
this.SaveCounterFile(this.CollectionWeightData);
|
|
this.SaveSystemConfigurationFile1(this.SystemConfig1);
|
|
}
|
|
else
|
|
{
|
|
// 생산속도 Clear
|
|
this.CurrentWeightData.ProductionSpeed = 0;
|
|
|
|
// 정지 시간 저장
|
|
this.CurrentWeightData.StopTime = DateTime.Now;
|
|
this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);
|
|
}
|
|
|
|
// 통신 지연용 Queue Clear
|
|
this.ClearQueue();
|
|
|
|
// 이더넷
|
|
if (this.SystemConfig2.EthernetOperationMode == 2)
|
|
this.EthernetClientDisconnect();
|
|
|
|
if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
|
|
{
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
|
|
}
|
|
else
|
|
{
|
|
if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemIOTest)
|
|
{
|
|
if (this.ChildFormMenu.CenterSystemIOTest != null)
|
|
this.ChildFormMenu.CenterSystemIOTest.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
|
|
}
|
|
|
|
if (this.ChildFormMenu != null)
|
|
this.ChildFormMenu.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
|
|
}
|
|
|
|
if (this.SystemConfig1.IsDataBackup == true)
|
|
{
|
|
if (this.SystemConfig1.DatabackupFormat == 1)
|
|
{
|
|
// 데이터백업 포맷 : OPT1 - 정지 시 리젝데이터 STOP 처리
|
|
for (int i = 0; i < this.CollectionBufferWeightData.Count; i++)
|
|
{
|
|
this.CollectionBufferWeightData[i].Status = DataStore.JudgmentResult.STOP.ToString();
|
|
this.DataBackup1(this.CollectionBufferWeightData[i]);
|
|
}
|
|
this.CollectionBufferWeightData.Clear();
|
|
}
|
|
}
|
|
|
|
if (this.ChildFormMainDisplay.MainDisplayFeedback.IsUsingFeedback() == true)
|
|
this.ChildFormMainDisplay.MainDisplayFeedback.ItemChangeEnable(true);
|
|
#endregion
|
|
break;
|
|
case "CBE":
|
|
#region 소거
|
|
|
|
#endregion
|
|
break;
|
|
case "CBZ":
|
|
#region 영점
|
|
|
|
#endregion
|
|
break;
|
|
case "Csm":
|
|
#region 메뉴모드
|
|
if(this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
#endregion
|
|
break;
|
|
case "Csc":
|
|
#region 중량조정모드
|
|
if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
#endregion
|
|
break;
|
|
case "CBU":
|
|
this.ChildFormMenu.CenterEquipUpdate.UpdateMainBoardFinish();
|
|
break;
|
|
//case "Cmd":
|
|
// #region 업다운 - 다운
|
|
// this.ChildFormMainDisplay.ConveryorUpDownButtonUp(true);
|
|
// #endregion
|
|
// break;
|
|
//case "Cmu":
|
|
// #region 업다운 - Up
|
|
// this.ChildFormMainDisplay.ConveryorUpDownButtonUp(false);
|
|
// #endregion
|
|
// break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
private int ReceiveCommandP(string strTemp)
|
|
{
|
|
int ret = 0;
|
|
string cmd = "", address = "", lane = "", receiveData = "";
|
|
|
|
// SIZE 확인
|
|
if (this.SizeCheck("P", strTemp) == false)
|
|
{
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data SIZE Error", DateTime.Now, strTemp));
|
|
return ret = -1;
|
|
}
|
|
// CHKSUM 확인
|
|
if (this.ChksumCheck(strTemp) == false)
|
|
{
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data CHKSUM Error", DateTime.Now, strTemp));
|
|
return ret = -1;
|
|
}
|
|
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
|
|
cmd = strTemp.Substring(0, 3);
|
|
lane = strTemp.Substring(5, 1);
|
|
address = strTemp.Substring(10, 4);
|
|
receiveData = strTemp.Substring(14, strTemp.Length - 16);
|
|
|
|
// 에러체크
|
|
if (this.IsErrorLogOpen == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
|
|
switch (cmd)
|
|
{
|
|
case "PR0":
|
|
if ((ret = this.ReceiveCommandPR0(lane, address, receiveData)) != 0)
|
|
return ret = -1;
|
|
break;
|
|
case "PW0":
|
|
if ((ret = this.ReceiveCommandPW0(lane, address, receiveData)) != 0)
|
|
return ret = -1;
|
|
break;
|
|
case "PB0":
|
|
if ((ret = this.ReceiveCommandPB0(lane, address, receiveData)) != 0)
|
|
return ret = -1;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
private int ReceiveCommandS(string strTemp)
|
|
{
|
|
int ret = 0;
|
|
string cmd = "", lane = "", receiveData = "", dataID = "", transferCount = "";
|
|
|
|
// SIZE 확인
|
|
if (this.SizeCheck("S", strTemp) == false)
|
|
{
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data SIZE Error", DateTime.Now, strTemp));
|
|
return ret = -1;
|
|
}
|
|
// CHKSUM 확인
|
|
if (this.ChksumCheck(strTemp) == false)
|
|
{
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data CHKSUM Error", DateTime.Now, strTemp));
|
|
return ret = -1;
|
|
}
|
|
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
|
|
cmd = strTemp.Substring(0, 3);
|
|
dataID = strTemp.Substring(3, 1);
|
|
transferCount = strTemp.Substring(4, 1);
|
|
lane = strTemp.Substring(5, 1);
|
|
receiveData = strTemp.Substring(10, strTemp.Length - 12);
|
|
|
|
switch (cmd)
|
|
{
|
|
case "SN0":
|
|
if ((ret = this.ReceiveCommandSN0(lane, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "SR0":
|
|
if ((ret = this.ReceiveCommandSR0(lane, dataID, transferCount, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "SC0":
|
|
// 에러체크
|
|
if (this.IsErrorLogOpen == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
if ((ret = this.ReceiveCommandSC0(lane, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "ST0":
|
|
if ((ret = this.ReceiveCommandST0(lane, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "SF0":
|
|
// 에러체크
|
|
if (this.IsErrorLogOpen == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
if ((ret = this.ReceiveCommandSF0(lane, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "SG0":
|
|
if ((ret = this.ReceiveCommandSG0(lane, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "SD0":
|
|
// 에러체크
|
|
if (this.IsErrorLogOpen == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
|
|
if ((ret = this.ReceiveCommandSD0(lane, dataID, transferCount, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "SM0":
|
|
if ((ret = this.ReceiveCommandSM0(lane, dataID, transferCount, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
case "SB0":
|
|
if ((ret = this.ReceiveCommandSB0(lane, dataID, transferCount, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
// ex
|
|
#region ex
|
|
//if (cmd == "SG0")
|
|
//{
|
|
// byte[] a = new UTF8Encoding().GetBytes(strTemp.Substring(0, strTemp.Length - 2));
|
|
// int j = 0, first, second;
|
|
// char char1, char2;
|
|
// string value1 = "";
|
|
// for (int i = 0; i < a.Length; i++)
|
|
// {
|
|
// j += a[i];
|
|
// }
|
|
|
|
// first = (j & 0x00f0) >> 4;
|
|
// if (first > 9)
|
|
// char1 = (char)(first + 0x37);
|
|
// else
|
|
// char1 = (char)(first + 0x30);
|
|
|
|
// second = j & 0x000f;
|
|
// if (second > 9)
|
|
// char2 = (char)(second + 0x37);
|
|
// else
|
|
// char2 = (char)(second + 0x30);
|
|
|
|
// value1 = char1.ToString() + char2.ToString();
|
|
// this.ChildFormMenu.CenterSystemJudgmentSetting.UpdateChecksumDisplay(strTemp.Substring(strTemp.Length - 2, 2), value1);
|
|
//}
|
|
#endregion
|
|
|
|
return ret;
|
|
}
|
|
private int ReceiveCommandT(string strTemp)
|
|
{
|
|
int ret = 0;
|
|
string cmd = "", lane = "", receiveData = "";
|
|
|
|
// SIZE 확인
|
|
if (this.SizeCheck("T", strTemp) == false)
|
|
{
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data SIZE Error", DateTime.Now, strTemp));
|
|
return ret = -1;
|
|
}
|
|
// CHKSUM 확인
|
|
if (this.ChksumCheck(strTemp) == false)
|
|
{
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data CHKSUM Error", DateTime.Now, strTemp));
|
|
return ret = -1;
|
|
}
|
|
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true)
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
|
|
cmd = strTemp.Substring(0, 3);
|
|
lane = strTemp.Substring(5, 1);
|
|
receiveData = strTemp.Substring(10, strTemp.Length - 12);
|
|
|
|
switch (cmd)
|
|
{
|
|
case "TG0":
|
|
// IO테스트 그래프 데이터
|
|
//if ((ret = this.ReceiveCommandTG0(lane, receiveData)) != 0)
|
|
return ret;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
// 파라미터 읽기 응답
|
|
private int ReceiveCommandPR0(string lane, string address, string receiveData)
|
|
{
|
|
int ret = 0, iValue = 0;
|
|
string sValue = "";
|
|
|
|
try
|
|
{
|
|
switch (address)
|
|
{
|
|
case "1502":
|
|
#region Value Assign
|
|
this.SystemConfig1.MainBoardVersion = receiveData;
|
|
#endregion
|
|
if (this.ChildFormMenu.CenterInforSystem != null)
|
|
this.ChildFormMenu.CenterInforSystem.UpdateMainBoardVersionDisplay(this.SystemConfig1.MainBoardVersion);
|
|
break;
|
|
case "2001":
|
|
#region Value Assign
|
|
iValue = int.Parse(receiveData);
|
|
#endregion
|
|
if (iValue <= 0 || iValue > 1000)
|
|
return ret = -1;
|
|
this.SystemConfig1.ProductNumber = iValue;
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProgramVersion, "");
|
|
|
|
// 최초에 부팅이 완료 되었는지 확인
|
|
if (this.IsBootingComplete == false)
|
|
{
|
|
this.IsBootingComplete = true;
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterCount, "");
|
|
|
|
if (this.CurrentSystemStatus.CurrentDisplay != DataStore.DisplayStore.MainDisplay)
|
|
{
|
|
this.ChildFormMainDisplay.DisplayRefresh(this.CurrentSystemStatus);
|
|
this.smartForm.Show((int)DataStore.FormStore.FormMainDisplay);
|
|
}
|
|
this.ChildFormMainDisplay.CurrentBottomMenuControlEnable(DataStore.EquipmentStatus.Stop);
|
|
}
|
|
else
|
|
{
|
|
this.SaveCounterFile(this.CollectionWeightData);
|
|
this.TransferCountData(this.SystemConfig1.ProductNumber);
|
|
}
|
|
|
|
if (this.SystemConfig1.IsBarcodeEnable == true && this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
|
|
return ret;
|
|
|
|
// Save System File
|
|
this.SaveSystemConfigurationFile1(this.SystemConfig1);
|
|
// 생산속도 Clear
|
|
this.CurrentWeightData.ProductionSpeed = 0;
|
|
|
|
if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
|
|
{
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
|
|
}
|
|
else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemSorterSetting)
|
|
{
|
|
if (this.ChildFormMenu.CenterSystemSorterSetting != null)
|
|
this.ChildFormMenu.CenterSystemSorterSetting.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
|
|
}
|
|
else
|
|
{
|
|
if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
|
|
this.ChildFormMenu.CenterSystemJudgmentManual.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
|
|
}
|
|
|
|
if (this.SystemConfig2.EthernetOperationMode == 1 && this.smartTCPMultiServer.IsStart == true)
|
|
this.ChildFormMainDisplay.TimerServer(true);
|
|
|
|
if (this.ChildFormMainDisplay.MainDisplayFeedback.IsUsingFeedback() == true)
|
|
{
|
|
this.UpdateFeedbackData(this.CurrentProductItem, this.CurrentSystemParameter2);
|
|
this.UpdateFeedbackDeviation(this.CurrentProductItem, this.CurrentSystemParameter2);
|
|
}
|
|
|
|
// OverloadWeight 값 확인을 위한 MaxWeight 값 읽기
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead3901, "");
|
|
break;
|
|
case "2002":
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.OverRange, "");
|
|
break;
|
|
case "3601":
|
|
break;
|
|
case "3901":
|
|
break;
|
|
case "5057":
|
|
#region Value Assign
|
|
this.SensorDetectingTime = int.Parse(receiveData.Substring(0, 4).Trim());
|
|
#endregion
|
|
if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
|
|
this.ChildFormMenu.CenterSystemJudgmentManual.CaculateJudgmentData(this.SensorDetectingTime);
|
|
break;
|
|
case "5302":
|
|
break;
|
|
case "6901":
|
|
break;
|
|
case "9031":
|
|
#region Value Assign
|
|
this.CurrentWeightData.BoardProductNumber = int.Parse(receiveData.Substring(0, 4).Trim());
|
|
this.CurrentWeightData.BoardExNGCount = int.Parse(receiveData.Substring(4, 7).Trim());
|
|
this.CurrentWeightData.BoardOverCount = int.Parse(receiveData.Substring(11, 7).Trim());
|
|
this.CurrentWeightData.BoardPassCount = int.Parse(receiveData.Substring(18, 7).Trim());
|
|
this.CurrentWeightData.BoardUnderCount = int.Parse(receiveData.Substring(25, 7).Trim());
|
|
|
|
this.UpdateCountData(this.CurrentWeightData);
|
|
#endregion
|
|
break;
|
|
case "9512":
|
|
#region Value Assign
|
|
this.SystemInfo2.MaxWeight = receiveData.Substring(0, 7).Trim();
|
|
this.SystemInfo2.BalanceWeight = receiveData.Substring(7, 7).Trim();
|
|
this.SystemInfo2.Digit = receiveData.Substring(14, 7).Trim();
|
|
this.SystemInfo2.Calc = receiveData.Substring(21, 7).Trim();
|
|
this.SystemInfo2.Filter = receiveData.Substring(28, 4).Trim();
|
|
this.SystemInfo2.JudgmentDelay = receiveData.Substring(32, 4).Trim();
|
|
this.SystemInfo2.DoubleDelay = receiveData.Substring(36, 4).Trim();
|
|
this.SystemInfo2.JudgmentNumber = receiveData.Substring(40, 4).Trim();
|
|
this.SystemInfo2.Speed = receiveData.Substring(44, 4).Trim();
|
|
this.SystemInfo2.Dynamic = receiveData.Substring(48, 7).Trim();
|
|
this.SystemInfo2.SorterAMode = receiveData.Substring(55, 4).Trim();
|
|
this.SystemInfo2.SorterADelay = receiveData.Substring(59, 4).Trim();
|
|
this.SystemInfo2.SorterAOperation = receiveData.Substring(63, 4).Trim();
|
|
this.SystemInfo2.SorterBMode = receiveData.Substring(67, 4).Trim();
|
|
this.SystemInfo2.SorterBDelay = receiveData.Substring(71, 4).Trim();
|
|
this.SystemInfo2.SorterBOperation = receiveData.Substring(75, 4).Trim();
|
|
this.SystemInfo2.DoubleEntry = receiveData.Substring(79, 4).Trim();
|
|
this.SystemInfo2.ExternalInput = receiveData.Substring(83, 4).Trim();
|
|
this.SystemInfo2.ETCNG = receiveData.Substring(87, 4).Trim();
|
|
this.SystemInfo2.AutoZero1Time = receiveData.Substring(91, 4).Trim();
|
|
this.SystemInfo2.AutoZero1Range = receiveData.Substring(95, 4).Trim();
|
|
this.SystemInfo2.AutoZero1Variate = receiveData.Substring(99, 4).Trim();
|
|
this.SystemInfo2.AutoZero1Mode = receiveData.Substring(103, 4).Trim();
|
|
this.SystemInfo2.AutoZero2Mode = receiveData.Substring(107, 4).Trim();
|
|
this.SystemInfo2.AutoZero2Time = receiveData.Substring(111, 4).Trim();
|
|
this.SystemInfo2.AutoZero2Range = receiveData.Substring(115, 4).Trim();
|
|
this.SystemInfo2.AutoZero2Variate = receiveData.Substring(119, 4).Trim();
|
|
this.SystemInfo2.UnderRange = receiveData.Substring(123, 7).Trim();
|
|
this.SystemInfo2.PassRange = receiveData.Substring(130, 7).Trim();
|
|
this.SystemInfo2.OverRange = receiveData.Substring(137, 7).Trim();
|
|
this.SystemInfo2.TareRange = receiveData.Substring(144, 7).Trim();
|
|
#endregion
|
|
|
|
if (this.ChildFormMenu.CenterInforSystem2 != null)
|
|
this.ChildFormMenu.CenterInforSystem2.UpdateParameter1Display(this.SystemInfo2);
|
|
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead2, "");
|
|
break;
|
|
case "9513":
|
|
#region Value Assign
|
|
this.SystemInfo2.ExternalOutput1Mode = receiveData.Substring(0, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput1Delay = receiveData.Substring(4, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput1Operation = receiveData.Substring(8, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput2Mode = receiveData.Substring(12, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput2Delay = receiveData.Substring(16, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput2Operation = receiveData.Substring(20, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput3Mode = receiveData.Substring(24, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput3Delay = receiveData.Substring(28, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput3Operation = receiveData.Substring(32, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput4Mode = receiveData.Substring(36, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput4Delay = receiveData.Substring(40, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput4Operation = receiveData.Substring(44, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput9Mode = receiveData.Substring(48, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput9Delay = receiveData.Substring(52, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput9Operation = receiveData.Substring(56, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput10Mode = receiveData.Substring(60, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput10Delay = receiveData.Substring(64, 4).Trim();
|
|
this.SystemInfo2.ExternalOutput10Operation = receiveData.Substring(68, 4).Trim();
|
|
this.SystemInfo2.AscendDelay = receiveData.Substring(72, 4).Trim();
|
|
this.SystemInfo2.DescendDelay = receiveData.Substring(76, 4).Trim();
|
|
this.SystemInfo2.dummy1 = receiveData.Substring(80, 4).Trim();
|
|
this.SystemInfo2.dummy2 = receiveData.Substring(84, 4).Trim();
|
|
this.SystemInfo2.dummy3 = receiveData.Substring(88, 4).Trim();
|
|
this.SystemInfo2.dummy4 = receiveData.Substring(92, 4).Trim();
|
|
this.SystemInfo2.dummy5 = receiveData.Substring(96, 4).Trim();
|
|
this.SystemInfo2.dummy6 = receiveData.Substring(100, 4).Trim();
|
|
this.SystemInfo2.dummy7 = receiveData.Substring(104, 4).Trim();
|
|
this.SystemInfo2.dummy8 = receiveData.Substring(108, 4).Trim();
|
|
#endregion
|
|
|
|
if (this.ChildFormMenu.CenterInforSystem2 != null)
|
|
this.ChildFormMenu.CenterInforSystem2.UpdateParameter2Display(this.SystemInfo2);
|
|
break;
|
|
case "9514":
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead4, "");
|
|
break;
|
|
case "9515":
|
|
#region Value Assign
|
|
this.SystemInfo3.OPT1SampleNumber = receiveData.Substring(0, 4).Trim();
|
|
this.SystemInfo3.OPT1DelayNumber = receiveData.Substring(4, 4).Trim();
|
|
this.SystemInfo3.OPT1PulseWidth = receiveData.Substring(8, 4).Trim();
|
|
this.SystemInfo3.OPT1Using = receiveData.Substring(12, 4).Trim();
|
|
this.SystemInfo3.OPT1OverRange = receiveData.Substring(16, 7).Trim();
|
|
this.SystemInfo3.OPT1UnderRange = receiveData.Substring(23, 7).Trim();
|
|
this.SystemInfo3.OPT2Port = receiveData.Substring(30, 4).Trim();
|
|
this.SystemInfo3.OPT2Delay1 = receiveData.Substring(34, 4).Trim();
|
|
this.SystemInfo3.OPT2Delay2 = receiveData.Substring(38, 4).Trim();
|
|
this.SystemInfo3.BuzzerONTime = receiveData.Substring(42, 4).Trim();
|
|
this.SystemInfo3.Chattering = receiveData.Substring(46, 4).Trim();
|
|
this.SystemInfo3.Relay = receiveData.Substring(50, 4).Trim();
|
|
this.SystemInfo3.OptionBoard = receiveData.Substring(54, 4).Trim();
|
|
this.SystemInfo3.EquipmentType = receiveData.Substring(58, 4).Trim();
|
|
this.SystemInfo3.PhotoB = receiveData.Substring(62, 4).Trim();
|
|
this.SystemInfo3.PI3 = receiveData.Substring(66, 4).Trim();
|
|
this.SystemInfo3.PI4 = receiveData.Substring(70, 4).Trim();
|
|
this.SystemInfo3.PI5 = receiveData.Substring(74, 4).Trim();
|
|
this.SystemInfo3.PI6 = receiveData.Substring(78, 4).Trim();
|
|
this.SystemInfo3.PI7 = receiveData.Substring(82, 4).Trim();
|
|
this.SystemInfo3.PI8 = receiveData.Substring(86, 4).Trim();
|
|
this.SystemInfo3.dummy1 = receiveData.Substring(90, 4).Trim();
|
|
this.SystemInfo3.dummy2 = receiveData.Substring(94, 4).Trim();
|
|
this.SystemInfo3.dummy3 = receiveData.Substring(98, 4).Trim();
|
|
this.SystemInfo3.dummy4 = receiveData.Substring(102, 4).Trim();
|
|
this.SystemInfo3.dummy5 = receiveData.Substring(106, 4).Trim();
|
|
this.SystemInfo3.dummy6 = receiveData.Substring(110, 4).Trim();
|
|
this.SystemInfo3.dummy7 = receiveData.Substring(114, 4).Trim();
|
|
this.SystemInfo3.dummy8 = receiveData.Substring(118, 4).Trim();
|
|
this.SystemInfo3.dummy9 = receiveData.Substring(122, 4).Trim();
|
|
this.SystemInfo3.dummy10 = receiveData.Substring(126, 4).Trim();
|
|
#endregion
|
|
|
|
if (this.ChildFormMenu.CenterInforSystem3 != null)
|
|
this.ChildFormMenu.CenterInforSystem3.UpdateParameter2Display(this.SystemInfo3);
|
|
break;
|
|
case "9516":
|
|
#region Value Assign
|
|
this.BLDCParameter.VersionMajor = receiveData.Substring(0, 4);
|
|
this.BLDCParameter.VersionMinor = receiveData.Substring(4, 4);
|
|
this.BLDCParameter.VersionBuild = receiveData.Substring(8, 4);
|
|
this.BLDCParameter.Frequency = receiveData.Substring(12, 4);
|
|
this.BLDCParameter.MotorRPM = receiveData.Substring(16, 4);
|
|
this.BLDCParameter.MotorDirection = int.Parse(receiveData.Substring(20, 4));
|
|
this.BLDCParameter.AttenuatorRPM = receiveData.Substring(24, 4);
|
|
this.BLDCParameter.SelectOperMode = int.Parse(receiveData.Substring(28, 4));
|
|
#endregion
|
|
|
|
if (this.ChildFormMenu.CenterSystemBLDCMotorSetting != null)
|
|
this.ChildFormMenu.CenterSystemBLDCMotorSetting.UpdateParameter(this.BLDCParameter);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// 파라미터 쓰기 응답
|
|
private int ReceiveCommandPW0(string lane, string address, string receiveData)
|
|
{
|
|
int ret = 0, index = 0;
|
|
byte[] beforeData;
|
|
string ack = "", data = "";
|
|
DataStore.ResponseData response = DataStore.ResponseData.NAK;
|
|
|
|
try
|
|
{
|
|
if (receiveData == "0")
|
|
response = DataStore.ResponseData.NAK;
|
|
else
|
|
response = DataStore.ResponseData.ACK;
|
|
|
|
switch (address)
|
|
{
|
|
case "1651":
|
|
#region 업데이트
|
|
#region Value Assign
|
|
try
|
|
{
|
|
index = int.Parse(receiveData.Substring(0, 4));
|
|
}
|
|
catch
|
|
{
|
|
index = 0;
|
|
}
|
|
ack = receiveData.Substring(4, 4);
|
|
#endregion
|
|
|
|
if (ack == "0001")
|
|
response = DataStore.ResponseData.ACK;
|
|
else
|
|
response = DataStore.ResponseData.NAK;
|
|
|
|
if (this.UpdateForMain.Index == index)
|
|
{
|
|
this.smartTimerUpdate.Stop();
|
|
if (response == DataStore.ResponseData.ACK)
|
|
{
|
|
beforeData = new byte[this.UpdateForMain.ByteData.Length];
|
|
for (int i = 0; i < this.UpdateForMain.ByteData.Length; i++)
|
|
beforeData[i] = this.UpdateForMain.ByteData[i];
|
|
|
|
if (this.UpdateForMain.IsLastData == false)
|
|
{
|
|
this.UpdateForMain.ByteData = new byte[beforeData.Length - 100];
|
|
for (int i = 0; i < beforeData.Length - 100; i++)
|
|
this.UpdateForMain.ByteData[i] = beforeData[100 + i];
|
|
this.UpdateForMain.Index++;
|
|
|
|
this.SendUpdateForMain(this.UpdateForMain.ByteData);
|
|
}
|
|
else
|
|
{
|
|
this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(5);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.RetryUpdateForMain(this.UpdateForMain);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.smartTimerUpdate.Stop();
|
|
this.ChildFormMenu.CenterEquipUpdate.UpdateMainBoardFail(this.SystemConfig1.Language);
|
|
}
|
|
#endregion
|
|
break;
|
|
case "4004":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead4901, "");
|
|
break;
|
|
case "4005":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead4902, "");
|
|
break;
|
|
case "9006":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferProductParameter(this.SystemConfig1.ProductNumber);
|
|
break;
|
|
case "9007":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProductNumber, "");
|
|
break;
|
|
case "9018":
|
|
if (response == DataStore.ResponseData.ACK && this.CurrentSystemStatus.CurrentDisplay != DataStore.DisplayStore.EquipFuctionSetting)
|
|
this.TransferParameter2();
|
|
break;
|
|
case "9019":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferParameter3();
|
|
break;
|
|
case "9020":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferParameter4();
|
|
break;
|
|
case "9021":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferRandomMode();
|
|
break;
|
|
case "9023":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferBLDCMotorData();
|
|
break;
|
|
case "9033":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProductNumber, "");
|
|
break;
|
|
case "9031":
|
|
break;
|
|
case "9040":
|
|
if (response == DataStore.ResponseData.ACK)
|
|
{
|
|
if (this.SystemConfig2.IsUsingRandomMode == true)
|
|
this.SystemConfig1.ProductNumber = 996;
|
|
this.TransferProductParameter(this.SystemConfig1.ProductNumber);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// Bypass to motor
|
|
private int ReceiveCommandPB0(string lane, string address, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
DataStore.ResponseData response = DataStore.ResponseData.NAK;
|
|
|
|
try
|
|
{
|
|
if (receiveData == "0000")
|
|
response = DataStore.ResponseData.NAK;
|
|
else
|
|
response = DataStore.ResponseData.ACK;
|
|
|
|
switch (address)
|
|
{
|
|
case "1101":
|
|
break;
|
|
case "1102":
|
|
break;
|
|
case "1103":
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
// 정지시 중량
|
|
private int ReceiveCommandSN0(string lane, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
|
|
try
|
|
{
|
|
switch (lane)
|
|
{
|
|
case "A":
|
|
#region Value Assign
|
|
if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Stop)
|
|
{
|
|
this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
|
|
this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
|
|
this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
|
|
this.CurrentWeightData.WeightString = receiveData.Substring(5, 5);
|
|
this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
|
|
}
|
|
else
|
|
{
|
|
this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
|
|
this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
|
|
}
|
|
#endregion
|
|
if (this.CurrentWeightData.WeightString.Trim() == "-9999" || this.CurrentWeightData.WeightString.Trim() == "9999"
|
|
|| this.CurrentWeightData.WeightString.Trim() == "99999")
|
|
if (this.IsErrorLogOpen == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Check ({0:yyyy-MM-dd HH:mm:ss}): {1},{2},{3}", DateTime.Now, receiveData, this.CurrentProductItem.UnderRange, this.CurrentProductItem.OverRange));
|
|
|
|
// V6.2.0
|
|
if (this.OverloadWeight <= this.CurrentWeightData.Weight)
|
|
{
|
|
this.CurrentWeightData.WeightString = this.CurrentCalibrationItem.OverloadWeightString;
|
|
this.CurrentWeightData.Weight = this.OverloadWeight;
|
|
}
|
|
|
|
if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
|
|
{
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateStopWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// 운전시 중량(여기서 변경되는 부분은 SM0에도 적용해야 함)
|
|
private int ReceiveCommandSR0(string lane, string dataID, string transferCount, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
int temp = 0;
|
|
|
|
try
|
|
{
|
|
switch (lane)
|
|
{
|
|
case "A":
|
|
#region Value Assign
|
|
this.CurrentWeightData.JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
|
|
this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
|
|
this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
|
|
this.CurrentWeightData.WeightString = receiveData.Substring(5, 5);
|
|
this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
|
|
//this.CurrentWeightData.ProductionSpeed = int.Parse(receiveData.Substring(15, 4).Trim());
|
|
|
|
this.CurrentWeightData.WeightSum(this.CurrentWeightData.JudgmentStatus);
|
|
this.CurrentWeightData.SetDataIDTransferCount(dataID, transferCount);
|
|
|
|
this.CurrentWeightData.Status = DataStore.WeightStatus.WeightChange;
|
|
#endregion
|
|
// 통신 제대로 받으면 ACK
|
|
this.TransferData(string.Format("{0}{1}{2}{3}", CommunicationCommand.RunWeightData, (int)DataStore.ResponseData.ACK, dataID, transferCount), CommunicationID.MainBoard);
|
|
|
|
if (this.CurrentWeightData.WeightString.Trim() == "-9999" || this.CurrentWeightData.WeightString.Trim() == "9999"
|
|
|| this.CurrentWeightData.WeightString.Trim() == "99999")
|
|
if (this.IsErrorLogOpen == true)
|
|
this.smartFileCheckLog.WriteString(string.Format("Check ({0:yyyy-MM-dd HH:mm:ss}): {1},{2},{3}", DateTime.Now, receiveData, this.CurrentProductItem.UnderRange, this.CurrentProductItem.OverRange));
|
|
|
|
if (this.IsErrorLogOpen == true)
|
|
this.ChecklogPrint(receiveData, this.CurrentWeightData);
|
|
|
|
// V6.2.0
|
|
if (this.OverloadWeight <= this.CurrentWeightData.Weight)
|
|
{
|
|
this.CurrentWeightData.WeightString = this.CurrentCalibrationItem.OverloadWeightString;
|
|
this.CurrentWeightData.Weight = this.OverloadWeight;
|
|
}
|
|
|
|
#region 통신
|
|
// 통신 COM1
|
|
if (this.SystemConfig1.SerialCOM1Mode != 0)
|
|
{
|
|
#region COM1
|
|
switch (this.SystemConfig1.SerialCOM1Mode)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM1(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM1(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.TransferSerialCOM1(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM1_Step = 1;
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.TransferSerialCOM1(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.TransferSerialCOM1(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.TransferSerialCOM1(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.TransferSerialCOM1(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM1));
|
|
break;
|
|
case 10:
|
|
this.TransferSerialCOM1(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.TransferSerialCOM1(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.TransferSerialCOM1(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.TransferSerialCOM1(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17 :
|
|
this.TransferSerialCOM1(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.TransferSerialCOM1(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.TransferSerialCOM1(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.TransferSerialCOM1(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.SerialMode.f23_STD2:
|
|
this.TransferSerialCOM1(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
// 통신 COM3
|
|
if (this.SystemConfig1.SerialCOM3Mode != 0)
|
|
{
|
|
#region COM3
|
|
switch (this.SystemConfig1.SerialCOM3Mode)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM3(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM3(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.TransferSerialCOM3(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM3_Step = 1;
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.TransferSerialCOM3(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.TransferSerialCOM3(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.TransferSerialCOM3(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.TransferSerialCOM3(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM3));
|
|
break;
|
|
case 10:
|
|
this.TransferSerialCOM3(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.TransferSerialCOM3(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.TransferSerialCOM3(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.TransferSerialCOM3(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.TransferSerialCOM3(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.TransferSerialCOM3(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.TransferSerialCOM3(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.TransferSerialCOM3(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.SerialMode.f23_STD2:
|
|
this.TransferSerialCOM3(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
// 통신 COM4
|
|
if (this.SystemConfig1.SerialCOM4Mode != 0)
|
|
{
|
|
#region COM4
|
|
switch (this.SystemConfig1.SerialCOM4Mode)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM4(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM4(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.TransferSerialCOM4(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM4_Step = 1;
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.TransferSerialCOM4(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.TransferSerialCOM4(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.TransferSerialCOM4(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.TransferSerialCOM4(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM4));
|
|
break;
|
|
case 10:
|
|
this.TransferSerialCOM4(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.TransferSerialCOM4(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.TransferSerialCOM4(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.TransferSerialCOM4(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.TransferSerialCOM4(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.TransferSerialCOM4(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.TransferSerialCOM4(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.TransferSerialCOM4(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.SerialMode.f23_STD2:
|
|
this.TransferSerialCOM4(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
// 이더넷
|
|
switch (this.SystemConfig2.EthernetOperationMode)
|
|
{
|
|
case 1:
|
|
if (this.smartTCPMultiServer.ClientInfoList != null)
|
|
{
|
|
if (this.SystemConfig2.EthernetCommMode != 0)
|
|
{
|
|
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
|
|
{
|
|
#region Server
|
|
switch (this.SystemConfig2.EthernetCommMode)
|
|
{
|
|
case 1:
|
|
this.EthernetServerSendMessage(client,
|
|
this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.EthernetServerSendMessage(client, this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.EthernetServerSendMessage(client, this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM1_Step = 1;
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.EthernetServerSendMessage(client, this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.EthernetServerSendMessage(client, this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.EthernetServerSendMessage(client, this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.EthernetServerSendMessage(client, this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM1));
|
|
break;
|
|
case 10:
|
|
this.EthernetServerSendMessage(client, this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.EthernetServerSendMessage(client, this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.EthernetServerSendMessage(client, this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.EthernetServerSendMessage(client, this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.EthernetServerSendMessage(client, this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.EthernetServerSendMessage(client, this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.EthernetMode.f23_STD2:
|
|
this.EthernetServerSendMessage(client,
|
|
this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 2:
|
|
if (this.SystemConfig2.EthernetCommMode != 0)
|
|
{
|
|
#region Client
|
|
switch (this.SystemConfig2.EthernetCommMode)
|
|
{
|
|
case 1:
|
|
this.EthernetWeightData(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.EthernetWeightData(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.EthernetWeightData(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM1_Step = 1;
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.EthernetWeightData(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.EthernetWeightData(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.EthernetWeightData(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.EthernetWeightData(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM1));
|
|
break;
|
|
case 10:
|
|
this.EthernetWeightData(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.EthernetWeightData(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.EthernetWeightData(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.EthernetWeightData(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.EthernetWeightData(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.EthernetWeightData(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.EthernetWeightData(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.EthernetWeightData(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.EthernetMode.f23_STD2:
|
|
this.EthernetWeightData(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
|
|
#region 카운터출력
|
|
|
|
#region Counting Output 1
|
|
temp = this.SystemConfig2.CountingOutput1Number;
|
|
|
|
if (this.SystemConfig2.CountingOutput1Mode != 0 && temp != 0)
|
|
{
|
|
switch (this.SystemConfig2.CountingOutput1Mode)
|
|
{
|
|
case 1: // Pass
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
case 2: // NG
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over
|
|
|| this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
case 3: // Over
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
case 4: // Under
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23. 알람 조건이 충족하여 장비가 정지되었습니다
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Counting Output 2
|
|
temp = this.SystemConfig2.CountingOutput2Number;
|
|
|
|
if (this.SystemConfig2.CountingOutput2Mode != 0 && temp != 0)
|
|
{
|
|
switch (this.SystemConfig2.CountingOutput2Mode)
|
|
{
|
|
case 1: // Pass
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
case 2: // NG
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over
|
|
|| this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
case 3: // Over
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
case 4: // Under
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
this.ChildFormMainDisplay.MainDisplayWeightBigScreen.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
|
|
this.ChildFormMainDisplay.MainDisplayWeightSmall.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
|
|
#endregion
|
|
|
|
// CurrentDisplay
|
|
switch (this.CurrentSystemStatus.CurrentDisplay)
|
|
{
|
|
case DataStore.DisplayStore.MainDisplay:
|
|
#region MainDisplay
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
this.CurrentBarcode.BarcodeDequeue();
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateBarcodeDisplay(this.CurrentBarcode);
|
|
|
|
if (this.CurrentBarcode.GetQueueCount > 0)
|
|
this.BarcodeProductChange(this.CurrentBarcode);
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
|
|
}
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateStartWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
|
|
|
|
if (this.SystemConfig1.IsDataBackup == true)
|
|
{
|
|
if (this.SystemConfig1.DatabackupFormat == 1)
|
|
{
|
|
#region OPT1 - 종근당 옵션
|
|
if (this.timeOut.Enabled == true)
|
|
this.timeOut.Enabled = false;
|
|
|
|
//if (this.CollectionBufferWeightData.Count != 0)
|
|
//{
|
|
// if (this.CurrentJudgmentResult.PreviousRejectData != DataStore.JudgmentResult.None)
|
|
// this.CollectionBufferWeightData[0].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
|
|
// else
|
|
// this.CollectionBufferWeightData[0].Status = DataStore.JudgmentResult.OM.ToString();
|
|
// this.DataBackup1(this.CollectionBufferWeightData[0]);
|
|
// this.CollectionBufferWeightData.Clear();
|
|
//}
|
|
|
|
this.CollectionBufferWeightData.Add(new DataBackupOPT1());
|
|
this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].SetData(
|
|
this.CurrentProductItem, this.CurrentWeightData, this.SystemConfig1, DateTime.Now);
|
|
|
|
if (this.CurrentJudgmentSetItem.Sorter2Mode == 3)
|
|
this.timeOut.Interval = (this.CurrentJudgmentSetItem.Sorter2DelayTime * 2) + (this.CurrentJudgmentSetItem.Sorter2RunTime * 5) + 1000;
|
|
else
|
|
this.timeOut.Interval = (this.CurrentJudgmentSetItem.Sorter1DelayTime * 2) + (this.CurrentJudgmentSetItem.Sorter1RunTime * 5) + 1000;
|
|
this.timeOut.Enabled = true;
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region STD1
|
|
if (this.CurrentWeightData.JudgmentStatus != DataStore.JudgmentStatus.Empty)
|
|
this.DataBackup0(this.CurrentWeightData);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
// 표준분포
|
|
this.CurrentWeightData.SetNormalDistribution(this.CurrentProductItem.CollectionNormalDistributionRange, this.CurrentWeightData.WeightString);
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// 랜덤모드 사용 시 운전시 중량
|
|
private int ReceiveCommandSM0(string lane, string dataID, string transferCount, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
int temp = 0;
|
|
|
|
try
|
|
{
|
|
switch (lane)
|
|
{
|
|
case "A":
|
|
#region Value Assign
|
|
this.SystemConfig1.ProductNumber = int.Parse(receiveData.Substring(0, 4));
|
|
|
|
this.CurrentWeightData.JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(4, 2));
|
|
this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(6, 3));
|
|
this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(9, 5), this.SystemConfig1.DecimalPlaces);
|
|
this.CurrentWeightData.WeightString = receiveData.Substring(9, 5);
|
|
this.CurrentWeightData.ADCValue = receiveData.Substring(14, 5);
|
|
this.CurrentWeightData.ProductionSpeed = int.Parse(receiveData.Substring(19, 4).Trim());
|
|
|
|
this.CurrentWeightData.WeightSum(this.CurrentWeightData.JudgmentStatus);
|
|
this.CurrentWeightData.SetDataIDTransferCount(dataID, transferCount);
|
|
|
|
this.CurrentWeightData.Status = DataStore.WeightStatus.WeightChange;
|
|
#endregion
|
|
// 통신 제대로 받으면 ACK
|
|
this.TransferData(string.Format("{0}{1}{2}{3}", CommunicationCommand.RunWeightData, (int)DataStore.ResponseData.ACK, dataID, transferCount), CommunicationID.MainBoard);
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment,
|
|
this.CurrentProductItem, this.CurrentWeightData);
|
|
|
|
// V6.2.0
|
|
if (this.OverloadWeight <= this.CurrentWeightData.Weight)
|
|
{
|
|
this.CurrentWeightData.WeightString = this.CurrentCalibrationItem.OverloadWeightString;
|
|
this.CurrentWeightData.Weight = this.OverloadWeight;
|
|
}
|
|
|
|
#region 통신
|
|
// 통신 COM1
|
|
if (this.SystemConfig1.SerialCOM1Mode != 0)
|
|
{
|
|
#region COM1
|
|
switch (this.SystemConfig1.SerialCOM1Mode)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM1(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM1(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.TransferSerialCOM1(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM1_Step = 1;
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.TransferSerialCOM1(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.TransferSerialCOM1(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.TransferSerialCOM1(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.TransferSerialCOM1(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM1));
|
|
break;
|
|
case 10:
|
|
this.TransferSerialCOM1(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.TransferSerialCOM1(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.TransferSerialCOM1(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.TransferSerialCOM1(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.TransferSerialCOM1(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.TransferSerialCOM1(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.TransferSerialCOM1(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.TransferSerialCOM1(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM1(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.SerialMode.f23_STD2:
|
|
this.TransferSerialCOM1(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
// 통신 COM3
|
|
if (this.SystemConfig1.SerialCOM3Mode != 0)
|
|
{
|
|
#region COM3
|
|
switch (this.SystemConfig1.SerialCOM3Mode)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM3(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM3(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.TransferSerialCOM3(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM3_Step = 1;
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.TransferSerialCOM3(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.TransferSerialCOM3(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.TransferSerialCOM3(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.TransferSerialCOM3(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM3));
|
|
break;
|
|
case 10:
|
|
this.TransferSerialCOM3(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.TransferSerialCOM3(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.TransferSerialCOM3(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.TransferSerialCOM3(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.TransferSerialCOM3(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.TransferSerialCOM3(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.TransferSerialCOM3(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.TransferSerialCOM3(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM3(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.SerialMode.f23_STD2:
|
|
this.TransferSerialCOM3(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
// 통신 COM4
|
|
if (this.SystemConfig1.SerialCOM4Mode != 0)
|
|
{
|
|
#region COM4
|
|
switch (this.SystemConfig1.SerialCOM4Mode)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM4(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM4(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.TransferSerialCOM4(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM4_Step = 1;
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.TransferSerialCOM4(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.TransferSerialCOM4(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.TransferSerialCOM4(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.TransferSerialCOM4(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM4));
|
|
break;
|
|
case 10:
|
|
this.TransferSerialCOM4(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.TransferSerialCOM4(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.TransferSerialCOM4(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.TransferSerialCOM4(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.TransferSerialCOM4(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.TransferSerialCOM4(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.TransferSerialCOM4(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.TransferSerialCOM4(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM4(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.SerialMode.f23_STD2:
|
|
this.TransferSerialCOM4(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
// 이더넷
|
|
switch (this.SystemConfig2.EthernetOperationMode)
|
|
{
|
|
case 1:
|
|
if (this.smartTCPMultiServer.ClientInfoList != null)
|
|
{
|
|
if (this.SystemConfig2.EthernetCommMode != 0)
|
|
{
|
|
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
|
|
{
|
|
#region Server
|
|
switch (this.SystemConfig2.EthernetCommMode)
|
|
{
|
|
case 1:
|
|
this.EthernetServerSendMessage(client,
|
|
this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.EthernetServerSendMessage(client, this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.EthernetServerSendMessage(client, this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM1_Step = 1;
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.EthernetServerSendMessage(client, this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.EthernetServerSendMessage(client, this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.EthernetServerSendMessage(client, this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.EthernetServerSendMessage(client, this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM1));
|
|
break;
|
|
case 10:
|
|
this.EthernetServerSendMessage(client, this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.EthernetServerSendMessage(client, this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.EthernetServerSendMessage(client, this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.EthernetServerSendMessage(client, this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.EthernetServerSendMessage(client, this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.EthernetServerSendMessage(client, this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetServerSendMessage(client, this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.EthernetMode.f23_STD2:
|
|
this.EthernetServerSendMessage(client,
|
|
this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 2:
|
|
if (this.SystemConfig2.EthernetCommMode != 0)
|
|
{
|
|
#region Client
|
|
switch (this.SystemConfig2.EthernetCommMode)
|
|
{
|
|
case 1:
|
|
this.EthernetWeightData(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 2:
|
|
this.EthernetWeightData(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 3:
|
|
if (this.SystemConfig1.IsPrintPerProductEnable == true)
|
|
this.EthernetWeightData(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 4:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case 5:
|
|
this.HMCOM1_Step = 1;
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 6:
|
|
this.EthernetWeightData(this.Transfer_6_OPT0(this.CurrentWeightData));
|
|
break;
|
|
case 7:
|
|
this.EthernetWeightData(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 8:
|
|
this.EthernetWeightData(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
|
|
break;
|
|
case 9:
|
|
this.EthernetWeightData(this.Transfer_9_Hitachi(this.CurrentWeightData, DataStore.SerialCOM.COM1));
|
|
break;
|
|
case 10:
|
|
this.EthernetWeightData(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 11:
|
|
this.EthernetWeightData(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 12:
|
|
this.EthernetWeightData(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 13:
|
|
this.EthernetWeightData(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
|
|
break;
|
|
case 17:
|
|
this.EthernetWeightData(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
case 18:
|
|
this.EthernetWeightData(this.Transfer_18_HP200(this.CurrentWeightData, 1));
|
|
this.EthernetWeightData(this.Transfer_18_HP200(this.CurrentWeightData, 2));
|
|
break;
|
|
case 19:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
this.EthernetWeightData(this.Transfer_19_SmartJet(this.CurrentWeightData));
|
|
break;
|
|
case 20:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
|
|
}
|
|
else
|
|
{
|
|
this.EthernetWeightData(this.RoomChange9410(1)); // 1번방 변경
|
|
Thread.Sleep(200);
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ACK)); // ACK
|
|
}
|
|
break;
|
|
case (int)DataStore.EthernetMode.f23_STD2:
|
|
this.EthernetWeightData(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion
|
|
|
|
#region 카운터출력
|
|
|
|
#region Counting Output 1
|
|
temp = this.SystemConfig2.CountingOutput1Number;
|
|
|
|
if (this.SystemConfig2.CountingOutput1Mode != 0 && temp != 0)
|
|
{
|
|
switch (this.SystemConfig2.CountingOutput1Mode)
|
|
{
|
|
case 1: // Pass
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
case 2: // NG
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over
|
|
|| this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
case 3: // Over
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
case 4: // Under
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput1Count++;
|
|
|
|
if (this.CountingOutput1Count >= temp)
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23. 알람 조건이 충족하여 장비가 정지되었습니다
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput1Continuous == true)
|
|
this.CountingOutput1Count = 0;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Counting Output 2
|
|
temp = this.SystemConfig2.CountingOutput2Number;
|
|
|
|
if (this.SystemConfig2.CountingOutput2Mode != 0 && temp != 0)
|
|
{
|
|
switch (this.SystemConfig2.CountingOutput2Mode)
|
|
{
|
|
case 1: // Pass
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
case 2: // NG
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over
|
|
|| this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
case 3: // Over
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
case 4: // Under
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
|
|
{
|
|
this.CountingOutput2Count++;
|
|
|
|
if (this.CountingOutput2Count >= temp)
|
|
{
|
|
this.CountingOutput2Count = 0;
|
|
|
|
if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
|
|
this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
|
|
if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
|
|
{
|
|
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
|
|
// 메시지 23
|
|
this.StartThreadMessage1();
|
|
}
|
|
if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
|
|
this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.SystemConfig2.IsCountingOutput2Continuous == true)
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
this.ChildFormMainDisplay.MainDisplayWeightBigScreen.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
|
|
this.ChildFormMainDisplay.MainDisplayWeightSmall.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
|
|
#endregion
|
|
|
|
// CurrentDisplay
|
|
switch (this.CurrentSystemStatus.CurrentDisplay)
|
|
{
|
|
case DataStore.DisplayStore.MainDisplay:
|
|
#region MainDisplay
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
this.CurrentBarcode.BarcodeDequeue();
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateBarcodeDisplay(this.CurrentBarcode);
|
|
|
|
if (this.CurrentBarcode.GetQueueCount > 0)
|
|
this.BarcodeProductChange(this.CurrentBarcode);
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
|
|
}
|
|
|
|
if (this.ChildFormMainDisplay != null)
|
|
this.ChildFormMainDisplay.UpdateStartWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
|
|
|
|
if (this.SystemConfig1.IsDataBackup == true)
|
|
{
|
|
if (this.SystemConfig1.DatabackupFormat == 1)
|
|
{
|
|
#region OPT1 - 종근당 옵션
|
|
if (this.timeOut.Enabled == true)
|
|
this.timeOut.Enabled = false;
|
|
|
|
//if (this.CollectionBufferWeightData.Count != 0)
|
|
//{
|
|
// if (this.CurrentJudgmentResult.PreviousRejectData != DataStore.JudgmentResult.None)
|
|
// this.CollectionBufferWeightData[0].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
|
|
// else
|
|
// this.CollectionBufferWeightData[0].Status = DataStore.JudgmentResult.OM.ToString();
|
|
// this.DataBackup1(this.CollectionBufferWeightData[0]);
|
|
// this.CollectionBufferWeightData.Clear();
|
|
//}
|
|
|
|
this.CollectionBufferWeightData.Add(new DataBackupOPT1());
|
|
this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].SetData(
|
|
this.CurrentProductItem, this.CurrentWeightData, this.SystemConfig1, DateTime.Now);
|
|
|
|
if (this.CurrentJudgmentSetItem.Sorter2Mode == 3)
|
|
this.timeOut.Interval = (this.CurrentJudgmentSetItem.Sorter2DelayTime * 2) + (this.CurrentJudgmentSetItem.Sorter2RunTime * 5) + 1000;
|
|
else
|
|
this.timeOut.Interval = (this.CurrentJudgmentSetItem.Sorter1DelayTime * 2) + (this.CurrentJudgmentSetItem.Sorter1RunTime * 5) + 1000;
|
|
this.timeOut.Enabled = true;
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region STD1
|
|
if (this.CurrentWeightData.JudgmentStatus != DataStore.JudgmentStatus.Empty)
|
|
this.DataBackup0(this.CurrentWeightData);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
// 표준분포
|
|
this.CurrentWeightData.SetNormalDistribution(this.CurrentProductItem.CollectionNormalDistributionRange, this.CurrentWeightData.WeightString);
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// 중량조정시 중량
|
|
private int ReceiveCommandSC0(string lane, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
|
|
switch (lane)
|
|
{
|
|
case "A":
|
|
#region Value Assign
|
|
this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
|
|
this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
|
|
this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
|
|
this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
|
|
#endregion
|
|
if (this.ChildFormMenu.CenterSystemCalibration != null)
|
|
this.ChildFormMenu.CenterSystemCalibration.UpdateWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// IO테스트-IN
|
|
private int ReceiveCommandST0(string lane, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
|
|
switch (lane)
|
|
{
|
|
case "0":
|
|
#region Value Assign
|
|
for (int i = 0; i < 8; i++)
|
|
this.CollectionIOTest_InputData[i] = receiveData.Substring(i, 1);
|
|
#endregion
|
|
if (this.CurrentSystemStatus.CurrentMode == DataStore.DisplayMode.IOTest)
|
|
{
|
|
if (this.ChildFormMenu.CenterSystemIOTest != null)
|
|
this.ChildFormMenu.CenterSystemIOTest.UpdateInputRead(this.CollectionIOTest_InputData);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// 판정설정시 중량 - 정지
|
|
private int ReceiveCommandSF0(string lane, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
|
|
switch (lane)
|
|
{
|
|
case "A":
|
|
#region Value Assign
|
|
this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
|
|
this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
|
|
this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
|
|
this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
|
|
#endregion
|
|
if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
|
|
this.ChildFormMenu.CenterSystemJudgmentManual.UpdateStopWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// 판정설정 그래프
|
|
private int ReceiveCommandSG0(string lane, string receiveData)
|
|
{
|
|
int ret = 0, temp = 15;
|
|
|
|
switch (lane)
|
|
{
|
|
case "A":
|
|
#region Value Assign
|
|
this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
|
|
this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
|
|
this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
|
|
this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
|
|
|
|
//for (int i = 0; i < this.CollectionGraphData.Count; i++)
|
|
//{
|
|
// this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
|
|
// temp += 5;
|
|
//}
|
|
#endregion
|
|
//if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
|
|
// this.ChildFormMenu.CenterSystemJudgmentManual.UpdateGraphDataDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData, this.CollectionGraphData);
|
|
if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
|
|
this.ChildFormMenu.CenterSystemJudgmentManual.UpdateDataDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
// 리젝데이터
|
|
private int ReceiveCommandSD0(string lane, string dataID, string transferCount, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (this.timeOut.Enabled == true)
|
|
this.timeOut.Enabled = false;
|
|
|
|
this.ConverterResult(receiveData);
|
|
|
|
if (this.CollectionBufferWeightData.Count > 0)
|
|
{
|
|
if (this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].DataID == dataID)
|
|
{
|
|
if (this.CollectionBufferWeightData.Count == 2)
|
|
{
|
|
this.CollectionBufferWeightData[0].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
|
|
this.DataBackup1(this.CollectionBufferWeightData[0]);
|
|
}
|
|
else if (this.CollectionBufferWeightData.Count > 2)
|
|
{
|
|
for (int i = 0; i < this.CollectionBufferWeightData.Count - 2; i++)
|
|
{
|
|
this.CollectionBufferWeightData[i].Status = DataStore.JudgmentResult.Timeout.ToString();
|
|
this.DataBackup1(this.CollectionBufferWeightData[i]);
|
|
}
|
|
|
|
this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 2].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
|
|
this.DataBackup1(this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 2]);
|
|
}
|
|
|
|
this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].Status = this.CurrentJudgmentResult.CurrentRejectData.ToString();
|
|
this.DataBackup1(this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1]);
|
|
|
|
this.CollectionBufferWeightData.Clear();
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
// 피드백 데이터
|
|
private int ReceiveCommandSB0(string lane, string dataID, string transferCount, string receiveData)
|
|
{
|
|
int ret = 0;
|
|
int temp = 0;
|
|
|
|
try
|
|
{
|
|
switch (lane)
|
|
{
|
|
case "A":
|
|
#region Value Assign
|
|
this.CurrentFeedbackItem.SampleCount = receiveData.Substring(0, 4);
|
|
this.CurrentFeedbackItem.DelayCount = receiveData.Substring(4, 4);
|
|
this.CurrentFeedbackItem.Sign = receiveData.Substring(8, 1);
|
|
this.CurrentFeedbackItem.FeedbackWeight = receiveData.Substring(9, 7);
|
|
#endregion
|
|
this.ChildFormMainDisplay.MainDisplayFeedback.UpdateDisplayCurrentValue(this.CurrentFeedbackItem);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region Communication protocol
|
|
private string Transfer_1_STD1(SystemConfigurationItem1 system, WeightData weight, ProductItem product)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
|
|
return "";
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append(string.Format("IN{0:000}", system.EquipmentID));
|
|
sb.Append(string.Format("{0:0000}", product.Number));
|
|
|
|
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.UnderRange, this.SystemConfig1.DecimalPlaces)));
|
|
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.PassRange, this.SystemConfig1.DecimalPlaces)));
|
|
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.OverRange, this.SystemConfig1.DecimalPlaces)));
|
|
|
|
switch (weight.JudgmentStatus)
|
|
{
|
|
case DataStore.JudgmentStatus.Empty:
|
|
break;
|
|
case DataStore.JudgmentStatus.Under:
|
|
sb.Append("U");
|
|
break;
|
|
case DataStore.JudgmentStatus.Pass:
|
|
sb.Append("P");
|
|
break;
|
|
case DataStore.JudgmentStatus.Over:
|
|
sb.Append("O");
|
|
break;
|
|
case DataStore.JudgmentStatus.Double:
|
|
sb.Append("D");
|
|
break;
|
|
case DataStore.JudgmentStatus.Metal:
|
|
sb.Append("M");
|
|
break;
|
|
case DataStore.JudgmentStatus.ExNg:
|
|
sb.Append("E");
|
|
break;
|
|
default:
|
|
sb.Append("E");
|
|
break;
|
|
}
|
|
|
|
if (weight.Weight <= 0.0)
|
|
sb.Append("-");
|
|
else
|
|
sb.Append(" ");
|
|
|
|
string temp = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces);
|
|
if(temp.StartsWith("-"))
|
|
temp = temp.Substring(1, temp.Length - 1);
|
|
sb.Append(temp.PadLeft(6, ' '));
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
private string Transfer_2_Remote(WeightData weight, ProductItem product)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
|
|
return "";
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append("01");
|
|
|
|
switch (weight.JudgmentStatus)
|
|
{
|
|
case DataStore.JudgmentStatus.Empty:
|
|
break;
|
|
case DataStore.JudgmentStatus.Under:
|
|
sb.Append("U");
|
|
break;
|
|
case DataStore.JudgmentStatus.Pass:
|
|
sb.Append("P");
|
|
break;
|
|
case DataStore.JudgmentStatus.Over:
|
|
sb.Append("O");
|
|
break;
|
|
case DataStore.JudgmentStatus.Double:
|
|
sb.Append("D");
|
|
break;
|
|
case DataStore.JudgmentStatus.Metal:
|
|
sb.Append("M");
|
|
break;
|
|
case DataStore.JudgmentStatus.ExNg:
|
|
sb.Append("E");
|
|
break;
|
|
default:
|
|
sb.Append(" ");
|
|
break;
|
|
}
|
|
|
|
sb.Append(Helper.StringZeroFillDigits6(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
private string Transfer_3_Print(WeightData weight, ProductItem product)
|
|
{
|
|
string sValue = "";
|
|
BarcodeStatus status = BarcodeStatus.None;
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
|
|
return "";
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(product.Number.ToString()));
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
if (product.Number == 1)
|
|
{
|
|
status = BarcodeStatus.NoRead;
|
|
sb.Append(string.Format("{0,8}", status));
|
|
}
|
|
else if (product.Number == 2)
|
|
{
|
|
status = BarcodeStatus.NoMatch;
|
|
sb.Append(string.Format("{0,8}", status));
|
|
}
|
|
else
|
|
sb.Append(string.Format("{0,8}", weight.JudgmentStatus));
|
|
}
|
|
else
|
|
sb.Append(string.Format("{0,8}", weight.JudgmentStatus));
|
|
sValue = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces);
|
|
sb.Append(sValue.PadLeft(10, ' '));
|
|
sValue = weight.TotalCount.ToString();
|
|
sb.Append(sValue.PadLeft(10, ' '));
|
|
|
|
return sb.ToString();
|
|
}
|
|
private string Transfer_6_OPT0(WeightData weight)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append((char)0x1B);
|
|
sb.Append("EW----;1.00I");
|
|
sb.Append((char)0x0D);
|
|
sb.Append((char)0x1B);
|
|
sb.Append("P1-0-000000000;A9mm;");
|
|
sb.Append(string.Format("{0, 6}", weight.Weight));
|
|
sb.Append((char)0x0D);
|
|
sb.Append((char)0x1B);
|
|
sb.Append("EX----;");
|
|
sb.Append((char)0x0D);
|
|
sb.Append((char)0x02);
|
|
sb.Append("TZ1.00I;13");
|
|
sb.Append((char)0x0D);
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
private byte[] Transfer_7_imaje9410OPT2(WeightData weight)
|
|
{
|
|
int tempStringLength = 0;
|
|
string tempString = "";
|
|
|
|
byte[] byteArray = new byte[12];
|
|
byte[] weightBytes = new byte[5];
|
|
|
|
// 외부변수사용 : 0xE8
|
|
byteArray[0] = 0xE8;
|
|
// Length : 0x00, 0x08 고정값
|
|
byteArray[1] = 0x00;
|
|
byteArray[2] = 0x08;
|
|
|
|
byteArray[3] = 0x01; // 1번 외부변수 번호
|
|
byteArray[4] = 0x00;
|
|
byteArray[5] = 0x05; // 1번 외부변수 길이
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
tempStringLength = weight.Weight.ToString().Trim().Length;
|
|
if (tempStringLength > 5)
|
|
tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
|
|
else
|
|
tempString = string.Format("{0,5}", weight.Weight);
|
|
|
|
weightBytes = new UTF8Encoding().GetBytes(tempString);
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + 6] = weightBytes[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
byteArray[i + 6] = 0x20;
|
|
}
|
|
}
|
|
|
|
byteArray[11] = 0x00;
|
|
byteArray[11] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
return byteArray;
|
|
}
|
|
private byte[] Transfer_8_imaje9028OPT2(WeightData weight)
|
|
{
|
|
int tempStringLength = 0;
|
|
string tempString = "";
|
|
|
|
byte[] byteArray = new byte[11];
|
|
byte[] weightBytes = new byte[5];
|
|
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ENQ)); // ACK
|
|
Thread.Sleep(30);
|
|
|
|
// 중량발송 : 0x99
|
|
byteArray[0] = 0x99;
|
|
|
|
// Length : 0x00, 0x02 고정값
|
|
byteArray[1] = 0x00;
|
|
byteArray[2] = 0x07;
|
|
byteArray[3] = 0x12;
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
tempStringLength = weight.Weight.ToString().Trim().Length;
|
|
if (tempStringLength > 5)
|
|
tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
|
|
else
|
|
tempString = string.Format("{0,5}", weight.Weight);
|
|
|
|
weightBytes = new UTF8Encoding().GetBytes(tempString);
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + 4] = weightBytes[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
byteArray[i + 4] = 0x20;
|
|
}
|
|
}
|
|
|
|
byteArray[9] = 0x12;
|
|
byteArray[10] = 0x00;
|
|
byteArray[10] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
return byteArray;
|
|
}
|
|
private string Transfer_9_Hitachi(WeightData weight, DataStore.SerialCOM com)
|
|
{
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append((char)0x10);
|
|
|
|
if (com == DataStore.SerialCOM.COM1)
|
|
{
|
|
sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM1));
|
|
if(this.SystemConfig2.IsHitachiBlankToNoneCOM1 == true)
|
|
sb.Append(weight.Weight.ToString().Trim());
|
|
else
|
|
sb.Append(string.Format("{0,6}", weight.Weight));
|
|
}
|
|
else if (com == DataStore.SerialCOM.COM3)
|
|
{
|
|
sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM3));
|
|
if (this.SystemConfig2.IsHitachiBlankToNoneCOM3 == true)
|
|
sb.Append(weight.Weight.ToString().Trim());
|
|
else
|
|
sb.Append(string.Format("{0,6}", weight.Weight));
|
|
}
|
|
else if (com == DataStore.SerialCOM.COM4)
|
|
{
|
|
sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM4));
|
|
if (this.SystemConfig2.IsHitachiBlankToNoneCOM4 == true)
|
|
sb.Append(weight.Weight.ToString().Trim());
|
|
else
|
|
sb.Append(string.Format("{0,6}", weight.Weight));
|
|
}
|
|
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
else
|
|
return "";
|
|
}
|
|
private byte[] Transfer_10_MACSA(WeightData weight, ProductItem product)
|
|
{
|
|
byte[] byteArray = new byte[14];
|
|
byte[] bytes = new byte[6];
|
|
byte sum = 0x00;
|
|
string str = "";
|
|
|
|
byteArray[0] = 0x02;
|
|
byteArray[1] = 0xFE;
|
|
byteArray[2] = 0x41;
|
|
byteArray[3] = 0x30;
|
|
byteArray[4] = 0x06;
|
|
|
|
if (weight.Weight >= 0.0)
|
|
bytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}", weight.Weight));
|
|
else if (product.TareRangeInt > 0)
|
|
bytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces)));
|
|
else
|
|
bytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}", 0.0));
|
|
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i + 5] = bytes[i];
|
|
}
|
|
|
|
byteArray[11] = byteArray[12] = byteArray[13] = 0x00;
|
|
byteArray[11] = Helper.ChecksumCalculator(byteArray);
|
|
byteArray[12] = (byte)(byteArray[11] & 0x00ff);
|
|
byteArray[13] = 0x03;
|
|
|
|
return byteArray;
|
|
}
|
|
private byte[] Transfer_11_Markoprint(WeightData weight, ProductItem product)
|
|
{
|
|
byte[] byteArray = new byte[50];
|
|
byte[] bytes = new byte[30];
|
|
byte[] weightBytes = new byte[30];
|
|
string strCosmax = "TZcosmax.00I;13";
|
|
string strCosmax2 = "TZcosmax2.00I;13";
|
|
string strDate = string.Format("{0:yyyy.MM.dd}", DateTime.Now);
|
|
|
|
if (this.SystemConfig2.IsMarkoprintTodaytDatePrintEthernet == false)
|
|
strDate = this.SystemConfig2.MarkoprintDateSettingEthernet;
|
|
else
|
|
this.SystemConfig2.MarkoprintDateSettingEthernet = strDate;
|
|
|
|
string str2 = "";
|
|
|
|
byteArray[0] = 0x02; // <STX>
|
|
if (this.SystemConfig2.MarkoprintLineNumberEthernet == 1)
|
|
{
|
|
#region 2줄
|
|
bytes = new UTF8Encoding().GetBytes(strCosmax2);
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i + 1] = bytes[i];
|
|
}
|
|
|
|
byteArray[strCosmax2.Length + 1] = 0x0D; // <CR>
|
|
|
|
if (this.SystemConfig2.IsMarkoprintDatePrintEthernet == true)
|
|
{
|
|
#region 날짜표시 On
|
|
if (weight.Weight >= 0.0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
|
|
else if (product.TareRangeInt > 0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
else
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));
|
|
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + strCosmax2.Length + 2] = weightBytes[i];
|
|
}
|
|
|
|
byteArray[strCosmax2.Length + weightBytes.Length + 2] = 0x0D; // <CR>
|
|
|
|
bytes = new UTF8Encoding().GetBytes(strDate);
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i + strCosmax2.Length + weightBytes.Length + 3] = bytes[i];
|
|
}
|
|
|
|
byteArray[strCosmax2.Length + strDate.Length + weightBytes.Length + 3] = 0x0D; // <CR>
|
|
byteArray[strCosmax2.Length + strDate.Length + weightBytes.Length + 4] = 0x03; // <ETX>
|
|
|
|
return byteArray;
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 날짜표시 Off
|
|
if (weight.Weight >= 0.0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
|
|
else if (product.TareRangeInt > 0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
else
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));
|
|
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + strCosmax.Length + 2] = weightBytes[i];
|
|
}
|
|
|
|
byteArray[strCosmax.Length + weightBytes.Length + 2] = 0x0D;
|
|
byteArray[strCosmax.Length + weightBytes.Length + 3] = 0x03;
|
|
|
|
return byteArray;
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 1줄
|
|
bytes = new UTF8Encoding().GetBytes(strCosmax);
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i + 1] = bytes[i];
|
|
}
|
|
|
|
byteArray[strCosmax.Length + 1] = 0x0D;
|
|
|
|
|
|
if (this.SystemConfig2.IsMarkoprintDatePrintEthernet == true)
|
|
{
|
|
#region 날짜표시 On
|
|
bytes = new UTF8Encoding().GetBytes(strDate);
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i + strCosmax.Length + 2] = bytes[i];
|
|
}
|
|
|
|
if (weight.Weight >= 0.0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
|
|
else if (product.TareRangeInt > 0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
else
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));
|
|
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + strCosmax.Length + strDate.Length + 2] = weightBytes[i];
|
|
}
|
|
|
|
byteArray[strCosmax.Length + strDate.Length + weightBytes.Length + 2] = 0x0D;
|
|
byteArray[strCosmax.Length + strDate.Length + weightBytes.Length + 3] = 0x03;
|
|
|
|
return byteArray;
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 날짜표시 Off
|
|
if (weight.Weight >= 0.0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
|
|
else if (product.TareRangeInt > 0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
else
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));
|
|
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + strCosmax.Length + 2] = weightBytes[i];
|
|
}
|
|
|
|
byteArray[strCosmax.Length + weightBytes.Length + 2] = 0x0D;
|
|
byteArray[strCosmax.Length + weightBytes.Length + 3] = 0x03;
|
|
|
|
return byteArray;
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
private byte[] Transfer_12_alphaJET(WeightData weight, ProductItem product)
|
|
{
|
|
byte[] byteArray = new byte[150];
|
|
byte[] bytes = new byte[100];
|
|
byte[] weightBytes = new byte[20];
|
|
int length = 0;
|
|
string fileName = "label\\1234.txt";
|
|
string str = "";
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
bytes = new UTF8Encoding().GetBytes("<GP><LOADLAB>" + fileName + "</LOADLAB><DSET>" + @"<DF aI=""1"">");
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i] = bytes[i];
|
|
}
|
|
|
|
length = bytes.Length;
|
|
|
|
///////////////////////////////////////////
|
|
|
|
if (weight.Weight >= 0.0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
|
|
else if (product.TareRangeInt > 0)
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
|
|
else
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));
|
|
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + length] = weightBytes[i];
|
|
}
|
|
|
|
length = length + weightBytes.Length;
|
|
|
|
////////////////////////////////////////////
|
|
|
|
bytes = new UTF8Encoding().GetBytes("</DF>");
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i + length] = bytes[i];
|
|
}
|
|
|
|
length = length + bytes.Length;
|
|
}
|
|
else
|
|
{
|
|
bytes = new UTF8Encoding().GetBytes("<GP><LOADLAB>" + fileName + "</LOADLAB><DSET><DFCLERAR/>");
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i] = bytes[i];
|
|
}
|
|
|
|
length = bytes.Length;
|
|
}
|
|
|
|
bytes = new UTF8Encoding().GetBytes("</DSET></GP>");
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
{
|
|
byteArray[i + length] = bytes[i];
|
|
}
|
|
|
|
return byteArray;
|
|
}
|
|
private string Transfer_13_Marking_VJ1510(WeightData weight)
|
|
{
|
|
// 총 byte 길이 = 9
|
|
byte[] byteArray = new byte[9];
|
|
byte[] weightBytes = new byte[4];
|
|
byte sum = 0x00;
|
|
string str = "";
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append((char)0x55); // U(고정)
|
|
sb.Append((char)0x4B); // K(고정)
|
|
sb.Append((char)0x0A); // LF(고정)
|
|
|
|
string temp = weight.WeightString.Trim().Substring(0, 4);
|
|
if (temp.Trim() == "")
|
|
temp = " 0";
|
|
|
|
sb.Append(temp);
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
else
|
|
return "";
|
|
}
|
|
private string Transfer_14_OPT1(string sValue)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append(sValue);
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
private string Transfer_17_OPT3(WeightData weight, ProductItem pItem)
|
|
{
|
|
string tempValue = "";
|
|
DateTime dt = DateTime.Now;
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append(string.Format(" {0:yyyyMMdd}", dt));
|
|
sb.Append(string.Format(" {0:HH:mm:ss}", dt));
|
|
if (weight.TotalCount.ToString().Length > 9)
|
|
{
|
|
int tempInt = weight.TotalCount.ToString().Length;
|
|
sb.Append(weight.TotalCount.ToString().Substring(tempInt - 9, 9));
|
|
}
|
|
else
|
|
sb.Append(string.Format("{0, 9}", weight.TotalCount));
|
|
|
|
switch (weight.JudgmentStatus)
|
|
{
|
|
case DataStore.JudgmentStatus.Empty:
|
|
sb.Append(" ");
|
|
break;
|
|
case DataStore.JudgmentStatus.Under:
|
|
tempValue = "U";
|
|
sb.Append(tempValue.PadLeft(9, ' '));
|
|
break;
|
|
case DataStore.JudgmentStatus.Pass:
|
|
tempValue = "P";
|
|
sb.Append(tempValue.PadLeft(9, ' '));
|
|
break;
|
|
case DataStore.JudgmentStatus.Over:
|
|
tempValue = "O";
|
|
sb.Append(tempValue.PadLeft(9, ' '));
|
|
break;
|
|
case DataStore.JudgmentStatus.Double:
|
|
tempValue = "D";
|
|
sb.Append(tempValue.PadLeft(9, ' '));
|
|
break;
|
|
case DataStore.JudgmentStatus.Metal:
|
|
tempValue = "M";
|
|
sb.Append(tempValue.PadLeft(9, ' '));
|
|
break;
|
|
case DataStore.JudgmentStatus.ExNg:
|
|
tempValue = "E";
|
|
sb.Append(tempValue.PadLeft(9, ' '));
|
|
break;
|
|
default:
|
|
tempValue = "E";
|
|
sb.Append(tempValue.PadLeft(9, ' '));
|
|
break;
|
|
}
|
|
|
|
sb.Append(string.Format("{0,9}", weight.Weight));
|
|
if (pItem.LotNo.Length > 9)
|
|
sb.Append(pItem.LotNo.Substring(0, 9));
|
|
else
|
|
sb.Append(pItem.LotNo.PadLeft(9, ' '));
|
|
sb.Append((Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces)).PadLeft(9));
|
|
sb.Append((Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces)).PadLeft(9));
|
|
sb.Append((Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces)).PadLeft(9));
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
private string Transfer_18_HP200(WeightData weight, int step)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
switch (step)
|
|
{
|
|
case 1:
|
|
if (weight.JudgmentStatus != DataStore.JudgmentStatus.Pass)
|
|
{
|
|
// 정량이 아닐 경우 공백 6문자 전송
|
|
sb.Append((char)0x02);
|
|
sb.Append((char)0x4a);
|
|
sb.Append((char)0x30);
|
|
sb.Append((char)0x2c);
|
|
sb.Append((char)0x20);
|
|
sb.Append((char)0x20);
|
|
sb.Append((char)0x20);
|
|
sb.Append((char)0x20);
|
|
sb.Append((char)0x20);
|
|
sb.Append((char)0x20);
|
|
sb.Append((char)0x0d);
|
|
sb.Append((char)0x04);
|
|
}
|
|
else
|
|
{
|
|
sb.Append((char)0x02);
|
|
sb.Append((char)0x4a);
|
|
sb.Append((char)0x30);
|
|
sb.Append((char)0x2c);
|
|
sb.Append((Helper.StringToDecimalPlaces(weight.WeightString.Trim(), this.SystemConfig1.DecimalPlaces)).PadLeft(6));
|
|
sb.Append((char)0x0d);
|
|
sb.Append((char)0x04);
|
|
}
|
|
|
|
return sb.ToString();
|
|
case 2:
|
|
// 화면 업데이트
|
|
sb.Append((char)0x02);
|
|
sb.Append((char)0x5a);
|
|
sb.Append((char)0x04);
|
|
|
|
return sb.ToString();
|
|
default:
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
private string Transfer_19_SmartJet(WeightData weight)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append("A01");
|
|
sb.Append(string.Format("{0,6}", weight.Weight));
|
|
sb.Append((char)0x04);
|
|
|
|
return sb.ToString();
|
|
}
|
|
private byte[] Transfer_22_Modbus()
|
|
{
|
|
byte[] madeData = new byte[TotalBytes];
|
|
byte[] Length2Value = new byte[2];
|
|
byte[] Length4Value = new byte[4];
|
|
|
|
double underValue = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces);
|
|
double passValue = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces);
|
|
double overValue = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces);
|
|
|
|
int equipmentStatus;
|
|
if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
|
|
equipmentStatus = 1;
|
|
else
|
|
equipmentStatus = 0;
|
|
|
|
int judgmentStatus;
|
|
switch (this.CurrentWeightData.JudgmentStatus)
|
|
{
|
|
case DataStore.JudgmentStatus.Over:
|
|
judgmentStatus = 0;
|
|
break;
|
|
case DataStore.JudgmentStatus.Pass:
|
|
judgmentStatus = 1;
|
|
break;
|
|
case DataStore.JudgmentStatus.Under:
|
|
judgmentStatus = 2;
|
|
break;
|
|
case DataStore.JudgmentStatus.Metal:
|
|
judgmentStatus = 3;
|
|
break;
|
|
case DataStore.JudgmentStatus.Double:
|
|
judgmentStatus = 4;
|
|
break;
|
|
default:
|
|
judgmentStatus = 5;
|
|
break;
|
|
}
|
|
|
|
Length2Value = GetBytes(this.SystemConfig1.EquipmentID);
|
|
for (int i = 0; i < 2; i++)
|
|
madeData[i] = Length2Value[1 - i];
|
|
|
|
Length2Value = GetBytes(this.SystemConfig1.ProductNumber);
|
|
for (int i = 0; i < 2; i++)
|
|
madeData[2 + i] = Length2Value[1 - i];
|
|
|
|
Length4Value = GetBytes((Single)underValue);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[4 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes((Single)passValue);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[8 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes((Single)overValue);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[12 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes(this.CurrentWeightData.UnderCount);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[16 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes(this.CurrentWeightData.PassCount);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[20 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes(this.CurrentWeightData.OverCount);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[24 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes(this.CurrentWeightData.OverCount + this.CurrentWeightData.UnderCount);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[28 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes(this.CurrentWeightData.ExNGCount);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[32 + i] = Length4Value[3 - i];
|
|
|
|
Length4Value = GetBytes(this.CurrentWeightData.TotalCount);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[36 + i] = Length4Value[3 - i];
|
|
|
|
Length2Value = GetBytes(judgmentStatus);
|
|
for (int i = 0; i < 2; i++)
|
|
madeData[40 + i] = Length2Value[1 - i];
|
|
|
|
Length4Value = GetBytes((Single)this.CurrentWeightData.Weight);
|
|
for (int i = 0; i < 4; i++)
|
|
madeData[42 + i] = Length4Value[3 - i];
|
|
|
|
Length2Value = GetBytes(equipmentStatus);
|
|
for (int i = 0; i < 2; i++)
|
|
madeData[46 + i] = Length2Value[1 - i];
|
|
|
|
return madeData;
|
|
}
|
|
private string Transfer_23_STD2(SystemConfigurationItem1 system, WeightData weight, ProductItem product)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
|
|
return "";
|
|
|
|
sb.Append((char)0x02);
|
|
sb.Append(string.Format("IN{0:000}", system.EquipmentID));
|
|
sb.Append(string.Format("{0:0000}", product.Number));
|
|
|
|
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.UnderRange, this.SystemConfig1.DecimalPlaces)));
|
|
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.PassRange, this.SystemConfig1.DecimalPlaces)));
|
|
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.OverRange, this.SystemConfig1.DecimalPlaces)));
|
|
|
|
sb.Append(string.Format("{0:0000000}", weight.UnderCount));
|
|
sb.Append(string.Format("{0:0000000}", weight.PassCount));
|
|
sb.Append(string.Format("{0:0000000}", weight.OverCount));
|
|
sb.Append(string.Format("{0:0000000}", weight.ExNGCount));
|
|
sb.Append(string.Format("{0:000000000}", weight.TotalCount));
|
|
|
|
switch (weight.JudgmentStatus)
|
|
{
|
|
case DataStore.JudgmentStatus.Empty:
|
|
break;
|
|
case DataStore.JudgmentStatus.Under:
|
|
sb.Append("U");
|
|
break;
|
|
case DataStore.JudgmentStatus.Pass:
|
|
sb.Append("P");
|
|
break;
|
|
case DataStore.JudgmentStatus.Over:
|
|
sb.Append("O");
|
|
break;
|
|
case DataStore.JudgmentStatus.Double:
|
|
sb.Append("D");
|
|
break;
|
|
case DataStore.JudgmentStatus.Metal:
|
|
sb.Append("M");
|
|
break;
|
|
case DataStore.JudgmentStatus.ExNg:
|
|
sb.Append("E");
|
|
break;
|
|
default:
|
|
sb.Append("E");
|
|
break;
|
|
}
|
|
|
|
if (weight.Weight <= 0.0)
|
|
sb.Append("-");
|
|
else
|
|
sb.Append(" ");
|
|
|
|
string temp = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces);
|
|
if (temp.StartsWith("-"))
|
|
temp = temp.Substring(1, temp.Length - 1);
|
|
sb.Append(temp.PadLeft(6, ' '));
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region SerialCommunication
|
|
public string SendChar(DataStore.CharValue sendChar)
|
|
{
|
|
StringBuilder temp = new StringBuilder();
|
|
|
|
switch (sendChar)
|
|
{
|
|
case DataStore.CharValue.ENQ:
|
|
temp.Append((char)0x05);
|
|
break;
|
|
case DataStore.CharValue.ACK:
|
|
temp.Append((char)0x06);
|
|
break;
|
|
case DataStore.CharValue.NAK:
|
|
temp.Append((char)0x15);
|
|
break;
|
|
case DataStore.CharValue.Space:
|
|
temp.Append((char)0x20);
|
|
break;
|
|
}
|
|
|
|
return temp.ToString();
|
|
}
|
|
|
|
// Markem-imaje 9410 방 변경
|
|
public byte[] RoomChange9410(int num)
|
|
{
|
|
byte[] byteArray = new byte[6];
|
|
|
|
// Position 변경 : 0xA0
|
|
byteArray[0] = 0xA0;
|
|
|
|
// Length : 0x00, 0x02 고정값
|
|
byteArray[1] = 0x00;
|
|
byteArray[2] = 0x02;
|
|
|
|
|
|
if (num == 1)
|
|
{
|
|
// 1번방으로 이동
|
|
byteArray[3] = 0x30;
|
|
byteArray[4] = 0x31;
|
|
}
|
|
else
|
|
{
|
|
// 2번방으로 이동
|
|
byteArray[3] = 0x30;
|
|
byteArray[4] = 0x32;
|
|
}
|
|
|
|
byteArray[5] = 0x00;
|
|
byteArray[5] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
return byteArray;
|
|
}
|
|
// Markem-imaje 9410 중량
|
|
public byte[] WeightData9410_OPT1(WeightData weight)
|
|
{
|
|
int tempStringLength = 0;
|
|
string tempString = "";
|
|
|
|
byte[] byteArray = new byte[12];
|
|
byte[] weightBytes = new byte[5];
|
|
// 외부변수사용 : 0xE8
|
|
byteArray[0] = 0xE8;
|
|
// Length : 0x00, 0x08 고정값
|
|
byteArray[1] = 0x00;
|
|
byteArray[2] = 0x08;
|
|
|
|
byteArray[3] = 0x01; // 1번 외부변수 번호
|
|
byteArray[4] = 0x00;
|
|
byteArray[5] = 0x05; // 1번 외부변수 길이
|
|
|
|
tempStringLength = weight.Weight.ToString().Trim().Length;
|
|
if (tempStringLength > 5)
|
|
tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
|
|
else
|
|
tempString = string.Format("{0,5}", weight.Weight);
|
|
|
|
weightBytes = new UTF8Encoding().GetBytes(tempString);
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + 6] = weightBytes[i];
|
|
}
|
|
|
|
byteArray[11] = 0x00;
|
|
byteArray[11] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
return byteArray;
|
|
}
|
|
// Markem-imaje 9410 중량(OPT3)
|
|
public byte[] WeightData9410_OPT3(WeightData weight)
|
|
{
|
|
int tempStringLength = 0;
|
|
string tempString = "";
|
|
|
|
byte[] byteArray = new byte[12];
|
|
byte[] weightBytes = new byte[5];
|
|
// 외부변수사용 : 0xE8
|
|
byteArray[0] = 0xE8;
|
|
// Length : 0x00, 0x08 고정값
|
|
byteArray[1] = 0x00;
|
|
byteArray[2] = 0x08;
|
|
|
|
byteArray[3] = 0x01; // 1번 외부변수 번호
|
|
byteArray[4] = 0x00;
|
|
byteArray[5] = 0x05; // 1번 외부변수 길이
|
|
|
|
string result = weight.Weight.ToString().Trim();
|
|
string[] splitResult = result.Split('.');
|
|
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 5}", int.Parse(splitResult[0])));
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + 6] = weightBytes[i];
|
|
}
|
|
|
|
byteArray[11] = 0x00;
|
|
byteArray[11] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
//tempStringLength = weight.Weight.ToString().Trim().Length;
|
|
//if (tempStringLength > 5)
|
|
// tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
|
|
//else
|
|
// tempString = string.Format("{0,5}", weight.Weight);
|
|
|
|
//weightBytes = new UTF8Encoding().GetBytes(tempString);
|
|
//for (int i = 0; i < weightBytes.Length; i++)
|
|
//{
|
|
// byteArray[i + 6] = weightBytes[i];
|
|
//}
|
|
|
|
//byteArray[11] = 0x00;
|
|
//byteArray[11] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
return byteArray;
|
|
}
|
|
|
|
// Markem-imaje 9028 방 변경
|
|
public byte[] RoomChange9028(int num)
|
|
{
|
|
byte[] byteArray = new byte[6];
|
|
|
|
// Position 변경 : 0x98
|
|
byteArray[0] = 0x98;
|
|
|
|
// Length : 0x00, 0x02 고정값
|
|
byteArray[1] = 0x00;
|
|
byteArray[2] = 0x02;
|
|
|
|
|
|
if (num == 1)
|
|
{
|
|
// 1번방으로 이동
|
|
byteArray[3] = 0x00;
|
|
byteArray[4] = 0x01;
|
|
}
|
|
else
|
|
{
|
|
// 2번방으로 이동
|
|
byteArray[3] = 0x00;
|
|
byteArray[4] = 0x02;
|
|
}
|
|
|
|
byteArray[5] = 0x00;
|
|
byteArray[5] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
return byteArray;
|
|
}
|
|
// Markem-imaje 9028 중량
|
|
public byte[] WeightData9028(WeightData weight)
|
|
{
|
|
int tempStringLength = 0;
|
|
string tempString = "";
|
|
|
|
byte[] byteArray = new byte[12];
|
|
byte[] weightBytes = new byte[5];
|
|
|
|
// byteArray[0] ~ byteArray[3]은 고정
|
|
byteArray[0] = 0x99;
|
|
byteArray[1] = 0x00;
|
|
byteArray[2] = 0x07;
|
|
byteArray[3] = 0x12;
|
|
|
|
string result = weight.Weight.ToString().Trim();
|
|
string[] splitResult = result.Split('.');
|
|
|
|
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 5}", int.Parse(splitResult[0])));
|
|
for (int i = 0; i < weightBytes.Length; i++)
|
|
{
|
|
byteArray[i + 4] = weightBytes[i];
|
|
}
|
|
|
|
byteArray[9] = 0x12;
|
|
byteArray[10] = 0x00;
|
|
byteArray[10] = Helper.ChecksumCalculator(byteArray);
|
|
|
|
return byteArray;
|
|
}
|
|
|
|
// 전송지연시간
|
|
private void CreateTimer(DataStore.MenuBottomConfiguration port)
|
|
{
|
|
switch (port)
|
|
{
|
|
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
|
System.Windows.Forms.Timer timerCOM1 = new System.Windows.Forms.Timer();
|
|
timerCOM1.Interval = this.SystemConfig1.TransmissionDelayTimeCOM1;
|
|
timerCOM1.Tick += new EventHandler(this.timerCOM1_Tick);
|
|
timerCOM1.Enabled = true;
|
|
break;
|
|
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
|
System.Windows.Forms.Timer timerCOM3 = new System.Windows.Forms.Timer();
|
|
timerCOM3.Interval = this.SystemConfig1.TransmissionDelayTimeCOM3;
|
|
timerCOM3.Tick += new EventHandler(this.timerCOM3_Tick);
|
|
timerCOM3.Enabled = true;
|
|
break;
|
|
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
|
System.Windows.Forms.Timer timerCOM4 = new System.Windows.Forms.Timer();
|
|
timerCOM4.Interval = this.SystemConfig1.TransmissionDelayTimeCOM4;
|
|
timerCOM4.Tick += new EventHandler(this.timerCOM4_Tick);
|
|
timerCOM4.Enabled = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
public void ClearQueue()
|
|
{
|
|
this.QueueCOM1.Clear();
|
|
this.QueueCOM3.Clear();
|
|
this.QueueCOM4.Clear();
|
|
}
|
|
|
|
private char HitachiRoomNumberToChar(int roomNumber)
|
|
{
|
|
switch (roomNumber)
|
|
{
|
|
case 1:
|
|
return (char)0x31;
|
|
case 2:
|
|
return (char)0x32;
|
|
case 3:
|
|
return (char)0x33;
|
|
case 4:
|
|
return (char)0x34;
|
|
case 5:
|
|
return (char)0x35;
|
|
case 6:
|
|
return (char)0x36;
|
|
case 7:
|
|
return (char)0x37;
|
|
case 8:
|
|
return (char)0x38;
|
|
case 9:
|
|
return (char)0x39;
|
|
default:
|
|
return (char)0x31;
|
|
}
|
|
}
|
|
private string ResponseFrameOPT2()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (this.CurrentOPT2COM1.IsReceivedData == true)
|
|
{
|
|
this.CurrentOPT2COM1.IsReceivedData = false;
|
|
|
|
// STX
|
|
sb.Append((char)0x02);
|
|
|
|
//식별코드;
|
|
if (this.CurrentOPT2COM1.IsErrorReceivedData == true)
|
|
sb.Append("1");
|
|
else if (this.CurrentOPT2COM1.IsErrorSettingStatus == true)
|
|
sb.Append("2");
|
|
else if (this.CurrentOPT2COM1.IsFailProductChange == true)
|
|
sb.Append("3");
|
|
else
|
|
sb.Append("0");
|
|
|
|
//동작
|
|
if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
|
|
sb.Append("0");
|
|
else
|
|
sb.Append("1");
|
|
|
|
//품종번호
|
|
if (this.CurrentProductItem.Number <= 99)
|
|
sb.Append(string.Format("{0:d2}", this.CurrentProductItem.Number));
|
|
else
|
|
sb.Append("00");
|
|
|
|
//ETX
|
|
sb.Append((char)0x03);
|
|
|
|
return sb.ToString();
|
|
}
|
|
else
|
|
return "";
|
|
}
|
|
private void SerialOPT2COM1Delegate()
|
|
{
|
|
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
|
|
timer.Interval = 500;
|
|
timer.Tick += new EventHandler(this.timerOPT2COM1_Tick);
|
|
timer.Enabled = true;
|
|
}
|
|
private void SerialOPT2COM3Delegate()
|
|
{
|
|
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
|
|
timer.Interval = 500;
|
|
timer.Tick += new EventHandler(this.timerOPT2COM3_Tick);
|
|
timer.Enabled = true;
|
|
}
|
|
private void SerialOPT2COM4Delegate()
|
|
{
|
|
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
|
|
timer.Interval = 500;
|
|
timer.Tick += new EventHandler(this.timerOPT2COM4_Tick);
|
|
timer.Enabled = true;
|
|
}
|
|
private void SerialOPT2EthernetDelegate()
|
|
{
|
|
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
|
|
timer.Interval = 500;
|
|
timer.Tick += new EventHandler(this.timerOPT2Ethernet_Tick);
|
|
timer.Enabled = true;
|
|
}
|
|
#endregion
|
|
#region Serial COM1
|
|
public void OpenSerialCOM1()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM1Mode == 0 || this.SystemConfig1.SerialCOM1Mode == 16)
|
|
return;
|
|
|
|
if (this.smartSerialPort1.IsOpen == true)
|
|
this.smartSerialPort1.Close();
|
|
|
|
switch (this.SystemConfig1.SerialCOM1BaudRate)
|
|
{
|
|
case 0:
|
|
this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
|
|
break;
|
|
case 1:
|
|
this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._19200bps;
|
|
break;
|
|
case 2:
|
|
this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._38400bps;
|
|
break;
|
|
case 3:
|
|
this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
|
|
break;
|
|
default:
|
|
this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
|
|
break;
|
|
}
|
|
|
|
this.smartSerialPort1.Open();
|
|
}
|
|
public void CloseSerialCOM1()
|
|
{
|
|
this.smartSerialPort1.Close();
|
|
}
|
|
public bool CheckOpenCOM1()
|
|
{
|
|
if (this.smartSerialPort1.IsOpen == true)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
public void TransferDirectSerialCOM1(string strTemp)
|
|
{
|
|
if (this.SystemConfig1.SerialCOM1Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
|
|
{
|
|
byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);
|
|
this.smartSerialPort1.WriteNoneFrame(strByte);
|
|
}
|
|
else
|
|
this.smartSerialPort1.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
|
|
}
|
|
public void TransferDirectSerialCOM1(byte[] buffer)
|
|
{
|
|
this.smartSerialPort1.WriteNoneFrame(buffer);
|
|
}
|
|
public void TransferSerialCOM1(string strTemp)
|
|
{
|
|
if (this.smartSerialPort1.IsOpen == true)
|
|
{
|
|
if (this.SystemConfig1.TransmissionDelayTimeCOM1 == 0)
|
|
{
|
|
if (this.SystemConfig1.SerialCOM1Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
|
|
{
|
|
byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);
|
|
this.smartSerialPort1.WriteNoneFrame(strByte);
|
|
}
|
|
else
|
|
this.smartSerialPort1.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
|
|
}
|
|
else
|
|
{
|
|
this.QueueCOM1.Enqueue(strTemp);
|
|
this.CreateTimer(DataStore.MenuBottomConfiguration.SerialCOM1);
|
|
}
|
|
}
|
|
}
|
|
public void TransferSerialCOM1(byte[] buffer)
|
|
{
|
|
if (this.smartSerialPort1.IsOpen == true)
|
|
{
|
|
if (this.SystemConfig1.TransmissionDelayTimeCOM1 == 0)
|
|
this.smartSerialPort1.WriteNoneFrame(buffer);
|
|
else
|
|
{
|
|
this.QueueCOM1.Enqueue(buffer);
|
|
this.CreateTimer(DataStore.MenuBottomConfiguration.SerialCOM1);
|
|
}
|
|
}
|
|
}
|
|
public void ChangeSerialCOM1FrameSeparateType(DataStore.SeparateType type)
|
|
{
|
|
// 통신 포트 설정
|
|
if (this.smartSerialPort1.IsOpen == true)
|
|
this.smartSerialPort1.Close();
|
|
|
|
if (type == DataStore.SeparateType.ETXONLY)
|
|
{
|
|
this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY;
|
|
|
|
byte[] etxCodes = new byte[2];
|
|
etxCodes[0] = 13;
|
|
etxCodes[1] = 10;
|
|
this.smartSerialPort1.ETXCodes = etxCodes;
|
|
}
|
|
else if (type == DataStore.SeparateType.STXANDETX)
|
|
{
|
|
this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;
|
|
|
|
this.smartSerialPort1.STXCode = 2;
|
|
this.smartSerialPort1.ETXCode = 3;
|
|
}
|
|
else if (type == DataStore.SeparateType.NONEFRAME_READTIMEOUT)
|
|
{
|
|
this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.NONEFRAME_READTIMEOUT;
|
|
this.smartSerialPort1.ReadTimeout = 300;
|
|
}
|
|
else
|
|
{
|
|
this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXONLY;
|
|
this.smartSerialPort1.STXCode = 2;
|
|
}
|
|
|
|
this.smartSerialPort1.Open();
|
|
}
|
|
#endregion
|
|
#region Serial COM3
|
|
public void OpenSerialCOM3()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM3Mode == 0 || this.SystemConfig1.SerialCOM3Mode == 16)
|
|
return;
|
|
|
|
if (this.smartSerialPort3.IsOpen == true)
|
|
this.smartSerialPort3.Close();
|
|
|
|
switch (this.SystemConfig1.SerialCOM3BaudRate)
|
|
{
|
|
case 0:
|
|
this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
|
|
break;
|
|
case 1:
|
|
this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._19200bps;
|
|
break;
|
|
case 2:
|
|
this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._38400bps;
|
|
break;
|
|
case 3:
|
|
this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
|
|
break;
|
|
default:
|
|
this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
|
|
break;
|
|
}
|
|
|
|
this.smartSerialPort3.Open();
|
|
}
|
|
public void CloseSerialCOM3()
|
|
{
|
|
this.smartSerialPort3.Close();
|
|
}
|
|
public bool CheckOpenCOM3()
|
|
{
|
|
if (this.smartSerialPort3.IsOpen == true)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
public void TransferDirectSerialCOM3(string strTemp)
|
|
{
|
|
if (this.SystemConfig1.SerialCOM3Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
|
|
{
|
|
byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);
|
|
this.smartSerialPort3.WriteNoneFrame(strByte);
|
|
}
|
|
else
|
|
this.smartSerialPort3.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
|
|
}
|
|
public void TransferDirectSerialCOM3(byte[] buffer)
|
|
{
|
|
this.smartSerialPort3.WriteNoneFrame(buffer);
|
|
}
|
|
public void TransferDirectSerialCOM3RawData(string strTemp)
|
|
{
|
|
this.smartSerialPort3.RawSerialPort.Write(strTemp);
|
|
}
|
|
public void TransferDirectSerialCOM3RawData(byte[] buffer)
|
|
{
|
|
this.smartSerialPort3.RawSerialPort.Write(buffer, 0, buffer.Length);
|
|
}
|
|
public void TransferSerialCOM3(string strTemp)
|
|
{
|
|
if (this.smartSerialPort3.IsOpen == true)
|
|
{
|
|
if (this.SystemConfig1.TransmissionDelayTimeCOM3 == 0)
|
|
{
|
|
if (this.SystemConfig1.SerialCOM3Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
|
|
{
|
|
byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);
|
|
this.smartSerialPort3.WriteNoneFrame(strByte);
|
|
}
|
|
else
|
|
this.smartSerialPort3.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
|
|
}
|
|
else
|
|
{
|
|
this.QueueCOM3.Enqueue(strTemp);
|
|
this.CreateTimer(DataStore.MenuBottomConfiguration.SerialCOM3);
|
|
}
|
|
}
|
|
}
|
|
public void TransferSerialCOM3(byte[] buffer)
|
|
{
|
|
if (this.smartSerialPort3.IsOpen == true)
|
|
{
|
|
if (this.SystemConfig1.TransmissionDelayTimeCOM3 == 0)
|
|
this.smartSerialPort3.WriteNoneFrame(buffer);
|
|
else
|
|
{
|
|
this.QueueCOM3.Enqueue(buffer);
|
|
this.CreateTimer(DataStore.MenuBottomConfiguration.SerialCOM3);
|
|
}
|
|
}
|
|
}
|
|
public void TransferSerialCOM3RawData(byte[] buffer)
|
|
{
|
|
if (this.smartSerialPort3.IsOpen == true)
|
|
{
|
|
if (this.SystemConfig1.TransmissionDelayTimeCOM3 == 0)
|
|
{
|
|
//RawSerialPort 기능을 사용하여 데이터를 전송
|
|
this.smartSerialPort3.RawSerialPort.Write(buffer, 0, buffer.Length);
|
|
}
|
|
else
|
|
{
|
|
this.QueueCOM3.Enqueue(buffer);
|
|
this.CreateTimer(DataStore.MenuBottomConfiguration.SerialCOM3);
|
|
}
|
|
}
|
|
}
|
|
public void ReceiveSerialCOM3()
|
|
{
|
|
int ret = 0;
|
|
string strTemp = "";
|
|
byte[] readByte;
|
|
|
|
SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;
|
|
|
|
try
|
|
{
|
|
receiveDataState = this.smartSerialPort3.ReadQueue(out readByte);
|
|
strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ((receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY) || (receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.FAILDATA))
|
|
return;
|
|
|
|
// Bacode
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public void ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType type)
|
|
{
|
|
// 통신 포트 설정
|
|
if (this.smartSerialPort3.IsOpen == true)
|
|
this.smartSerialPort3.Close();
|
|
|
|
if (type == DataStore.SeparateType.ETXONLY)
|
|
{
|
|
this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY;
|
|
|
|
byte[] etxCodes = new byte[2];
|
|
etxCodes[0] = 13;
|
|
etxCodes[1] = 10;
|
|
this.smartSerialPort3.ETXCodes = etxCodes;
|
|
}
|
|
else if (type == DataStore.SeparateType.STXANDETX)
|
|
{
|
|
this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;
|
|
|
|
this.smartSerialPort3.STXCode = 2;
|
|
this.smartSerialPort3.ETXCode = 3;
|
|
}
|
|
else if (type == DataStore.SeparateType.NONEFRAME_READTIMEOUT)
|
|
{
|
|
this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.NONEFRAME_READTIMEOUT;
|
|
this.smartSerialPort3.ReadTimeout = 300;
|
|
}
|
|
else
|
|
{
|
|
this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXONLY;
|
|
this.smartSerialPort3.STXCode = 2;
|
|
}
|
|
|
|
this.smartSerialPort3.Open();
|
|
}
|
|
#endregion
|
|
#region Serial COM4
|
|
public void OpenSerialCOM4()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM4Mode == 0 || this.SystemConfig1.SerialCOM4Mode == 16)
|
|
return;
|
|
|
|
if (this.smartSerialPort4.IsOpen == true)
|
|
this.smartSerialPort4.Close();
|
|
|
|
switch (this.SystemConfig1.SerialCOM4BaudRate)
|
|
{
|
|
case 0:
|
|
this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
|
|
break;
|
|
case 1:
|
|
this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._19200bps;
|
|
break;
|
|
case 2:
|
|
this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._38400bps;
|
|
break;
|
|
case 3:
|
|
this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
|
|
break;
|
|
default:
|
|
this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
|
|
break;
|
|
}
|
|
|
|
this.smartSerialPort4.Open();
|
|
}
|
|
public void CloseSerialCOM4()
|
|
{
|
|
this.smartSerialPort4.Close();
|
|
}
|
|
public bool CheckOpenCOM4()
|
|
{
|
|
if (this.smartSerialPort4.IsOpen == true)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
public void TransferDirectSerialCOM4(string strTemp)
|
|
{
|
|
if (this.SystemConfig1.SerialCOM4Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
|
|
{
|
|
byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);
|
|
this.smartSerialPort4.WriteNoneFrame(strByte);
|
|
}
|
|
else
|
|
this.smartSerialPort4.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
|
|
}
|
|
public void TransferDirectSerialCOM4(byte[] buffer)
|
|
{
|
|
this.smartSerialPort4.WriteNoneFrame(buffer);
|
|
}
|
|
public void TransferSerialCOM4(string strTemp)
|
|
{
|
|
if (this.smartSerialPort4.IsOpen == true)
|
|
{
|
|
if (this.SystemConfig1.TransmissionDelayTimeCOM4 == 0)
|
|
{
|
|
if (this.SystemConfig1.SerialCOM4Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
|
|
{
|
|
byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);
|
|
this.smartSerialPort4.WriteNoneFrame(strByte);
|
|
}
|
|
else
|
|
this.smartSerialPort4.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
|
|
}
|
|
else
|
|
{
|
|
this.QueueCOM4.Enqueue(strTemp);
|
|
this.CreateTimer(DataStore.MenuBottomConfiguration.SerialCOM4);
|
|
}
|
|
}
|
|
}
|
|
public void TransferSerialCOM4(byte[] buffer)
|
|
{
|
|
if (this.smartSerialPort4.IsOpen == true)
|
|
{
|
|
if (this.SystemConfig1.TransmissionDelayTimeCOM4 == 0)
|
|
this.smartSerialPort4.WriteNoneFrame(buffer);
|
|
else
|
|
{
|
|
this.QueueCOM4.Enqueue(buffer);
|
|
this.CreateTimer(DataStore.MenuBottomConfiguration.SerialCOM4);
|
|
}
|
|
}
|
|
}
|
|
public void ChangeSerialCOM4FrameSeparateType(DataStore.SeparateType type)
|
|
{
|
|
// 통신 포트 설정
|
|
if (this.smartSerialPort4.IsOpen == true)
|
|
this.smartSerialPort4.Close();
|
|
|
|
if (type == DataStore.SeparateType.ETXONLY)
|
|
{
|
|
this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY;
|
|
|
|
byte[] etxCodes = new byte[2];
|
|
etxCodes[0] = 13;
|
|
etxCodes[1] = 10;
|
|
this.smartSerialPort4.ETXCodes = etxCodes;
|
|
}
|
|
else if (type == DataStore.SeparateType.STXANDETX)
|
|
{
|
|
this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;
|
|
|
|
this.smartSerialPort4.STXCode = 2;
|
|
this.smartSerialPort4.ETXCode = 3;
|
|
}
|
|
else if (type == DataStore.SeparateType.NONEFRAME_READTIMEOUT)
|
|
{
|
|
this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.NONEFRAME_READTIMEOUT;
|
|
this.smartSerialPort4.ReadTimeout = 300;
|
|
}
|
|
else
|
|
{
|
|
this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXONLY;
|
|
this.smartSerialPort4.STXCode = 2;
|
|
}
|
|
|
|
this.smartSerialPort4.Open();
|
|
}
|
|
#endregion
|
|
|
|
#region OPC, Modbus
|
|
public static byte[] GetBytes(int argument)
|
|
{
|
|
byte[] byteArray = BitConverter.GetBytes(argument);
|
|
return byteArray;
|
|
}
|
|
public static byte[] GetBytes(Single argument)
|
|
{
|
|
byte[] byteArray = BitConverter.GetBytes(argument);
|
|
return byteArray;
|
|
}
|
|
public static byte[] GetBytes(uint argument)
|
|
{
|
|
byte[] byteArray = BitConverter.GetBytes(argument);
|
|
return byteArray;
|
|
}
|
|
#endregion
|
|
#region Modbus Slave COM1
|
|
public void OpenModbusSlaveCOM1()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM1Mode == 0)
|
|
return;
|
|
|
|
this.CloseModbusCOM1();
|
|
this.CloseModbusSlaveCOM1();
|
|
|
|
if (this.SystemConfig1.SerialCOM1Mode == (int)DataStore.SerialMode.f16_OPC)
|
|
{
|
|
this.smartModbusSlave1.SlaveAddress = 1;
|
|
this.smartModbusSlave1.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
this.smartModbusSlave1.Start();
|
|
}
|
|
else if (this.SystemConfig1.SerialCOM1Mode == (int)DataStore.SerialMode.f22_Modbus_RTU)
|
|
{
|
|
this.smartModbusSlave1.SlaveAddress = this.SystemConfig2.ModbusRTUSlaveIDCOM1;
|
|
switch (this.SystemConfig1.SerialCOM1BaudRate)
|
|
{
|
|
case 0:
|
|
this.smartModbusSlave1.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
break;
|
|
case 1:
|
|
this.smartModbusSlave1.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_19200;
|
|
break;
|
|
case 2:
|
|
this.smartModbusSlave1.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_38400;
|
|
break;
|
|
case 3:
|
|
this.smartModbusSlave1.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_57600;
|
|
break;
|
|
case 4:
|
|
this.smartModbusSlave1.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_115200;
|
|
break;
|
|
default:
|
|
this.smartModbusSlave1.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
break;
|
|
}
|
|
|
|
this.smartModbusSlave1.Start();
|
|
}
|
|
}
|
|
public void CloseModbusSlaveCOM1()
|
|
{
|
|
if (this.smartModbusSlave1.IsOpen == true)
|
|
this.smartModbusSlave1.End();
|
|
}
|
|
#endregion
|
|
#region Modbus Slave COM3
|
|
public void OpenModbusSlaveCOM3()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM3Mode == 0)
|
|
return;
|
|
|
|
this.CloseModbusCOM3();
|
|
this.CloseModbusSlaveCOM3();
|
|
|
|
if (this.SystemConfig1.SerialCOM3Mode == (int)DataStore.SerialMode.f16_OPC)
|
|
{
|
|
this.smartModbusSlave3.SlaveAddress = 1;
|
|
this.smartModbusSlave3.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
this.smartModbusSlave3.Start();
|
|
}
|
|
else if (this.SystemConfig1.SerialCOM3Mode == (int)DataStore.SerialMode.f22_Modbus_RTU)
|
|
{
|
|
this.smartModbusSlave3.SlaveAddress = this.SystemConfig2.ModbusRTUSlaveIDCOM3;
|
|
switch (this.SystemConfig1.SerialCOM3BaudRate)
|
|
{
|
|
case 0:
|
|
this.smartModbusSlave3.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
break;
|
|
case 1:
|
|
this.smartModbusSlave3.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_19200;
|
|
break;
|
|
case 2:
|
|
this.smartModbusSlave3.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_38400;
|
|
break;
|
|
case 3:
|
|
this.smartModbusSlave3.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_57600;
|
|
break;
|
|
case 4:
|
|
this.smartModbusSlave3.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_115200;
|
|
break;
|
|
default:
|
|
this.smartModbusSlave3.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
break;
|
|
}
|
|
this.smartModbusSlave3.Start();
|
|
}
|
|
}
|
|
public void CloseModbusSlaveCOM3()
|
|
{
|
|
if (this.smartModbusSlave3.IsOpen == true)
|
|
this.smartModbusSlave3.End();
|
|
}
|
|
#endregion
|
|
#region Modbus Slave COM4
|
|
public void OpenModbusSlaveCOM4()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM4Mode == 0)
|
|
return;
|
|
|
|
this.CloseModbusCOM4();
|
|
this.CloseModbusSlaveCOM4();
|
|
|
|
if (this.SystemConfig1.SerialCOM4Mode == (int)DataStore.SerialMode.f16_OPC)
|
|
{
|
|
this.smartModbusSlave4.SlaveAddress = 1;
|
|
this.smartModbusSlave4.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
this.smartModbusSlave4.Start();
|
|
}
|
|
else if (this.SystemConfig1.SerialCOM4Mode == (int)DataStore.SerialMode.f22_Modbus_RTU)
|
|
{
|
|
this.smartModbusSlave4.SlaveAddress = this.SystemConfig2.ModbusRTUSlaveIDCOM4;
|
|
switch (this.SystemConfig1.SerialCOM4BaudRate)
|
|
{
|
|
case 0:
|
|
this.smartModbusSlave4.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
break;
|
|
case 1:
|
|
this.smartModbusSlave4.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_19200;
|
|
break;
|
|
case 2:
|
|
this.smartModbusSlave4.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_38400;
|
|
break;
|
|
case 3:
|
|
this.smartModbusSlave4.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_57600;
|
|
break;
|
|
case 4:
|
|
this.smartModbusSlave4.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_115200;
|
|
break;
|
|
default:
|
|
this.smartModbusSlave4.Buad_Rate = SmartModbusSlave.BUADRATE.CBR_9600;
|
|
break;
|
|
}
|
|
this.smartModbusSlave4.Start();
|
|
}
|
|
}
|
|
public void CloseModbusSlaveCOM4()
|
|
{
|
|
if (this.smartModbusSlave4.IsOpen == true)
|
|
this.smartModbusSlave4.End();
|
|
}
|
|
#endregion
|
|
#region Modbus COM1
|
|
public void OpenModbusCOM1()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM1Mode == 0)
|
|
return;
|
|
|
|
if (this.SystemConfig1.SerialCOM1Mode == 16)
|
|
{
|
|
this.CloseModbusCOM1();
|
|
this.smartModbusSlave1.Start();
|
|
}
|
|
}
|
|
public void CloseModbusCOM1()
|
|
{
|
|
if (this.smartModbusSlave1.IsOpen == true)
|
|
this.smartModbusSlave1.End();
|
|
}
|
|
#endregion
|
|
#region Modbus COM3
|
|
public void OpenModbusCOM3()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM3Mode == 0)
|
|
return;
|
|
|
|
if (this.SystemConfig1.SerialCOM3Mode == 16)
|
|
{
|
|
this.CloseModbusCOM3();
|
|
this.smartModbusSlave3.Start();
|
|
}
|
|
}
|
|
public void CloseModbusCOM3()
|
|
{
|
|
if (this.smartModbusSlave3.IsOpen == true)
|
|
this.smartModbusSlave3.End();
|
|
}
|
|
#endregion
|
|
#region Modbus COM4
|
|
public void OpenModbusCOM4()
|
|
{
|
|
if (this.SystemConfig1.SerialCOM4Mode == 0)
|
|
return;
|
|
|
|
if (this.SystemConfig1.SerialCOM4Mode == 16)
|
|
{
|
|
this.CloseModbusCOM4();
|
|
this.smartModbusSlave4.Start();
|
|
}
|
|
}
|
|
public void CloseModbusCOM4()
|
|
{
|
|
if (this.smartModbusSlave4.IsOpen == true)
|
|
this.smartModbusSlave4.End();
|
|
}
|
|
#endregion
|
|
|
|
#region Ethernet
|
|
//private string EthernetWeightDataFormat(SystemConfigurationItem1 system, WeightData weight, ProductItem product)
|
|
//{
|
|
// StringBuilder sb = new StringBuilder();
|
|
|
|
// sb.Append((char)0x02);
|
|
// sb.Append(string.Format("IN{0:000}", system.EquipmentID));
|
|
// sb.Append(string.Format("{0:0000}", product.Number));
|
|
|
|
// sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.UnderRange, system.DecimalPlaces)));
|
|
// sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.PassRange, system.DecimalPlaces)));
|
|
// sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.OverRange, system.DecimalPlaces)));
|
|
|
|
// switch (weight.JudgmentStatus)
|
|
// {
|
|
// case DataStore.JudgmentStatus.Empty:
|
|
// break;
|
|
// case DataStore.JudgmentStatus.Under:
|
|
// sb.Append("U");
|
|
// break;
|
|
// case DataStore.JudgmentStatus.Pass:
|
|
// sb.Append("P");
|
|
// break;
|
|
// case DataStore.JudgmentStatus.Over:
|
|
// sb.Append("O");
|
|
// break;
|
|
// case DataStore.JudgmentStatus.Double:
|
|
// sb.Append("D");
|
|
// break;
|
|
// case DataStore.JudgmentStatus.Metal:
|
|
// sb.Append("M");
|
|
// break;
|
|
// case DataStore.JudgmentStatus.ExNg:
|
|
// sb.Append("E");
|
|
// break;
|
|
// default:
|
|
// sb.Append("E");
|
|
// break;
|
|
// }
|
|
|
|
// sb.Append(Helper.StringZeroFillDigits6(Helper.DoubleToString(weight.Weight, system.DecimalPlaces)));
|
|
// sb.Append((char)0x03);
|
|
|
|
// return sb.ToString();
|
|
//}
|
|
|
|
#region Client
|
|
public void EthernetClientConnect()
|
|
{
|
|
if (this.IsEthernetThreadStop == false)
|
|
return; // Online 경우
|
|
if (this.SystemConfig2.IsEthernetEnable == false)
|
|
{
|
|
this.TextStatusOut("<Disable");
|
|
return;
|
|
}
|
|
|
|
if (string.Compare(this.SystemConfig2.EthernetAddress, "0.0.0.0") == 0)
|
|
{
|
|
this.TextStatusOut("<Addr Err");
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
Thread cpClientThread = new Thread(new ThreadStart(EthernetClientReceiveThread));
|
|
|
|
cpClientThread.IsBackground = true;
|
|
|
|
cpClientThread.Start();
|
|
}
|
|
catch
|
|
{
|
|
TextStatusOut(">Thread Error");
|
|
}
|
|
}
|
|
public void EthernetClientDisconnect()
|
|
{
|
|
this.IsEthernetThreadStop = true;
|
|
this.DelegateUISeverStatus(false);
|
|
if (null != this.EthernetStmReader)
|
|
this.EthernetStmReader.Close();
|
|
|
|
if (null != this.EthernetStmWriter)
|
|
this.EthernetStmWriter.Close();
|
|
|
|
if (null != this.EthernetNetStream)
|
|
this.EthernetNetStream.Close();
|
|
|
|
if (null != this.EthernetTcpClient)
|
|
this.EthernetTcpClient.Close();
|
|
}
|
|
|
|
private void EthernetClientReceiveThread()
|
|
{
|
|
int nConnectPort = Convert.ToInt32(this.SystemConfig2.EthernetPort);
|
|
try
|
|
{
|
|
this.DelegateTextStatusOut(">Now Connecting..");
|
|
this.EthernetTcpClient = new TcpClient(this.SystemConfig2.EthernetAddress, nConnectPort);
|
|
|
|
this.EthernetNetStream = EthernetTcpClient.GetStream();
|
|
this.EthernetStmReader = new StreamReader(EthernetNetStream);
|
|
this.EthernetStmWriter = new StreamWriter(EthernetNetStream);
|
|
|
|
this.DelegateUISeverStatus(true);
|
|
this.DelegateTextStatusOut(">Connected Server");
|
|
|
|
this.IsEthernetThreadStop = false;
|
|
|
|
// 판정 데이터 전송
|
|
if (this.IsEthernetTransferData == true)
|
|
{
|
|
this.IsEthernetTransferData = false;
|
|
Type type = this.EthernetTransferData.GetType();
|
|
if (type == typeof(string))
|
|
this.DelegateTransferData((string)this.EthernetTransferData);
|
|
else if (type == typeof(byte[]))
|
|
this.DelegateTransferData((byte[])this.EthernetTransferData);
|
|
else if (type == typeof(byte))
|
|
this.DelegateTransferData((byte)this.EthernetTransferData);
|
|
}
|
|
|
|
while (this.IsEthernetThreadStop == false)
|
|
{
|
|
string strRecvMsg = this.EthernetStmReader.ReadLine();
|
|
|
|
if (null == strRecvMsg)
|
|
{
|
|
this.DelegateTextStatusOut(">Server Out");
|
|
this.IsEthernetThreadStop = true;
|
|
break;
|
|
}
|
|
|
|
this.DelegateTextStatusOut(strRecvMsg);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
this.DelegateTextStatusOut(">Connect Fail !");
|
|
}
|
|
finally
|
|
{
|
|
this.IsEthernetThreadStop = true;
|
|
this.DelegateUISeverStatus(false);
|
|
this.DelegateTextStatusOut(">Disconnected Server");
|
|
if (null != this.EthernetStmReader)
|
|
this.EthernetStmReader.Close();
|
|
|
|
if (null != this.EthernetStmWriter)
|
|
this.EthernetStmWriter.Close();
|
|
|
|
if (null != this.EthernetNetStream)
|
|
this.EthernetNetStream.Close();
|
|
|
|
if (null != this.EthernetTcpClient)
|
|
this.EthernetTcpClient.Close();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
private void UIServerStatus(bool status)
|
|
{
|
|
this.ChildFormMainDisplay.UpdateEthernetStatusDisplay(status);
|
|
}
|
|
private void DelegateUISeverStatus(bool status)
|
|
{
|
|
this.Invoke(new UIServerStatusCallback(this.UIServerStatus), status);
|
|
}
|
|
|
|
private void TextStatusOut(string value)
|
|
{
|
|
if (this.ChildFormMenu.CenterConfiEthernet != null)
|
|
this.ChildFormMenu.CenterConfiEthernet.UpdateEthernetStatusDisplay(value);
|
|
}
|
|
private void DelegateTextStatusOut(string value)
|
|
{
|
|
this.Invoke(new TextStatusCallback(this.TextStatusOut), value);
|
|
}
|
|
|
|
private void DelegateTransferData(string data)
|
|
{
|
|
this.Invoke(new TransferDataCollbaack(this.EthernetSendMessage), data);
|
|
}
|
|
private void DelegateTransferData(byte[] data)
|
|
{
|
|
this.Invoke(new TransferDataCollbaack(this.EthernetSendMessage), data);
|
|
}
|
|
private void DelegateTransferData(byte data)
|
|
{
|
|
this.Invoke(new TransferDataCollbaack(this.EthernetSendMessage), data);
|
|
}
|
|
public void EthernetSendMessage(string msg)
|
|
{
|
|
try
|
|
{
|
|
this.EthernetStmWriter.WriteLine(msg);
|
|
this.EthernetStmWriter.Flush();
|
|
}
|
|
catch
|
|
{
|
|
this.DelegateUISeverStatus(false);
|
|
this.DelegateTextStatusOut("> Disconnect");
|
|
}
|
|
}
|
|
public void EthernetSendMessage(byte[] msg)
|
|
{
|
|
try
|
|
{
|
|
this.EthernetStmWriter.WriteLine(msg);
|
|
this.EthernetStmWriter.Flush();
|
|
}
|
|
catch
|
|
{
|
|
this.DelegateUISeverStatus(false);
|
|
this.DelegateTextStatusOut("> Disconnect");
|
|
}
|
|
}
|
|
public void EthernetSendMessage(byte msg)
|
|
{
|
|
try
|
|
{
|
|
this.EthernetStmWriter.WriteLine(msg);
|
|
this.EthernetStmWriter.Flush();
|
|
}
|
|
catch
|
|
{
|
|
this.DelegateUISeverStatus(false);
|
|
this.DelegateTextStatusOut("> Disconnect");
|
|
}
|
|
}
|
|
public void EthernetWeightData(string strTemp)
|
|
{
|
|
this.IsEthernetTransferData = true;
|
|
this.EthernetTransferData = strTemp;
|
|
|
|
if (this.IsEthernetThreadStop == true)
|
|
this.EthernetClientConnect();
|
|
else
|
|
this.EthernetSendMessage((string)this.EthernetTransferData);
|
|
}
|
|
public void EthernetWeightData(byte[] bytes)
|
|
{
|
|
this.IsEthernetTransferData = true;
|
|
this.EthernetTransferData = bytes;
|
|
|
|
if (this.IsEthernetThreadStop == true)
|
|
this.EthernetClientConnect();
|
|
else
|
|
this.EthernetSendMessage((byte[])this.EthernetTransferData);
|
|
}
|
|
public void EthernetWeightData(byte temp)
|
|
{
|
|
this.IsEthernetTransferData = true;
|
|
this.EthernetTransferData = temp;
|
|
|
|
if (this.IsEthernetThreadStop == true)
|
|
this.EthernetClientConnect();
|
|
else
|
|
this.EthernetSendMessage((byte)this.EthernetTransferData);
|
|
}
|
|
#endregion
|
|
|
|
#region Server
|
|
public void EthernetServerStart()
|
|
{
|
|
if (this.smartTCPMultiServer.IsStart == false)
|
|
{
|
|
this.ChildFormMenu.CenterConfiEthernet.DisplayLabelLocalPort(false);
|
|
this.smartTCPMultiServer.Port = this.SystemConfig2.EthernetLocalPort;
|
|
this.smartTCPMultiServer.Start();
|
|
}
|
|
}
|
|
public void EthernetServerStop()
|
|
{
|
|
if (this.smartTCPMultiServer.IsStart == true)
|
|
{
|
|
this.ChildFormMenu.CenterConfiEthernet.DisplayLabelLocalPort(true);
|
|
this.smartTCPMultiServer.Stop();
|
|
}
|
|
}
|
|
public void EthernetServerSendMessage(SmartTCPMultiServer.CLIENTSINFOS client, string msg)
|
|
{
|
|
this.smartTCPMultiServer.SendStringASCIIID(client.strID, msg);
|
|
}
|
|
public void EthernetServerSendMessage(SmartTCPMultiServer.CLIENTSINFOS client, byte[] bytes)
|
|
{
|
|
this.smartTCPMultiServer.SendByteByClientID(client.strID, bytes);
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Alarm
|
|
public void ClearAlarm(int clearAlarm)
|
|
{
|
|
// 0:모두 1:알람1 2:알람2
|
|
if (clearAlarm == 1)
|
|
this.CountingOutput1Count = 0;
|
|
else if (clearAlarm == 2)
|
|
this.CountingOutput2Count = 0;
|
|
else
|
|
{
|
|
this.CountingOutput1Count = 0;
|
|
this.CountingOutput2Count = 0;
|
|
}
|
|
|
|
this.ChildFormMainDisplay.MainDisplayWeightBigScreen.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
|
|
this.ChildFormMainDisplay.MainDisplayWeightSmall.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
|
|
}
|
|
#endregion
|
|
|
|
#region Data Backup
|
|
private void RemoveUsbBackupFile()
|
|
{
|
|
bool directoryCheck = false;
|
|
|
|
try
|
|
{
|
|
string dday = string.Format("{0:yyyyMMdd}", DateTime.Now.AddDays(-180)) + ".csv";
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(this.PathDataBackupFolder);
|
|
|
|
directoryCheck = dir.Exists;
|
|
// 폴더 체크
|
|
if (directoryCheck == false)
|
|
dir.Create();
|
|
|
|
FileInfo[] files = dir.GetFiles();
|
|
foreach (FileInfo subfile in files)
|
|
{
|
|
if (subfile.Name.StartsWith("20")) // 날짜 비교하여 180일 지난화일은 삭제함
|
|
{
|
|
if (subfile.Name.CompareTo(dday) < 0)
|
|
{
|
|
subfile.Delete();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// DataBackup Format - STD1
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
private void DataBackup0(WeightData item)
|
|
{
|
|
bool fileCheck = false, directoryCheck = false;
|
|
string fullFilePath = "";
|
|
string filePathExtension = "";
|
|
StreamWriter sw;
|
|
DateTime time = DateTime.Now;
|
|
|
|
this.RemoveUsbBackupFile();
|
|
|
|
if (this.SystemConfig2.FileNameExtension == 0)
|
|
filePathExtension = ".csv";
|
|
else
|
|
filePathExtension = ".txt";
|
|
|
|
fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}_{3}{4}", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig1.UsbID, this.CurrentProductItem.Name, filePathExtension);
|
|
|
|
DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
|
|
directoryCheck = di.Exists;
|
|
// 폴더 체크
|
|
if (directoryCheck == false)
|
|
di.Create();
|
|
// 파일 체크
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
sw = new StreamWriter(fullFilePath, true, Encoding.UTF8);
|
|
|
|
if (fileCheck == false)
|
|
{
|
|
sw.Write("Date");
|
|
sw.Write(",");
|
|
sw.Write("Time");
|
|
sw.Write(",");
|
|
sw.Write("P_No");
|
|
sw.Write(",");
|
|
sw.Write("Name");
|
|
sw.Write(",");
|
|
sw.Write("Lot");
|
|
sw.Write(",");
|
|
sw.Write("UnderRange");
|
|
sw.Write(",");
|
|
sw.Write("PassRange");
|
|
sw.Write(",");
|
|
sw.Write("OverRange");
|
|
sw.Write(",");
|
|
sw.Write("TareRange");
|
|
sw.Write(",");
|
|
sw.Write("Weight");
|
|
sw.Write(",");
|
|
sw.Write("Grade");
|
|
sw.WriteLine();
|
|
}
|
|
|
|
sw.Write(string.Format("{0:yyyy-MM-dd}", time));
|
|
sw.Write(",");
|
|
sw.Write(string.Format("{0:HH:mm:ss}", time));
|
|
sw.Write(",");
|
|
sw.Write(this.CurrentProductItem.Number);
|
|
sw.Write(",");
|
|
sw.Write(this.CurrentProductItem.Name);
|
|
sw.Write(",");
|
|
sw.Write(this.CurrentProductItem.LotNo);
|
|
sw.Write(",");
|
|
sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces));
|
|
sw.Write(",");
|
|
sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces));
|
|
sw.Write(",");
|
|
sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces));
|
|
sw.Write(",");
|
|
sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.TareRange, this.SystemConfig1.DecimalPlaces));
|
|
sw.Write(",");
|
|
if(item.Weight == this.OverloadWeight)
|
|
sw.Write("O.L");
|
|
else
|
|
sw.Write(Helper.DoubleToString(item.Weight, this.SystemConfig1.DecimalPlaces));
|
|
sw.Write(",");
|
|
sw.Write(item.JudgmentStatus);
|
|
|
|
sw.WriteLine();
|
|
|
|
sw.Close();
|
|
}
|
|
/// <summary>
|
|
/// DataBackup Format - OPT1(종근당)
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
private void DataBackup1(DataBackupOPT1 item)
|
|
{
|
|
bool fileCheck = false, directoryCheck = false;
|
|
string fullFilePath = "";
|
|
string filePathExtension = "";
|
|
StreamWriter sw;
|
|
DateTime time = DateTime.Now;
|
|
|
|
this.RemoveUsbBackupFile();
|
|
|
|
if (this.SystemConfig2.FileNameExtension == 0)
|
|
filePathExtension = ".csv";
|
|
else
|
|
filePathExtension = ".txt";
|
|
|
|
fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}_{3}{4}", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig1.UsbID, this.CurrentProductItem.Name, filePathExtension);
|
|
|
|
DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
|
|
directoryCheck = di.Exists;
|
|
// 폴더 체크
|
|
if (directoryCheck == false)
|
|
di.Create();
|
|
// 파일 체크
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
sw = new StreamWriter(fullFilePath, true, Encoding.UTF8);
|
|
|
|
#region OPT1 - 종근당
|
|
// 제품명, LOT번호, 상한설정값, 하한설정값, 중량, 날짜, 시간, Pass수량, Grade, Status
|
|
if (fileCheck == false)
|
|
{
|
|
sw.Write("Name");
|
|
sw.Write(",");
|
|
sw.Write("LOT");
|
|
sw.Write(",");
|
|
sw.Write("OverRange");
|
|
sw.Write(",");
|
|
sw.Write("UnderRange");
|
|
sw.Write(",");
|
|
sw.Write("Weight");
|
|
sw.Write(",");
|
|
sw.Write("Date");
|
|
sw.Write(",");
|
|
sw.Write("Time");
|
|
sw.Write(",");
|
|
sw.Write("Pass Count");
|
|
sw.Write(",");
|
|
sw.Write("Grade");
|
|
sw.Write(",");
|
|
sw.Write("Status");
|
|
sw.WriteLine();
|
|
}
|
|
|
|
sw.Write(item.Name);
|
|
sw.Write(",");
|
|
sw.Write(item.Lot);
|
|
sw.Write(",");
|
|
sw.Write(item.OverRange);
|
|
sw.Write(",");
|
|
sw.Write(item.UnderRange);
|
|
sw.Write(",");
|
|
if (double.Parse(item.Weight) == this.OverloadWeight)
|
|
sw.Write("O.L");
|
|
else
|
|
sw.Write(item.Weight);
|
|
sw.Write(",");
|
|
sw.Write(item.Date);
|
|
sw.Write(",");
|
|
sw.Write(item.Time);
|
|
sw.Write(",");
|
|
sw.Write(item.PassCount);
|
|
sw.Write(",");
|
|
sw.Write(item.Grade);
|
|
sw.Write(",");
|
|
sw.Write(item.Status);
|
|
|
|
sw.WriteLine();
|
|
sw.Close();
|
|
#endregion
|
|
}
|
|
///// <summary>
|
|
///// DataBackup Format - OPT1(종근당)
|
|
///// </summary>
|
|
///// <param name="item"></param>
|
|
//private void DataBackup1(WeightData item)
|
|
//{
|
|
// bool fileCheck = false, directoryCheck = false;
|
|
// string fullFilePath = "";
|
|
// StreamWriter sw;
|
|
// DateTime time = DateTime.Now;
|
|
|
|
// this.RemoveUsbBackupFile();
|
|
|
|
// fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}_{3}.csv", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig.UsbID, this.CurrentProductItem.Name);
|
|
|
|
// DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
|
|
// directoryCheck = di.Exists;
|
|
// // 폴더 체크
|
|
// if (directoryCheck == false)
|
|
// di.Create();
|
|
// // 파일 체크
|
|
// FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
// fileCheck = fileInfo.Exists;
|
|
|
|
// sw = new StreamWriter(fullFilePath, true, Encoding.Default);
|
|
|
|
// #region OPT1 - 종근당
|
|
// // 제품명, LOT번호, 상한설정값, 하한설정값, 중량, 날짜, 시간, Pass수량, Grade, Status
|
|
// if (fileCheck == false)
|
|
// {
|
|
// sw.Write("Name");
|
|
// sw.Write(",");
|
|
// sw.Write("LOT");
|
|
// sw.Write(",");
|
|
// sw.Write("OverRange");
|
|
// sw.Write(",");
|
|
// sw.Write("UnderRange");
|
|
// sw.Write(",");
|
|
// sw.Write("Weight");
|
|
// sw.Write(",");
|
|
// sw.Write("Date");
|
|
// sw.Write(",");
|
|
// sw.Write("Time");
|
|
// sw.Write(",");
|
|
// sw.Write("Pass Count");
|
|
// sw.Write(",");
|
|
// sw.Write("Grade");
|
|
// sw.Write(",");
|
|
// sw.Write("Status");
|
|
// sw.WriteLine();
|
|
// }
|
|
|
|
// sw.Write(this.CurrentProductItem.Name);
|
|
// sw.Write(",");
|
|
// sw.Write(this.CurrentProductItem.LotNo);
|
|
// sw.Write(",");
|
|
// sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.OverRange, this.SystemConfig.DecimalPlaces));
|
|
// sw.Write(",");
|
|
// sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.UnderRange, this.SystemConfig.DecimalPlaces));
|
|
// sw.Write(",");
|
|
// sw.Write(Helper.DoubleToString(item.Weight, this.SystemConfig.DecimalPlaces));
|
|
// sw.Write(",");
|
|
// sw.Write(string.Format("{0:yyyy-MM-dd}", time));
|
|
// sw.Write(",");
|
|
// sw.Write(string.Format("{0:HH:mm:ss}", time));
|
|
// sw.Write(",");
|
|
// sw.Write(item.PassCount);
|
|
// sw.Write(",");
|
|
// sw.Write(item.JudgmentStatus);
|
|
// sw.Write(",");
|
|
// sw.Write("리젝데이터");
|
|
|
|
// sw.WriteLine();
|
|
// sw.Close();
|
|
// #endregion
|
|
//}
|
|
#endregion
|
|
|
|
#region SystemConfiguration File1
|
|
private void CreateSystemConfigurationFile1()
|
|
{
|
|
StructSystemConfigurationItem1 structItem;
|
|
|
|
this.SystemConfig1.Initialization();
|
|
|
|
structItem.IsDataBackup = this.SystemConfig1.IsDataBackup;
|
|
structItem.IsLogin = this.SystemConfig1.IsLogin;
|
|
|
|
structItem.EquipmentID = this.SystemConfig1.EquipmentID;
|
|
structItem.DecimalPlaces = this.SystemConfig1.DecimalPlaces;
|
|
structItem.ProductNumber = this.SystemConfig1.ProductNumber;
|
|
structItem.UsbID = this.SystemConfig1.UsbID;
|
|
structItem.Serial1BaudRate = this.SystemConfig1.SerialCOM1BaudRate;
|
|
structItem.Serial1Mode = this.SystemConfig1.SerialCOM1Mode;
|
|
structItem.Serial2BaudRate = this.SystemConfig1.SerialCOM3BaudRate;
|
|
structItem.Serial2Mode = this.SystemConfig1.SerialCOM3Mode;
|
|
structItem.Serial3BaudRate = this.SystemConfig1.SerialCOM4BaudRate;
|
|
structItem.Serial3Mode = this.SystemConfig1.SerialCOM4Mode;
|
|
|
|
structItem.SerialNumber = this.SystemConfig1.SerialNumber;
|
|
structItem.Language = this.SystemConfig1.Language;
|
|
structItem.Unit = this.SystemConfig1.Unit;
|
|
|
|
structItem.IsBLDCON = this.SystemConfig1.IsBLDCON;
|
|
structItem.IsExternalInputLamp = this.SystemConfig1.IsExternalInputLamp;
|
|
structItem.IsExternalInputBuzzer = this.SystemConfig1.IsExternalInputBuzzer;
|
|
structItem.IsPrintPerProductEnable = this.SystemConfig1.IsPrintPerProductEnable;
|
|
structItem.IsBarcodeEnable = this.SystemConfig1.IsBarcodeEnable;
|
|
structItem.TransmissionDelayTimeCOM1 = this.SystemConfig1.TransmissionDelayTimeCOM1;
|
|
structItem.TransmissionDelayTimeCOM3 = this.SystemConfig1.TransmissionDelayTimeCOM3;
|
|
structItem.TransmissionDelayTimeCOM4 = this.SystemConfig1.TransmissionDelayTimeCOM4;
|
|
structItem.StatisticsPrintFormat = this.SystemConfig1.StatisticsPrintFormat;
|
|
structItem.DatabackupFormat = this.SystemConfig1.DatabackupFormat;
|
|
structItem.DummyString1 = "0";
|
|
structItem.UserDefineCOM1 = this.SystemConfig1.UserDefineCOM1;
|
|
structItem.UserDefineCOM3 = this.SystemConfig1.UserDefineCOM3;
|
|
structItem.UserDefineCOM4 = this.SystemConfig1.UserDefineCOM4;
|
|
structItem.DummyString5 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
}
|
|
public void SaveSystemConfigurationFile1(SystemConfigurationItem1 item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemConfigurationItem1 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "system.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemConfigurationFile1();
|
|
}
|
|
|
|
structItem.IsDataBackup = item.IsDataBackup;
|
|
structItem.IsLogin = item.IsLogin;
|
|
|
|
structItem.EquipmentID = item.EquipmentID;
|
|
structItem.DecimalPlaces = item.DecimalPlaces;
|
|
structItem.ProductNumber = item.ProductNumber;
|
|
structItem.UsbID = item.UsbID;
|
|
structItem.Serial1BaudRate = item.SerialCOM1BaudRate;
|
|
structItem.Serial1Mode = item.SerialCOM1Mode;
|
|
structItem.Serial2BaudRate = item.SerialCOM3BaudRate;
|
|
structItem.Serial2Mode = item.SerialCOM3Mode;
|
|
structItem.Serial3BaudRate = item.SerialCOM4BaudRate;
|
|
structItem.Serial3Mode = item.SerialCOM4Mode;
|
|
|
|
structItem.SerialNumber = item.SerialNumber;
|
|
structItem.Language = item.Language;
|
|
structItem.Unit = item.Unit;
|
|
|
|
structItem.IsBLDCON = item.IsBLDCON;
|
|
structItem.IsExternalInputLamp = item.IsExternalInputLamp;
|
|
structItem.IsExternalInputBuzzer = item.IsExternalInputBuzzer;
|
|
structItem.IsPrintPerProductEnable = item.IsPrintPerProductEnable;
|
|
structItem.IsBarcodeEnable = item.IsBarcodeEnable;
|
|
structItem.TransmissionDelayTimeCOM1 = item.TransmissionDelayTimeCOM1;
|
|
structItem.TransmissionDelayTimeCOM3 = item.TransmissionDelayTimeCOM3;
|
|
structItem.TransmissionDelayTimeCOM4 = item.TransmissionDelayTimeCOM4;
|
|
structItem.StatisticsPrintFormat = item.StatisticsPrintFormat;
|
|
structItem.DatabackupFormat = item.DatabackupFormat;
|
|
structItem.DummyString1 = "0";
|
|
structItem.UserDefineCOM1 = item.UserDefineCOM1;
|
|
structItem.UserDefineCOM3 = item.UserDefineCOM3;
|
|
structItem.UserDefineCOM4 = item.UserDefineCOM4;
|
|
structItem.DummyString5 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadSystemConfigurationFile1()
|
|
{
|
|
string fullFilePath = "", value = "";
|
|
bool fileCheck = false;
|
|
StructSystemConfigurationItem1 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "system.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemConfigurationFile1();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructSystemConfigurationItem1)this.smartFileIO.ReadStructure(0, typeof(StructSystemConfigurationItem1));
|
|
|
|
this.SystemConfig1.IsDataBackup = structItem.IsDataBackup;
|
|
this.SystemConfig1.IsLogin = structItem.IsLogin;
|
|
this.SystemConfig1.IsBarcodeEnable = structItem.IsBarcodeEnable;
|
|
this.SystemConfig1.IsPrintPerProductEnable = structItem.IsPrintPerProductEnable;
|
|
this.SystemConfig1.IsExternalInputBuzzer = structItem.IsExternalInputBuzzer;
|
|
this.SystemConfig1.IsExternalInputLamp = structItem.IsExternalInputLamp;
|
|
this.SystemConfig1.IsBLDCON = structItem.IsBLDCON;
|
|
|
|
this.SystemConfig1.EquipmentID = structItem.EquipmentID;
|
|
this.SystemConfig1.DecimalPlaces = structItem.DecimalPlaces;
|
|
this.SystemConfig1.ProductNumber = structItem.ProductNumber;
|
|
this.SystemConfig1.UsbID = structItem.UsbID;
|
|
this.SystemConfig1.SerialCOM1BaudRate = structItem.Serial1BaudRate;
|
|
this.SystemConfig1.SerialCOM1Mode = structItem.Serial1Mode;
|
|
this.SystemConfig1.SerialCOM3BaudRate = structItem.Serial2BaudRate;
|
|
this.SystemConfig1.SerialCOM3Mode = structItem.Serial2Mode;
|
|
this.SystemConfig1.SerialCOM4BaudRate = structItem.Serial3BaudRate;
|
|
this.SystemConfig1.SerialCOM4Mode = structItem.Serial3Mode;
|
|
this.SystemConfig1.DatabackupFormat = structItem.DatabackupFormat;
|
|
this.SystemConfig1.TransmissionDelayTimeCOM1 = structItem.TransmissionDelayTimeCOM1;
|
|
this.SystemConfig1.TransmissionDelayTimeCOM3 = structItem.TransmissionDelayTimeCOM3;
|
|
this.SystemConfig1.TransmissionDelayTimeCOM4 = structItem.TransmissionDelayTimeCOM4;
|
|
this.SystemConfig1.StatisticsPrintFormat = structItem.StatisticsPrintFormat;
|
|
|
|
this.SystemConfig1.SerialNumber = structItem.SerialNumber;
|
|
this.SystemConfig1.Language = structItem.Language;
|
|
this.SystemConfig1.Unit = structItem.Unit;
|
|
this.SystemConfig1.UserDefineCOM1 = structItem.UserDefineCOM1;
|
|
this.SystemConfig1.UserDefineCOM3 = structItem.UserDefineCOM3;
|
|
this.SystemConfig1.UserDefineCOM4 = structItem.UserDefineCOM4;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
#region SystemConfiguration File2
|
|
private void CreateSystemConfigurationFile2()
|
|
{
|
|
StructSystemConfigurationItem2 structItem;
|
|
|
|
this.SystemConfig2.Initialization();
|
|
|
|
structItem.Alarm1Mode = this.SystemConfig2.CountingOutput1Mode;
|
|
structItem.Alarm1Number = this.SystemConfig2.CountingOutput1Number;
|
|
structItem.IsAlarm1Continuous = this.SystemConfig2.IsCountingOutput1Continuous;
|
|
structItem.IsAlarm1ConveyorStop = this.SystemConfig2.IsCountingOutput1ConveyorStop;
|
|
structItem.IsAlarm1BuzzerOn = this.SystemConfig2.IsCountingOutput1BuzzerOn;
|
|
structItem.IsAlarm1ExternalOutput = this.SystemConfig2.IsCountingOutput1ExternalOutput;
|
|
|
|
structItem.Alarm2Mode = this.SystemConfig2.CountingOutput2Mode;
|
|
structItem.Alarm2Number = this.SystemConfig2.CountingOutput2Number;
|
|
structItem.IsAlarm2Continuous = this.SystemConfig2.IsCountingOutput2Continuous;
|
|
structItem.IsAlarm2ConveyorStop = this.SystemConfig2.IsCountingOutput2ConveyorStop;
|
|
structItem.IsAlarm2BuzzerOn = this.SystemConfig2.IsCountingOutput2BuzzerOn;
|
|
structItem.IsAlarm2ExternalOutput = this.SystemConfig2.IsCountingOutput2ExternalOutput;
|
|
|
|
structItem.DummyBool1 = false;
|
|
structItem.IsCommunicationOption = this.SystemConfig2.IsCommunicationOption;
|
|
structItem.IsBypassOnce = this.SystemConfig2.IsBypassOnce;
|
|
structItem.IsBypassDirectionPass = this.SystemConfig2.IsBypassDirectionPass;
|
|
structItem.IsHitachiBlankToNoneCOM4 = this.SystemConfig2.IsHitachiBlankToNoneCOM4;
|
|
structItem.IsHitachiBlankToNoneCOM3 = this.SystemConfig2.IsHitachiBlankToNoneCOM3;
|
|
structItem.IsHitachiBlankToNoneCOM1 = this.SystemConfig2.IsHitachiBlankToNoneCOM1;
|
|
structItem.IsMarkoprintTodaytDatePrintEthernet = this.SystemConfig2.IsMarkoprintTodaytDatePrintEthernet;
|
|
structItem.IsMarkoprintDatePrintEthernet = this.SystemConfig2.IsMarkoprintDatePrintEthernet;
|
|
structItem.IsGroup1UsingRandomMode = this.SystemConfig2.IsGroup1UsingRandomMode;
|
|
structItem.IsGroup2UsingRandomMode = this.SystemConfig2.IsGroup2UsingRandomMode;
|
|
structItem.IsGroup3UsingRandomMode = this.SystemConfig2.IsGroup3UsingRandomMode;
|
|
structItem.IsGroup4UsingRandomMode = this.SystemConfig2.IsGroup4UsingRandomMode;
|
|
structItem.IsGroup5UsingRandomMode = this.SystemConfig2.IsGroup5UsingRandomMode;
|
|
structItem.IsMarkoprintTodaytDatePrintCOM4 = this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM4;
|
|
structItem.IsMarkoprintDatePrintCOM4 = this.SystemConfig2.IsMarkoprintDatePrintCOM4;
|
|
structItem.IsMarkoprintTodaytDatePrintCOM3 = this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM3;
|
|
structItem.IsMarkoprintDatePrintCOM3 = this.SystemConfig2.IsMarkoprintDatePrintCOM3;
|
|
structItem.IsMarkoprintTodaytDatePrintCOM1 = this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM1;
|
|
structItem.IsMarkoprintDatePrintCOM1 = this.SystemConfig2.IsMarkoprintDatePrintCOM1;
|
|
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
structItem.DummyInt3 = 0;
|
|
structItem.DummyInt4 = 0;
|
|
structItem.DummyInt5 = 0;
|
|
structItem.DummyInt6 = 0;
|
|
structItem.DummyInt7 = 0;
|
|
structItem.DummyInt8 = 0;
|
|
structItem.DummyInt9 = 0;
|
|
structItem.DummyInt10 = 0;
|
|
structItem.ModbusRTUSelectFunction = this.SystemConfig2.ModbusRTUSelectFunction;
|
|
structItem.ModbusRTUSlaveIDCOM1 = this.SystemConfig2.ModbusRTUSlaveIDCOM1;
|
|
structItem.ModbusRTUSlaveIDCOM3 = this.SystemConfig2.ModbusRTUSlaveIDCOM3;
|
|
structItem.ModbusRTUSlaveIDCOM4 = this.SystemConfig2.ModbusRTUSlaveIDCOM4;
|
|
structItem.Barcode = this.SystemConfig2.Barcode;
|
|
structItem.EthernetLocalPort = this.SystemConfig2.EthernetLocalPort;
|
|
structItem.SortingPointLength = this.SystemConfig2.SortingPointLength;
|
|
structItem.ConveyorLength = this.SystemConfig2.ConveyorLength;
|
|
structItem.MarkoprintLineNumberEthernet = this.SystemConfig2.MarkoprintLineNumberEthernet;
|
|
structItem.HitachiRoomNumberEthernet = this.SystemConfig2.HitachiRoomNumberEthernet;
|
|
structItem.EthernetPort = this.SystemConfig2.EthernetPort;
|
|
structItem.EthernetCommMode = this.SystemConfig2.EthernetCommMode;
|
|
structItem.EthernetOperationMode = this.SystemConfig2.EthernetOperationMode;
|
|
structItem.FileNameExtension = this.SystemConfig2.FileNameExtension;
|
|
structItem.MarkoprintLineNumberCOM4 = this.SystemConfig2.MarkoprintLineNumberCOM4;
|
|
structItem.HitachiRoomNumberCOM4 = this.SystemConfig2.HitachiRoomNumberCOM4;
|
|
structItem.MarkoprintLineNumberCOM3 = this.SystemConfig2.MarkoprintLineNumberCOM3;
|
|
structItem.HitachiRoomNumberCOM3 = this.SystemConfig2.HitachiRoomNumberCOM3;
|
|
structItem.MarkoprintLineNumberCOM1 = this.SystemConfig2.MarkoprintLineNumberCOM1;
|
|
structItem.HitachiRoomNumberCOM1 = this.SystemConfig2.HitachiRoomNumberCOM1;
|
|
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
structItem.DummyString5 = "0";
|
|
structItem.DummyString6 = "0";
|
|
structItem.DummyString7 = "0";
|
|
structItem.DummyString8 = "0";
|
|
structItem.DummyString9 = "0";
|
|
structItem.DummyString10 = "0";
|
|
structItem.MarkoprintDateSettingEthernet = this.SystemConfig2.MarkoprintDateSettingEthernet;
|
|
structItem.EthernetAddress = this.SystemConfig2.EthernetAddress;
|
|
structItem.MarkoprintDateSettingCOM4 = this.SystemConfig2.MarkoprintDateSettingCOM4;
|
|
structItem.MarkoprintDateSettingCOM3 = this.SystemConfig2.MarkoprintDateSettingCOM3;
|
|
structItem.MarkoprintDateSettingCOM1 = this.SystemConfig2.MarkoprintDateSettingCOM1;
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
}
|
|
public void SaveSystemConfigurationFile2(SystemConfigurationItem2 item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemConfigurationItem2 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "system2.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemConfigurationFile2();
|
|
}
|
|
|
|
structItem.Alarm1Mode = item.CountingOutput1Mode;
|
|
structItem.Alarm1Number = item.CountingOutput1Number;
|
|
structItem.IsAlarm1Continuous = item.IsCountingOutput1Continuous;
|
|
structItem.IsAlarm1ConveyorStop = item.IsCountingOutput1ConveyorStop;
|
|
structItem.IsAlarm1BuzzerOn = item.IsCountingOutput1BuzzerOn;
|
|
structItem.IsAlarm1ExternalOutput = item.IsCountingOutput1ExternalOutput;
|
|
|
|
structItem.Alarm2Mode = item.CountingOutput2Mode;
|
|
structItem.Alarm2Number = item.CountingOutput2Number;
|
|
structItem.IsAlarm2Continuous = item.IsCountingOutput2Continuous;
|
|
structItem.IsAlarm2ConveyorStop = item.IsCountingOutput2ConveyorStop;
|
|
structItem.IsAlarm2BuzzerOn = item.IsCountingOutput2BuzzerOn;
|
|
structItem.IsAlarm2ExternalOutput = item.IsCountingOutput2ExternalOutput;
|
|
|
|
structItem.DummyBool1 = false;
|
|
structItem.IsCommunicationOption = item.IsCommunicationOption;
|
|
structItem.IsBypassOnce = item.IsBypassOnce;
|
|
structItem.IsBypassDirectionPass = item.IsBypassDirectionPass;
|
|
structItem.IsHitachiBlankToNoneCOM4 = item.IsHitachiBlankToNoneCOM4;
|
|
structItem.IsHitachiBlankToNoneCOM3 = item.IsHitachiBlankToNoneCOM3;
|
|
structItem.IsHitachiBlankToNoneCOM1 = item.IsHitachiBlankToNoneCOM1;
|
|
structItem.IsMarkoprintTodaytDatePrintEthernet = item.IsMarkoprintTodaytDatePrintEthernet;
|
|
structItem.IsMarkoprintDatePrintEthernet = item.IsMarkoprintDatePrintEthernet;
|
|
structItem.IsGroup1UsingRandomMode = item.IsGroup1UsingRandomMode;
|
|
structItem.IsGroup2UsingRandomMode = item.IsGroup2UsingRandomMode;
|
|
structItem.IsGroup3UsingRandomMode = item.IsGroup3UsingRandomMode;
|
|
structItem.IsGroup4UsingRandomMode = item.IsGroup4UsingRandomMode;
|
|
structItem.IsGroup5UsingRandomMode = item.IsGroup5UsingRandomMode;
|
|
structItem.IsMarkoprintTodaytDatePrintCOM4 = item.IsMarkoprintTodaytDatePrintCOM4;
|
|
structItem.IsMarkoprintDatePrintCOM4 = item.IsMarkoprintDatePrintCOM4;
|
|
structItem.IsMarkoprintTodaytDatePrintCOM3 = item.IsMarkoprintTodaytDatePrintCOM3;
|
|
structItem.IsMarkoprintDatePrintCOM3 = item.IsMarkoprintDatePrintCOM3;
|
|
structItem.IsMarkoprintTodaytDatePrintCOM1 = item.IsMarkoprintTodaytDatePrintCOM1;
|
|
structItem.IsMarkoprintDatePrintCOM1 = item.IsMarkoprintDatePrintCOM1;
|
|
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
structItem.DummyInt3 = 0;
|
|
structItem.DummyInt4 = 0;
|
|
structItem.DummyInt5 = 0;
|
|
structItem.DummyInt6 = 0;
|
|
structItem.DummyInt7 = 0;
|
|
structItem.DummyInt8 = 0;
|
|
structItem.DummyInt9 = 0;
|
|
structItem.DummyInt10 = 0;
|
|
structItem.ModbusRTUSelectFunction = item.ModbusRTUSelectFunction;
|
|
structItem.ModbusRTUSlaveIDCOM1 = item.ModbusRTUSlaveIDCOM1;
|
|
structItem.ModbusRTUSlaveIDCOM3 = item.ModbusRTUSlaveIDCOM3;
|
|
structItem.ModbusRTUSlaveIDCOM4 = item.ModbusRTUSlaveIDCOM4;
|
|
structItem.Barcode = item.Barcode;
|
|
structItem.EthernetLocalPort = item.EthernetLocalPort;
|
|
structItem.SortingPointLength = item.SortingPointLength;
|
|
structItem.ConveyorLength = item.ConveyorLength;
|
|
structItem.MarkoprintLineNumberEthernet = item.MarkoprintLineNumberEthernet;
|
|
structItem.HitachiRoomNumberEthernet = item.HitachiRoomNumberEthernet;
|
|
structItem.EthernetPort = item.EthernetPort;
|
|
structItem.EthernetCommMode = item.EthernetCommMode;
|
|
structItem.EthernetOperationMode = item.EthernetOperationMode;
|
|
structItem.FileNameExtension = item.FileNameExtension;
|
|
structItem.MarkoprintLineNumberCOM4 = item.MarkoprintLineNumberCOM4;
|
|
structItem.HitachiRoomNumberCOM4 = item.HitachiRoomNumberCOM4;
|
|
structItem.MarkoprintLineNumberCOM3 = item.MarkoprintLineNumberCOM3;
|
|
structItem.HitachiRoomNumberCOM3 = item.HitachiRoomNumberCOM3;
|
|
structItem.MarkoprintLineNumberCOM1 = item.MarkoprintLineNumberCOM1;
|
|
structItem.HitachiRoomNumberCOM1 = item.HitachiRoomNumberCOM1;
|
|
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
structItem.DummyString5 = "0";
|
|
structItem.DummyString6 = "0";
|
|
structItem.DummyString7 = "0";
|
|
structItem.DummyString8 = "0";
|
|
structItem.DummyString9 = "0";
|
|
structItem.DummyString10 = "0";
|
|
structItem.MarkoprintDateSettingEthernet = item.MarkoprintDateSettingEthernet;
|
|
structItem.EthernetAddress = item.EthernetAddress;
|
|
structItem.MarkoprintDateSettingCOM4 = item.MarkoprintDateSettingCOM4;
|
|
structItem.MarkoprintDateSettingCOM3 = item.MarkoprintDateSettingCOM3;
|
|
structItem.MarkoprintDateSettingCOM1 = item.MarkoprintDateSettingCOM1;
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadSystemConfigurationFile2()
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
string value;
|
|
StructSystemConfigurationItem2 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "system2.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemConfigurationFile2();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructSystemConfigurationItem2)this.smartFileIO.ReadStructure(0, typeof(StructSystemConfigurationItem2));
|
|
|
|
this.SystemConfig2.CountingOutput1Mode = structItem.Alarm1Mode;
|
|
this.SystemConfig2.CountingOutput1Number = structItem.Alarm1Number;
|
|
this.SystemConfig2.IsCountingOutput1Continuous = structItem.IsAlarm1Continuous;
|
|
this.SystemConfig2.IsCountingOutput1ConveyorStop = structItem.IsAlarm1ConveyorStop;
|
|
this.SystemConfig2.IsCountingOutput1BuzzerOn = structItem.IsAlarm1BuzzerOn;
|
|
this.SystemConfig2.IsCountingOutput1ExternalOutput = structItem.IsAlarm1ExternalOutput;
|
|
|
|
this.SystemConfig2.CountingOutput2Mode = structItem.Alarm2Mode;
|
|
this.SystemConfig2.CountingOutput2Number = structItem.Alarm2Number;
|
|
this.SystemConfig2.IsCountingOutput2Continuous = structItem.IsAlarm2Continuous;
|
|
this.SystemConfig2.IsCountingOutput2ConveyorStop = structItem.IsAlarm2ConveyorStop;
|
|
this.SystemConfig2.IsCountingOutput2BuzzerOn = structItem.IsAlarm2BuzzerOn;
|
|
this.SystemConfig2.IsCountingOutput2ExternalOutput = structItem.IsAlarm2ExternalOutput;
|
|
|
|
this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM1 = structItem.IsMarkoprintTodaytDatePrintCOM1;
|
|
this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM3 = structItem.IsMarkoprintTodaytDatePrintCOM3;
|
|
this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM4 = structItem.IsMarkoprintTodaytDatePrintCOM4;
|
|
this.SystemConfig2.IsMarkoprintDatePrintCOM1 = structItem.IsMarkoprintDatePrintCOM1;
|
|
this.SystemConfig2.IsMarkoprintDatePrintCOM3 = structItem.IsMarkoprintDatePrintCOM3;
|
|
this.SystemConfig2.IsMarkoprintDatePrintCOM4 = structItem.IsMarkoprintDatePrintCOM4;
|
|
|
|
this.SystemConfig2.MarkoprintLineNumberCOM1 = structItem.MarkoprintLineNumberCOM1;
|
|
this.SystemConfig2.MarkoprintLineNumberCOM3 = structItem.MarkoprintLineNumberCOM3;
|
|
this.SystemConfig2.MarkoprintLineNumberCOM4 = structItem.MarkoprintLineNumberCOM4;
|
|
this.SystemConfig2.HitachiRoomNumberCOM1 = structItem.HitachiRoomNumberCOM1;
|
|
this.SystemConfig2.HitachiRoomNumberCOM3 = structItem.HitachiRoomNumberCOM3;
|
|
this.SystemConfig2.HitachiRoomNumberCOM4 = structItem.HitachiRoomNumberCOM4;
|
|
|
|
this.SystemConfig2.IsHitachiBlankToNoneCOM1 = structItem.IsHitachiBlankToNoneCOM1;
|
|
this.SystemConfig2.IsHitachiBlankToNoneCOM3 = structItem.IsHitachiBlankToNoneCOM3;
|
|
this.SystemConfig2.IsHitachiBlankToNoneCOM4 = structItem.IsHitachiBlankToNoneCOM4;
|
|
|
|
this.SystemConfig2.MarkoprintDateSettingCOM1 = structItem.MarkoprintDateSettingCOM1;
|
|
this.SystemConfig2.MarkoprintDateSettingCOM3 = structItem.MarkoprintDateSettingCOM3;
|
|
this.SystemConfig2.MarkoprintDateSettingCOM4 = structItem.MarkoprintDateSettingCOM4;
|
|
|
|
this.SystemConfig2.IsGroup1UsingRandomMode = structItem.IsGroup1UsingRandomMode;
|
|
this.SystemConfig2.IsGroup2UsingRandomMode = structItem.IsGroup2UsingRandomMode;
|
|
this.SystemConfig2.IsGroup3UsingRandomMode = structItem.IsGroup3UsingRandomMode;
|
|
this.SystemConfig2.IsGroup4UsingRandomMode = structItem.IsGroup4UsingRandomMode;
|
|
this.SystemConfig2.IsGroup5UsingRandomMode = structItem.IsGroup5UsingRandomMode;
|
|
|
|
this.SystemConfig2.Barcode = structItem.Barcode;
|
|
this.SystemConfig2.FileNameExtension = structItem.FileNameExtension;
|
|
|
|
this.SystemConfig2.EthernetPort = structItem.EthernetPort;
|
|
this.SystemConfig2.EthernetCommMode = structItem.EthernetCommMode;
|
|
this.SystemConfig2.EthernetOperationMode = structItem.EthernetOperationMode;
|
|
this.SystemConfig2.EthernetLocalPort = structItem.EthernetLocalPort;
|
|
|
|
this.SystemConfig2.IsBypassOnce = structItem.IsBypassOnce;
|
|
this.SystemConfig2.IsBypassDirectionPass = structItem.IsBypassDirectionPass;
|
|
this.SystemConfig2.IsCommunicationOption = structItem.IsCommunicationOption;
|
|
|
|
this.SystemConfig2.ModbusRTUSelectFunction = structItem.ModbusRTUSelectFunction;
|
|
this.SystemConfig2.ModbusRTUSlaveIDCOM1 = structItem.ModbusRTUSlaveIDCOM1;
|
|
this.SystemConfig2.ModbusRTUSlaveIDCOM3 = structItem.ModbusRTUSlaveIDCOM3;
|
|
this.SystemConfig2.ModbusRTUSlaveIDCOM4 = structItem.ModbusRTUSlaveIDCOM4;
|
|
|
|
this.SystemConfig2.ConveyorLength = structItem.ConveyorLength;
|
|
this.SystemConfig2.SortingPointLength = structItem.SortingPointLength;
|
|
|
|
value = structItem.EthernetAddress;
|
|
if (value == "")
|
|
value = this.SystemConfig2.EthernetAddress;
|
|
this.SystemConfig2.EthernetAddress = value;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region BLDCMotorParameter
|
|
private void CreateBLDCMotorParameter()
|
|
{
|
|
StructBLDCMotorParameter1 structItem1;
|
|
StructBLDCMotorParameter2 structItem2;
|
|
|
|
this.BLDCParameter.Initialization();
|
|
|
|
structItem1.CommBaudrate = this.BLDCParameter.CommBaudrate;
|
|
structItem1.CommParityBit = this.BLDCParameter.CommParityBit;
|
|
structItem1.PWMDelay = this.BLDCParameter.PWMDelay;
|
|
structItem1.FeedbackDeviation = this.BLDCParameter.FeedbackDeviation;
|
|
structItem1.MotorSpeed = this.BLDCParameter.MotorSpeed;
|
|
structItem1.PoleNum = this.BLDCParameter.PoleNum;
|
|
structItem1.AttenuatorRatio = this.BLDCParameter.AttenuatorRatio;
|
|
|
|
structItem1.DummyInt1 = 0;
|
|
structItem1.DummyInt2 = 0;
|
|
structItem1.DummyInt3 = 0;
|
|
structItem1.DummyInt4 = 0;
|
|
structItem1.DummyInt5 = 0;
|
|
structItem1.DummyInt6 = 0;
|
|
structItem1.DummyInt7 = 0;
|
|
structItem1.DummyInt8 = 0;
|
|
structItem1.DummyInt9 = 0;
|
|
structItem1.DummyInt10 = 0;
|
|
structItem1.DummyInt11 = 0;
|
|
structItem1.DummyInt12 = 0;
|
|
structItem1.DummyInt13 = 0;
|
|
structItem1.DummyInt14 = 0;
|
|
structItem1.DummyInt15 = 0;
|
|
structItem1.DummyInt16 = 0;
|
|
structItem1.DummyInt17 = 0;
|
|
structItem1.DummyInt18 = 0;
|
|
structItem1.DummyInt19 = 0;
|
|
structItem1.DummyInt20 = 0;
|
|
|
|
structItem1.DummyString1 = "0";
|
|
structItem1.DummyString2 = "0";
|
|
structItem1.DummyString3 = "0";
|
|
structItem1.DummyString4 = "0";
|
|
structItem1.DummyString5 = "0";
|
|
structItem1.DummyString6 = "0";
|
|
structItem1.DummyString7 = "0";
|
|
structItem1.DummyString8 = "0";
|
|
structItem1.DummyString9 = "0";
|
|
structItem1.DummyString10 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem1, 0);
|
|
|
|
structItem2.BootingStart = this.BLDCParameter.BootingStart;
|
|
structItem2.PortUse = this.BLDCParameter.PortUse;
|
|
structItem2.Feedback = this.BLDCParameter.Feedback;
|
|
structItem2.InitDirection = this.BLDCParameter.InitDirection;
|
|
structItem2.OperDirection = this.BLDCParameter.OperDirection;
|
|
|
|
structItem2.DummyInt1 = 0;
|
|
structItem2.DummyInt2 = 0;
|
|
structItem2.DummyInt3 = 0;
|
|
structItem2.DummyInt4 = 0;
|
|
structItem2.DummyInt5 = 0;
|
|
structItem2.DummyInt6 = 0;
|
|
structItem2.DummyInt7 = 0;
|
|
structItem2.DummyInt8 = 0;
|
|
structItem2.DummyInt9 = 0;
|
|
structItem2.DummyInt10 = 0;
|
|
structItem2.DummyInt11 = 0;
|
|
structItem2.DummyInt12 = 0;
|
|
structItem2.DummyInt13 = 0;
|
|
structItem2.DummyInt14 = 0;
|
|
structItem2.DummyInt15 = 0;
|
|
structItem2.DummyInt16 = 0;
|
|
structItem2.DummyInt17 = 0;
|
|
structItem2.DummyInt18 = 0;
|
|
structItem2.DummyInt19 = 0;
|
|
structItem2.DummyInt20 = 0;
|
|
|
|
structItem2.DummyString1 = "0";
|
|
structItem2.DummyString2 = "0";
|
|
structItem2.DummyString3 = "0";
|
|
structItem2.DummyString4 = "0";
|
|
structItem2.DummyString5 = "0";
|
|
structItem2.DummyString6 = "0";
|
|
structItem2.DummyString7 = "0";
|
|
structItem2.DummyString8 = "0";
|
|
structItem2.DummyString9 = "0";
|
|
structItem2.DummyString10 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem2, 1);
|
|
}
|
|
public void SaveBLDCMotorFile(BLDCMotorParameter item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructBLDCMotorParameter1 structItem1;
|
|
StructBLDCMotorParameter2 structItem2;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "BLDCMotorItem.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateBLDCMotorParameter();
|
|
}
|
|
|
|
structItem1.CommBaudrate = item.CommBaudrate;
|
|
structItem1.CommParityBit = item.CommParityBit;
|
|
structItem1.PWMDelay = item.PWMDelay;
|
|
structItem1.FeedbackDeviation = item.FeedbackDeviation;
|
|
structItem1.MotorSpeed = item.MotorSpeed;
|
|
structItem1.PoleNum = item.PoleNum;
|
|
structItem1.AttenuatorRatio = item.AttenuatorRatio;
|
|
|
|
structItem1.DummyInt1 = 0;
|
|
structItem1.DummyInt2 = 0;
|
|
structItem1.DummyInt3 = 0;
|
|
structItem1.DummyInt4 = 0;
|
|
structItem1.DummyInt5 = 0;
|
|
structItem1.DummyInt6 = 0;
|
|
structItem1.DummyInt7 = 0;
|
|
structItem1.DummyInt8 = 0;
|
|
structItem1.DummyInt9 = 0;
|
|
structItem1.DummyInt10 = 0;
|
|
structItem1.DummyInt11 = 0;
|
|
structItem1.DummyInt12 = 0;
|
|
structItem1.DummyInt13 = 0;
|
|
structItem1.DummyInt14 = 0;
|
|
structItem1.DummyInt15 = 0;
|
|
structItem1.DummyInt16 = 0;
|
|
structItem1.DummyInt17 = 0;
|
|
structItem1.DummyInt18 = 0;
|
|
structItem1.DummyInt19 = 0;
|
|
structItem1.DummyInt20 = 0;
|
|
|
|
structItem1.DummyString1 = "0";
|
|
structItem1.DummyString2 = "0";
|
|
structItem1.DummyString3 = "0";
|
|
structItem1.DummyString4 = "0";
|
|
structItem1.DummyString5 = "0";
|
|
structItem1.DummyString6 = "0";
|
|
structItem1.DummyString7 = "0";
|
|
structItem1.DummyString8 = "0";
|
|
structItem1.DummyString9 = "0";
|
|
structItem1.DummyString10 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem1, 0);
|
|
|
|
structItem2.BootingStart = item.BootingStart;
|
|
structItem2.PortUse = item.PortUse;
|
|
structItem2.Feedback = item.Feedback;
|
|
structItem2.InitDirection = item.InitDirection;
|
|
structItem2.OperDirection = item.OperDirection;
|
|
|
|
structItem2.DummyInt1 = 0;
|
|
structItem2.DummyInt2 = 0;
|
|
structItem2.DummyInt3 = 0;
|
|
structItem2.DummyInt4 = 0;
|
|
structItem2.DummyInt5 = 0;
|
|
structItem2.DummyInt6 = 0;
|
|
structItem2.DummyInt7 = 0;
|
|
structItem2.DummyInt8 = 0;
|
|
structItem2.DummyInt9 = 0;
|
|
structItem2.DummyInt10 = 0;
|
|
structItem2.DummyInt11 = 0;
|
|
structItem2.DummyInt12 = 0;
|
|
structItem2.DummyInt13 = 0;
|
|
structItem2.DummyInt14 = 0;
|
|
structItem2.DummyInt15 = 0;
|
|
structItem2.DummyInt16 = 0;
|
|
structItem2.DummyInt17 = 0;
|
|
structItem2.DummyInt18 = 0;
|
|
structItem2.DummyInt19 = 0;
|
|
structItem2.DummyInt20 = 0;
|
|
|
|
structItem2.DummyString1 = "0";
|
|
structItem2.DummyString2 = "0";
|
|
structItem2.DummyString3 = "0";
|
|
structItem2.DummyString4 = "0";
|
|
structItem2.DummyString5 = "0";
|
|
structItem2.DummyString6 = "0";
|
|
structItem2.DummyString7 = "0";
|
|
structItem2.DummyString8 = "0";
|
|
structItem2.DummyString9 = "0";
|
|
structItem2.DummyString10 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem2, 1);
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadBLDCMotorFile()
|
|
{
|
|
string fullFilePath = "", value = "";
|
|
bool fileCheck = false;
|
|
StructBLDCMotorParameter1 structItem1;
|
|
StructBLDCMotorParameter2 structItem2;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "BLDCMotorItem.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateBLDCMotorParameter();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem1 = (StructBLDCMotorParameter1)this.smartFileIO.ReadStructure(0, typeof(StructBLDCMotorParameter1));
|
|
|
|
this.BLDCParameter.CommBaudrate = structItem1.CommBaudrate;
|
|
this.BLDCParameter.CommParityBit = structItem1.CommParityBit;
|
|
this.BLDCParameter.PWMDelay = structItem1.PWMDelay;
|
|
this.BLDCParameter.FeedbackDeviation = structItem1.FeedbackDeviation;
|
|
this.BLDCParameter.MotorSpeed = structItem1.MotorSpeed;
|
|
this.BLDCParameter.PoleNum = structItem1.PoleNum;
|
|
this.BLDCParameter.AttenuatorRatio = structItem1.AttenuatorRatio;
|
|
|
|
structItem2 = (StructBLDCMotorParameter2)this.smartFileIO.ReadStructure(1, typeof(StructBLDCMotorParameter2));
|
|
|
|
this.BLDCParameter.BootingStart = structItem2.BootingStart;
|
|
this.BLDCParameter.PortUse = structItem2.PortUse;
|
|
this.BLDCParameter.Feedback = structItem2.Feedback;
|
|
this.BLDCParameter.InitDirection = structItem2.InitDirection;
|
|
this.BLDCParameter.OperDirection = structItem2.OperDirection;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region TransferParameter
|
|
public void TransferParameter1()
|
|
{
|
|
string value = "";
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
SystemParameter1 sItem = new SystemParameter1();
|
|
|
|
this.LoadSystemParameter1File(ref sItem);
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.BuzzerOnTime.ToString())); // 부저ON시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.RelayOnTime.ToString())); // 릴레이동작시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.SorterDoubleEntry.ToString())); // 이중진입(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.Chattering.ToString())); // 채터링감지4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.SorterExternalNgInput.ToString())); // 외부NG입력(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.SorterEtcNg.ToString())); // 기타NG사용유무(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.StopWeighing.ToString())); // 정지계량(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OptionBoard.ToString())); // 옵션보드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.InitialDrive.ToString())); // 초기운전(4)
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.PI2.ToString())); // PI2
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.PI3.ToString())); // PI3
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.PI4.ToString())); // PI4
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.PI5.ToString())); // PI5
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.PI6.ToString())); // PI6
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.PI7.ToString())); // PI7
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.PI8.ToString())); // PI8
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.EquipmentType.ToString())); // 장비타입
|
|
|
|
sb.Append("0000"); // Dummy1(4)
|
|
sb.Append("0000"); // Dummy2(4)
|
|
sb.Append("0000"); // Dummy3(4)
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite1, sb.ToString());
|
|
}
|
|
public void TransferParameter2()
|
|
{
|
|
string value = "";
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
SystemParameter2 sItem = new SystemParameter2();
|
|
|
|
this.LoadSystemParameter2File(ref sItem);
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1SamplingCount.ToString())); // OPT1_샘플링개수(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1DelayCount.ToString())); // OPT1_지연개수(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1PulseWidth.ToString())); // OPT1_펄스폭(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1IsWeightSetting.ToString())); // OPT1_범위설정사용여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits7(sItem.OPT1OverRange.ToString())); // OPT1_상한범위(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(sItem.OPT1UnderRange.ToString())); // OPT1_하한범위(7)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1Port.ToString())); // OPT1_포트(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2Port.ToString())); // OPT2_포트(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2DelayTime1.ToString())); // OPT2_지연시간1(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2DelayTime2.ToString())); // OPT2_지연시간2(4)
|
|
sb.Append("0000000"); // Dummy1(7)
|
|
sb.Append("0000000"); // Dummy2(7)
|
|
sb.Append("0000"); // Dummy3(4)
|
|
sb.Append("0000"); // Dummy4(4)
|
|
sb.Append("0000"); // Dummy5(4)
|
|
sb.Append("0000"); // Dummy6(4)
|
|
sb.Append("0000"); // Dummy7(4)
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite2, sb.ToString());
|
|
}
|
|
public void TransferParameter3()
|
|
{
|
|
string value = "";
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
SystemParameter3 sItem = new SystemParameter3();
|
|
|
|
this.LoadSystemParameter3File(ref sItem);
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut1Mode.ToString())); // 외부출력1모드4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut1DelayTime.ToString())); // 외부출력1지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut1RunTime.ToString())); // 외부출력1동작(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut2Mode.ToString())); // 외부출력2모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut2DelayTime.ToString())); // 외부출력2지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut2RunTime.ToString())); // 외부출력2동작(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut3Mode.ToString())); // 외부출력3모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut3DelayTime.ToString())); // 외부출력3지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut3RunTime.ToString())); // 외부출력3동작(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut4Mode.ToString())); // 외부출력4모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut4DelayTime.ToString())); // 외부출력4지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut4RunTime.ToString())); // 외부출력4동작(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut5Mode.ToString())); // 외부출력9모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut5DelayTime.ToString())); // 외부출력9지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut5RunTime.ToString())); // 외부출력9동작(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut6Mode.ToString())); // 외부출력10모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut6DelayTime.ToString())); // 외부출력10지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut6RunTime.ToString())); // 외부출력10동작(4)
|
|
sb.Append("0000"); // Dummy1(4)
|
|
sb.Append("0000"); // Dummy2(4)
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite3, sb.ToString());
|
|
}
|
|
public void TransferParameter4()
|
|
{
|
|
string value = "";
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
SystemParameter4 sItem = new SystemParameter4();
|
|
|
|
this.LoadSystemParameter4File(ref sItem);
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero1Time)); // 자동영점1시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero1Range)); // 자동영점1범위(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero1Variate)); // 자동영점1변량(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero1Mode)); // 자동영점1모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Mode)); // 자동영점2모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Time)); // 자동영점2시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Range)); // 자동영점2범위(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Variate)); // 자동영점2변량(4)
|
|
sb.Append("0000"); // Dummy1(4)
|
|
sb.Append("0000"); // Dummy2(4)
|
|
sb.Append("0000"); // Dummy3(4)
|
|
sb.Append("0000"); // Dummy4(4)
|
|
sb.Append("0000"); // Dummy5(4)
|
|
sb.Append("0000"); // Dummy6(4)
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite4, sb.ToString());
|
|
}
|
|
public void TransferRandomMode()
|
|
{
|
|
string value = "";
|
|
|
|
ProductItem pItem = new ProductItem();
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
pItem = this.CollectionProductItem[995];
|
|
sb.Append("0996"); // 품번(4)
|
|
sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup1UsingRandomMode)).ToString())); // 사용여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange)); // 하한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange)); // 상한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange)); // 용기(7)
|
|
|
|
pItem = this.CollectionProductItem[996];
|
|
sb.Append("0997"); // 품번(4)
|
|
sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup2UsingRandomMode)).ToString())); // 사용여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange)); // 하한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange)); // 상한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange)); // 용기(7)
|
|
|
|
pItem = this.CollectionProductItem[997];
|
|
sb.Append("0998"); // 품번(4)
|
|
sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup3UsingRandomMode)).ToString())); // 사용여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange)); // 하한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange)); // 상한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange)); // 용기(7)
|
|
|
|
pItem = this.CollectionProductItem[998];
|
|
sb.Append("0999"); // 품번(4)
|
|
sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup4UsingRandomMode)).ToString())); // 사용여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange)); // 하한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange)); // 상한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange)); // 용기(7)
|
|
|
|
pItem = this.CollectionProductItem[999];
|
|
sb.Append("1000"); // 품번(4)
|
|
sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup5UsingRandomMode)).ToString())); // 사용여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange)); // 하한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange)); // 상한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange)); // 용기(7)
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.RandomModeWrite, sb.ToString());
|
|
}
|
|
public void TransferProductParameter(int productNumber)
|
|
{
|
|
string value = "";
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
ProductItem pItem = new ProductItem();
|
|
JudgmentSetItem jItem = new JudgmentSetItem();
|
|
|
|
pItem = this.CollectionProductItem[productNumber - 1];
|
|
jItem = this.CollectionJudgmentItem[productNumber - 1];
|
|
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange)); // 하한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.PassRange)); // 기준값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange)); // 상한값(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange)); // 용기(7)
|
|
value = Helper.DoubleToString(jItem.DynamicCorrection, 6);
|
|
value = value.Replace(".", "");
|
|
sb.Append(Helper.StringZeroFillDigits7(value)); // 동보정(7)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.Filter.ToString())); // 필터(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentDelayTime.ToString())); // 판정지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.DoubleDelayTime.ToString())); // 이중지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentCount.ToString())); // 판정개수(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.AscendDelayTime.ToString())); // 상승지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.DescendDelayTime.ToString())); // 하강지연(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.FeedSpeed1.ToString())); // 인버터1속도(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.FeedSpeed2.ToString())); // 인버터2속도(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.FeedSpeed3.ToString())); // 인버터3속도(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.ProductLength.ToString())); // 자동판정-길이(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.AutoJudgment1.ToString())); // 자동판정-1(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.AutoJudgment2.ToString())); // 자동판정-2(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.AutoJudgment3.ToString())); // 자동판정-3(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1Mode.ToString())); // 선별기1모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString())); // 선별기1지연시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1RunTime.ToString())); // 선별기1동작시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2Mode.ToString())); // 선별기2모드(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2DelayTime.ToString())); // 선별기2지연시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2RunTime.ToString())); // 선별기2동작시간(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.SystemConfig1.EquipmentID.ToString())); // 장비ID(4)
|
|
sb.Append("0000000"); // Dummy1(7)
|
|
sb.Append("0000000"); // Dummy2(7)
|
|
sb.Append("0000"); // Dummy3(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(jItem.MovingAverage.ToString())); // 이동평균(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.SystemConfig1.DecimalPlaces.ToString())); // 소수점(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(productNumber.ToString())); // 품번
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWriteAll, sb.ToString());
|
|
|
|
string temp = "";
|
|
if (productNumber > 100)
|
|
temp = productNumber.ToString().Substring(productNumber.ToString().Length - 2, 2);
|
|
else
|
|
temp = string.Format("{0:00}", productNumber);
|
|
|
|
// OPT1(액트라 - 안리쯔 금속검출기)
|
|
if (this.SystemConfig1.SerialCOM1Mode == 14)
|
|
this.TransferSerialCOM1(this.Transfer_14_OPT1("200" + temp));
|
|
if (this.SystemConfig1.SerialCOM3Mode == 14)
|
|
this.TransferSerialCOM3(this.Transfer_14_OPT1("200" + temp));
|
|
if (this.SystemConfig1.SerialCOM4Mode == 14)
|
|
this.TransferSerialCOM4(this.Transfer_14_OPT1("200" + temp));
|
|
|
|
// OPT2(NOW - PPI)
|
|
if (this.SystemConfig1.SerialCOM1Mode == 15)
|
|
this.TransferSerialCOM1(this.ResponseFrameOPT2());
|
|
if (this.SystemConfig1.SerialCOM3Mode == 15)
|
|
this.TransferSerialCOM3(this.ResponseFrameOPT2());
|
|
if (this.SystemConfig1.SerialCOM4Mode == 15)
|
|
this.TransferSerialCOM4(this.ResponseFrameOPT2());
|
|
}
|
|
public void TransferCountData(int productNumber)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
WeightData wItem = new WeightData();
|
|
wItem = this.CollectionWeightData[productNumber - 1];
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(productNumber.ToString())); // 품번(4)
|
|
sb.Append(Helper.StringZeroFillDigits7(wItem.ExNGCount.ToString())); // ExNG카운트(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(wItem.OverCount.ToString())); // 상한카운트(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(wItem.PassCount.ToString())); // 기준카운트(7)
|
|
sb.Append(Helper.StringZeroFillDigits7(wItem.UnderCount.ToString())); // 하한카운트(7)
|
|
sb.Append("0000"); // Dummy1(4)
|
|
sb.Append("0000000"); // Dummy1(7)
|
|
sb.Append("0000000"); // Dummy2(7)
|
|
sb.Append("0000000"); // Dummy3(7)
|
|
sb.Append("0000000"); // Dummy4(7)
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ParameterCount, sb.ToString());
|
|
}
|
|
public void TransferBLDCMotorData()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.CommBaudrate)); // 메인보드와의 통신 Baudrate(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.CommParityBit)); // 메인보드와의 통신 Parity bit(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.PWMDelay)); // PWM 변화 속도(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.FeedbackDeviation)); // Feedback 구동을 위한 변화 편차(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.MotorSpeed)); // Motor 속도(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.PoleNum)); // BLDC 모터 Pole 수(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.AttenuatorRatio)); // 감속기 비율(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.BootingStart)); // 부팅 시 자동 구동 여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.PortUse)); // 타 Port 모터 사용 여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.Feedback)); // 모터 구동 중 피드백 제어 여부(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.InitDirection)); // 초기 모터 방향(4)
|
|
sb.Append(Helper.StringZeroFillDigits4(this.BLDCParameter.OperDirection)); // 구동 중 모터 방향(4)
|
|
sb.Append("0000"); // Dummy1(4)
|
|
sb.Append("0000"); // Dummy2(4)
|
|
sb.Append("0000"); // Dummy3(4)
|
|
sb.Append("0000"); // Dummy4(4)
|
|
sb.Append("0000"); // Dummy5(4)
|
|
sb.Append("0000"); // Dummy6(4)
|
|
sb.Append("0000"); // Dummy7(4)
|
|
sb.Append("0000"); // Dummy8(4)
|
|
sb.Append("0000"); // Dummy9(4)
|
|
sb.Append("0000"); // Dummy10(4)
|
|
sb.Append("0000"); // Dummy11(4)
|
|
sb.Append("0000"); // Dummy12(4)
|
|
sb.Append("0000"); // Dummy13(4)
|
|
sb.Append("0000"); // Dummy14(4)
|
|
sb.Append("0000"); // Dummy15(4)
|
|
sb.Append("0000"); // Dummy16(4)
|
|
sb.Append("0000"); // Dummy17(4)
|
|
sb.Append("0000"); // Dummy18(4)
|
|
sb.Append("0000"); // Dummy19(4)
|
|
sb.Append("0000"); // Dummy20(4)
|
|
sb.Append("0000"); // Dummy21(4)
|
|
sb.Append("0000"); // Dummy22(4)
|
|
sb.Append("0000"); // Dummy23(4)
|
|
|
|
this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.BLDCMotorSetting, sb.ToString());
|
|
}
|
|
#endregion
|
|
#region SystemParameter1
|
|
private void CreateSystemParameter1File()
|
|
{
|
|
StructSystemParameter1 structItem;
|
|
|
|
this.CurrentSystemParameter1.Initialization();
|
|
|
|
structItem.BuzzerOnTime = this.CurrentSystemParameter1.BuzzerOnTime;
|
|
structItem.RelayOnTime = this.CurrentSystemParameter1.RelayOnTime;
|
|
structItem.Chattering = this.CurrentSystemParameter1.Chattering;
|
|
structItem.SorterDoubleEntry = this.CurrentSystemParameter1.SorterDoubleEntry;
|
|
structItem.SorterExternalNgInput = this.CurrentSystemParameter1.SorterExternalNgInput;
|
|
structItem.SorterEtcNgInput = this.CurrentSystemParameter1.SorterEtcNg;
|
|
structItem.StopWeighing = this.CurrentSystemParameter1.StopWeighing;
|
|
structItem.InitialDrive = this.CurrentSystemParameter1.InitialDrive;
|
|
structItem.OptionBoard = this.CurrentSystemParameter1.OptionBoard;
|
|
|
|
structItem.PI2 = this.CurrentSystemParameter1.PI2;
|
|
structItem.PI3 = this.CurrentSystemParameter1.PI3;
|
|
structItem.PI4 = this.CurrentSystemParameter1.PI4;
|
|
structItem.PI5 = this.CurrentSystemParameter1.PI5;
|
|
structItem.PI6 = this.CurrentSystemParameter1.PI6;
|
|
structItem.PI7 = this.CurrentSystemParameter1.PI7;
|
|
structItem.PI8 = this.CurrentSystemParameter1.PI8;
|
|
|
|
structItem.EquipmentType = this.CurrentSystemParameter1.EquipmentType;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
structItem.Dummy3 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
}
|
|
public void SaveSystemParameter1File(SystemParameter1 item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter1 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter1.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter1File();
|
|
}
|
|
|
|
structItem.BuzzerOnTime = item.BuzzerOnTime;
|
|
structItem.RelayOnTime = item.RelayOnTime;
|
|
structItem.SorterDoubleEntry = item.SorterDoubleEntry;
|
|
structItem.Chattering = item.Chattering;
|
|
structItem.SorterExternalNgInput = item.SorterExternalNgInput;
|
|
structItem.SorterEtcNgInput = item.SorterEtcNg;
|
|
structItem.StopWeighing = item.StopWeighing;
|
|
structItem.OptionBoard = item.OptionBoard;
|
|
structItem.InitialDrive = item.InitialDrive;
|
|
|
|
structItem.PI2 = item.PI2;
|
|
structItem.PI3 = item.PI3;
|
|
structItem.PI4 = item.PI4;
|
|
structItem.PI5 = item.PI5;
|
|
structItem.PI6 = item.PI6;
|
|
structItem.PI7 = item.PI7;
|
|
structItem.PI8 = item.PI8;
|
|
|
|
structItem.EquipmentType = item.EquipmentType;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
structItem.Dummy3 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadSystemParameter1File(ref SystemParameter1 pItem)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter1 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter1.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter1File();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructSystemParameter1)this.smartFileIO.ReadStructure(0, typeof(StructSystemParameter1));
|
|
|
|
pItem.BuzzerOnTime = structItem.BuzzerOnTime;
|
|
pItem.RelayOnTime = structItem.RelayOnTime;
|
|
pItem.Chattering = structItem.Chattering;
|
|
pItem.SorterDoubleEntry = structItem.SorterDoubleEntry;
|
|
pItem.SorterExternalNgInput = structItem.SorterExternalNgInput;
|
|
pItem.SorterEtcNg = structItem.SorterEtcNgInput;
|
|
pItem.StopWeighing = structItem.StopWeighing;
|
|
pItem.InitialDrive = structItem.InitialDrive;
|
|
pItem.OptionBoard = structItem.OptionBoard;
|
|
|
|
// Version 4 -> Version 5 업데이트 시, 값이 ""라서 오류 발생하여 강제로 값 삽입
|
|
if (structItem.EquipmentType == "")
|
|
structItem.EquipmentType = "0";
|
|
pItem.EquipmentType = structItem.EquipmentType;
|
|
|
|
pItem.PI2 = structItem.PI2;
|
|
pItem.PI3 = structItem.PI3;
|
|
pItem.PI4 = structItem.PI4;
|
|
pItem.PI5 = structItem.PI5;
|
|
pItem.PI6 = structItem.PI6;
|
|
pItem.PI7 = structItem.PI7;
|
|
pItem.PI8 = structItem.PI8;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
#region SystemParameter2
|
|
private void CreateSystemParameter2File()
|
|
{
|
|
StructSystemParameter2 structItem;
|
|
|
|
this.CurrentSystemParameter2.Initialization();
|
|
|
|
structItem.OPT1SamplingCount = this.CurrentSystemParameter2.OPT1SamplingCount;
|
|
structItem.OPT1DelayCount = this.CurrentSystemParameter2.OPT1DelayCount;
|
|
structItem.OPT1PulseWidth = this.CurrentSystemParameter2.OPT1PulseWidth;
|
|
structItem.OPT1IsWeightSetting = this.CurrentSystemParameter2.OPT1IsWeightSetting;
|
|
structItem.OPT1OverRange = this.CurrentSystemParameter2.OPT1OverRange;
|
|
structItem.OPT1UnderRange = this.CurrentSystemParameter2.OPT1UnderRange;
|
|
structItem.OPT1Port = this.CurrentSystemParameter2.OPT1Port;
|
|
|
|
structItem.OPT2Port = this.CurrentSystemParameter2.OPT2Port;
|
|
structItem.OPT2DelayTime1 = this.CurrentSystemParameter2.OPT2DelayTime1;
|
|
structItem.OPT2DelayTime2 = this.CurrentSystemParameter2.OPT2DelayTime2;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
structItem.Dummy3 = "0";
|
|
structItem.Dummy4 = "0";
|
|
structItem.Dummy5 = "0";
|
|
structItem.Dummy6 = "0";
|
|
structItem.Dummy7 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
}
|
|
public void SaveSystemParameter2File(SystemParameter2 item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter2 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter2.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter2File();
|
|
}
|
|
|
|
structItem.OPT1SamplingCount = item.OPT1SamplingCount;
|
|
structItem.OPT1DelayCount = item.OPT1DelayCount;
|
|
structItem.OPT1PulseWidth = item.OPT1PulseWidth;
|
|
structItem.OPT1IsWeightSetting = item.OPT1IsWeightSetting;
|
|
structItem.OPT1OverRange = item.OPT1OverRange;
|
|
structItem.OPT1UnderRange = item.OPT1UnderRange;
|
|
structItem.OPT1Port = item.OPT1Port;
|
|
|
|
structItem.OPT2Port = item.OPT2Port;
|
|
structItem.OPT2DelayTime1 = item.OPT2DelayTime1;
|
|
structItem.OPT2DelayTime2 = item.OPT2DelayTime2;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
structItem.Dummy3 = "0";
|
|
structItem.Dummy4 = "0";
|
|
structItem.Dummy5 = "0";
|
|
structItem.Dummy6 = "0";
|
|
structItem.Dummy7 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadSystemParameter2File(ref SystemParameter2 pItem)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter2 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter2.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter2File();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructSystemParameter2)this.smartFileIO.ReadStructure(0, typeof(StructSystemParameter2));
|
|
|
|
pItem.OPT1SamplingCount = structItem.OPT1SamplingCount;
|
|
pItem.OPT1DelayCount = structItem.OPT1DelayCount;
|
|
pItem.OPT1PulseWidth = structItem.OPT1PulseWidth;
|
|
pItem.OPT1IsWeightSetting = structItem.OPT1IsWeightSetting;
|
|
pItem.OPT1OverRange = structItem.OPT1OverRange;
|
|
pItem.OPT1UnderRange = structItem.OPT1UnderRange;
|
|
pItem.OPT1Port = structItem.OPT1Port;
|
|
|
|
pItem.OPT2Port = structItem.OPT2Port;
|
|
pItem.OPT2DelayTime1 = structItem.OPT2DelayTime1;
|
|
pItem.OPT2DelayTime2 = structItem.OPT2DelayTime2;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
#region SystemParameter3
|
|
private void CreateSystemParameter3File()
|
|
{
|
|
StructSystemParameter3 structItem;
|
|
|
|
this.CurrentSystemParameter3.Initialization();
|
|
|
|
structItem.ExternalOut1Mode = this.CurrentSystemParameter3.ExternalOut1Mode;
|
|
structItem.ExternalOut1DelayTime = this.CurrentSystemParameter3.ExternalOut1DelayTime;
|
|
structItem.ExternalOut1RunTime = this.CurrentSystemParameter3.ExternalOut1RunTime;
|
|
|
|
structItem.ExternalOut2Mode = this.CurrentSystemParameter3.ExternalOut2Mode;
|
|
structItem.ExternalOut2DelayTime = this.CurrentSystemParameter3.ExternalOut2DelayTime;
|
|
structItem.ExternalOut2RunTime = this.CurrentSystemParameter3.ExternalOut2RunTime;
|
|
|
|
structItem.ExternalOut3Mode = this.CurrentSystemParameter3.ExternalOut3Mode;
|
|
structItem.ExternalOut3DelayTime = this.CurrentSystemParameter3.ExternalOut3DelayTime;
|
|
structItem.ExternalOut3RunTime = this.CurrentSystemParameter3.ExternalOut3RunTime;
|
|
|
|
structItem.ExternalOut4Mode = this.CurrentSystemParameter3.ExternalOut4Mode;
|
|
structItem.ExternalOut4DelayTime = this.CurrentSystemParameter3.ExternalOut4DelayTime;
|
|
structItem.ExternalOut4RunTime = this.CurrentSystemParameter3.ExternalOut4RunTime;
|
|
|
|
structItem.ExternalOut5Mode = this.CurrentSystemParameter3.ExternalOut5Mode;
|
|
structItem.ExternalOut5DelayTime = this.CurrentSystemParameter3.ExternalOut5DelayTime;
|
|
structItem.ExternalOut5RunTime = this.CurrentSystemParameter3.ExternalOut5RunTime;
|
|
|
|
structItem.ExternalOut6Mode = this.CurrentSystemParameter3.ExternalOut6Mode;
|
|
structItem.ExternalOut6DelayTime = this.CurrentSystemParameter3.ExternalOut6DelayTime;
|
|
structItem.ExternalOut6RunTime = this.CurrentSystemParameter3.ExternalOut6RunTime;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
}
|
|
public void SaveSystemParameter3File(SystemParameter3 item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter3 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter3.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter3File();
|
|
}
|
|
|
|
structItem.ExternalOut1Mode = item.ExternalOut1Mode;
|
|
structItem.ExternalOut1DelayTime = item.ExternalOut1DelayTime;
|
|
structItem.ExternalOut1RunTime = item.ExternalOut1RunTime;
|
|
|
|
structItem.ExternalOut2Mode = item.ExternalOut2Mode;
|
|
structItem.ExternalOut2DelayTime = item.ExternalOut2DelayTime;
|
|
structItem.ExternalOut2RunTime = item.ExternalOut2RunTime;
|
|
|
|
structItem.ExternalOut3Mode = item.ExternalOut3Mode;
|
|
structItem.ExternalOut3DelayTime = item.ExternalOut3DelayTime;
|
|
structItem.ExternalOut3RunTime = item.ExternalOut3RunTime;
|
|
|
|
structItem.ExternalOut4Mode = item.ExternalOut4Mode;
|
|
structItem.ExternalOut4DelayTime = item.ExternalOut4DelayTime;
|
|
structItem.ExternalOut4RunTime = item.ExternalOut4RunTime;
|
|
|
|
structItem.ExternalOut5Mode = item.ExternalOut5Mode;
|
|
structItem.ExternalOut5DelayTime = item.ExternalOut5DelayTime;
|
|
structItem.ExternalOut5RunTime = item.ExternalOut5RunTime;
|
|
|
|
structItem.ExternalOut6Mode = item.ExternalOut6Mode;
|
|
structItem.ExternalOut6DelayTime = item.ExternalOut6DelayTime;
|
|
structItem.ExternalOut6RunTime = item.ExternalOut6RunTime;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadSystemParameter3File(ref SystemParameter3 pItem)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter3 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter3.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter3File();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructSystemParameter3)this.smartFileIO.ReadStructure(0, typeof(StructSystemParameter3));
|
|
|
|
pItem.ExternalOut1Mode = structItem.ExternalOut1Mode;
|
|
pItem.ExternalOut1DelayTime = structItem.ExternalOut1DelayTime;
|
|
pItem.ExternalOut1RunTime = structItem.ExternalOut1RunTime;
|
|
|
|
pItem.ExternalOut2Mode = structItem.ExternalOut2Mode;
|
|
pItem.ExternalOut2DelayTime = structItem.ExternalOut2DelayTime;
|
|
pItem.ExternalOut2RunTime = structItem.ExternalOut2RunTime;
|
|
|
|
pItem.ExternalOut3Mode = structItem.ExternalOut3Mode;
|
|
pItem.ExternalOut3DelayTime = structItem.ExternalOut3DelayTime;
|
|
pItem.ExternalOut3RunTime = structItem.ExternalOut3RunTime;
|
|
|
|
pItem.ExternalOut4Mode = structItem.ExternalOut4Mode;
|
|
pItem.ExternalOut4DelayTime = structItem.ExternalOut4DelayTime;
|
|
pItem.ExternalOut4RunTime = structItem.ExternalOut4RunTime;
|
|
|
|
pItem.ExternalOut5Mode = structItem.ExternalOut5Mode;
|
|
pItem.ExternalOut5DelayTime = structItem.ExternalOut5DelayTime;
|
|
pItem.ExternalOut5RunTime = structItem.ExternalOut5RunTime;
|
|
|
|
pItem.ExternalOut6Mode = structItem.ExternalOut6Mode;
|
|
pItem.ExternalOut6DelayTime = structItem.ExternalOut6DelayTime;
|
|
pItem.ExternalOut6RunTime = structItem.ExternalOut6RunTime;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
#region SystemParameter4
|
|
private void CreateSystemParameter4File()
|
|
{
|
|
StructSystemParameter4 structItem;
|
|
|
|
this.CurrentSystemParameter4.Initialization();
|
|
|
|
structItem.AutoZero1UserSettingRange = this.CurrentSystemParameter4.LCDAutoZero1Range;
|
|
structItem.AutoZero1UserSettingTime = this.CurrentSystemParameter4.LCDAutoZero1Time;
|
|
structItem.AutoZero1UserSettingVariate = this.CurrentSystemParameter4.LCDAutoZero1Variate;
|
|
structItem.AutoZero1Mode = this.CurrentSystemParameter4.LCDAutoZero1Mode;
|
|
|
|
structItem.AutoZero2UserSettingRange = this.CurrentSystemParameter4.LCDAutoZero2Range;
|
|
structItem.AutoZero2UserSettingTime = this.CurrentSystemParameter4.LCDAutoZero2Time;
|
|
structItem.AutoZero2UserSettingVariate = this.CurrentSystemParameter4.LCDAutoZero2Variate;
|
|
structItem.AutoZero2Mode = this.CurrentSystemParameter4.LCDAutoZero2Mode;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
structItem.Dummy3 = "0";
|
|
structItem.Dummy4 = "0";
|
|
structItem.Dummy5 = "0";
|
|
structItem.Dummy6 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
}
|
|
public void SaveSystemParameter4File(SystemParameter4 item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter4 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter4.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter4File();
|
|
}
|
|
|
|
structItem.AutoZero1UserSettingRange = item.LCDAutoZero1Range;
|
|
structItem.AutoZero1UserSettingTime = item.LCDAutoZero1Time;
|
|
structItem.AutoZero1UserSettingVariate = item.LCDAutoZero1Variate;
|
|
structItem.AutoZero1Mode = item.LCDAutoZero1Mode;
|
|
|
|
structItem.AutoZero2UserSettingRange = item.LCDAutoZero2Range;
|
|
structItem.AutoZero2UserSettingTime = item.LCDAutoZero2Time;
|
|
structItem.AutoZero2UserSettingVariate = item.LCDAutoZero2Variate;
|
|
structItem.AutoZero2Mode = item.LCDAutoZero2Mode;
|
|
|
|
structItem.Dummy1 = "0";
|
|
structItem.Dummy2 = "0";
|
|
structItem.Dummy3 = "0";
|
|
structItem.Dummy4 = "0";
|
|
structItem.Dummy5 = "0";
|
|
structItem.Dummy6 = "0";
|
|
|
|
this.smartFileIO.WriteStructure(structItem, 0);
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadSystemParameter4File(ref SystemParameter4 pItem)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructSystemParameter4 structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter4.cfg";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateSystemParameter4File();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructSystemParameter4)this.smartFileIO.ReadStructure(0, typeof(StructSystemParameter4));
|
|
|
|
pItem.LCDAutoZero1Range = structItem.AutoZero1UserSettingRange;
|
|
pItem.LCDAutoZero1Time = structItem.AutoZero1UserSettingTime;
|
|
pItem.LCDAutoZero1Variate = structItem.AutoZero1UserSettingVariate;
|
|
pItem.LCDAutoZero1Mode = structItem.AutoZero1Mode;
|
|
|
|
pItem.LCDAutoZero2Range = structItem.AutoZero2UserSettingRange;
|
|
pItem.LCDAutoZero2Time = structItem.AutoZero2UserSettingTime;
|
|
pItem.LCDAutoZero2Variate = structItem.AutoZero2UserSettingVariate;
|
|
pItem.LCDAutoZero2Mode = structItem.AutoZero2Mode;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region Product File
|
|
private void CreateProductFile()
|
|
{
|
|
StructProductItem structItem;
|
|
|
|
this.CurrentProductItem.Initialization();
|
|
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
structItem.Number = i + 1;
|
|
structItem.Name = string.Format("Product {0}", i + 1);
|
|
structItem.LotNo = string.Format("Lot {0}", i + 1);
|
|
structItem.PassRange = this.CurrentProductItem.PassRange;
|
|
structItem.OverRange = this.CurrentProductItem.OverRange;
|
|
structItem.UnderRange = this.CurrentProductItem.UnderRange;
|
|
structItem.TareRange = this.CurrentProductItem.TareRange;
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
}
|
|
public void OpenSmartFileIO()
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "ProductItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
}
|
|
public void CloseSmartFileIO()
|
|
{
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void SaveProductFile(ProductItem item, int index)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructProductItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "ProductItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateProductFile();
|
|
}
|
|
|
|
structItem.Number = item.Number;
|
|
structItem.Name = item.Name;
|
|
structItem.LotNo = item.LotNo;
|
|
structItem.OverRange = item.OverRange;
|
|
structItem.PassRange = item.PassRange;
|
|
structItem.UnderRange = item.UnderRange;
|
|
structItem.TareRange = item.TareRange;
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, index);
|
|
this.smartFileIO.WriteStructure_End();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void SaveProductFile(Collection<ProductItem> items)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructProductItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "ProductItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateProductFile();
|
|
}
|
|
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
structItem.Number = items[i].Number;
|
|
structItem.Name = items[i].Name;
|
|
structItem.LotNo = items[i].LotNo;
|
|
structItem.OverRange = items[i].OverRange;
|
|
structItem.PassRange = items[i].PassRange;
|
|
structItem.UnderRange = items[i].UnderRange;
|
|
structItem.TareRange = items[i].TareRange;
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadProductFile(ref ProductItem item, int index)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructProductItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "ProductItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateProductFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructProductItem)this.smartFileIO.ReadStructure(index, typeof(StructProductItem));
|
|
|
|
item.Number = structItem.Number;
|
|
item.Name = structItem.Name;
|
|
item.LotNo = structItem.LotNo;
|
|
item.PassRange = structItem.PassRange;
|
|
item.OverRange = structItem.OverRange;
|
|
item.UnderRange = structItem.UnderRange;
|
|
item.TareRange = structItem.TareRange;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadProductName(ref Collection<string> values)
|
|
{
|
|
string fullFilePath = "";
|
|
StructProductItem structItem;
|
|
|
|
values.Clear();
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "ProductItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
if (this.smartFileIO.ReadStructureAllBuffer() == true)
|
|
{
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
structItem = (StructProductItem)this.smartFileIO.ReadStructureBuffer(typeof(StructProductItem), i);
|
|
|
|
values.Add(structItem.Name);
|
|
}
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
private void LoadProductFile(ref Collection<ProductItem> items)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructProductItem structProduct;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "ProductItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateProductFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
if (this.smartFileIO.ReadStructureAllBuffer() == true)
|
|
{
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
structProduct = (StructProductItem)this.smartFileIO.ReadStructureBuffer(typeof(StructProductItem), i);
|
|
|
|
items[i].Number = structProduct.Number;
|
|
items[i].Name = structProduct.Name;
|
|
items[i].LotNo = structProduct.LotNo;
|
|
items[i].OverRange = structProduct.OverRange;
|
|
items[i].PassRange = structProduct.PassRange;
|
|
items[i].UnderRange = structProduct.UnderRange;
|
|
items[i].TareRange = structProduct.TareRange;
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void ReLoadProductFile()
|
|
{
|
|
this.LoadProductFile(ref this.CollectionProductItem);
|
|
}
|
|
#endregion
|
|
|
|
#region JudgmentSet File
|
|
private void CreateJudgmentSetFile()
|
|
{
|
|
StructJudgmentSetItem structItem;
|
|
|
|
this.CurrentJudgmentSetItem.Initialization();
|
|
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
structItem.Filter = this.CurrentJudgmentSetItem.Filter;
|
|
structItem.JudgmentDelayTime = this.CurrentJudgmentSetItem.JudgmentDelayTime;
|
|
structItem.DoubleDelayTime = this.CurrentJudgmentSetItem.DoubleDelayTime;
|
|
structItem.JudgmentCount = this.CurrentJudgmentSetItem.JudgmentCount;
|
|
structItem.FeedSpeed1 = this.CurrentJudgmentSetItem.FeedSpeed1;
|
|
structItem.FeedSpeed2 = this.CurrentJudgmentSetItem.FeedSpeed2;
|
|
structItem.FeedSpeed3 = this.CurrentJudgmentSetItem.FeedSpeed3;
|
|
structItem.DynamicCorrection = this.CurrentJudgmentSetItem.DynamicCorrection;
|
|
structItem.AscendDelayTime = this.CurrentJudgmentSetItem.AscendDelayTime;
|
|
structItem.DescendDelayTime = this.CurrentJudgmentSetItem.DescendDelayTime;
|
|
|
|
structItem.Sorter1Mode = this.CurrentJudgmentSetItem.Sorter1Mode;
|
|
structItem.Sorter1DelayTime = this.CurrentJudgmentSetItem.Sorter1DelayTime;
|
|
structItem.Sorter1RunTime = this.CurrentJudgmentSetItem.Sorter1RunTime;
|
|
structItem.Sorter2Mode = this.CurrentJudgmentSetItem.Sorter2Mode;
|
|
structItem.Sorter2DelayTime = this.CurrentJudgmentSetItem.Sorter2DelayTime;
|
|
structItem.Sorter2RunTime = this.CurrentJudgmentSetItem.Sorter2RunTime;
|
|
|
|
structItem.ProductLength = this.CurrentJudgmentSetItem.ProductLength;
|
|
structItem.AutoJudgment1 = this.CurrentJudgmentSetItem.AutoJudgment1;
|
|
structItem.AutoJudgment2 = this.CurrentJudgmentSetItem.AutoJudgment2;
|
|
structItem.AutoJudgment3 = this.CurrentJudgmentSetItem.AutoJudgment3;
|
|
|
|
structItem.MovingAverage = this.CurrentJudgmentSetItem.MovingAverage;
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
structItem.DummyString5 = "0";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
}
|
|
public void SaveJudgmentSetFile(JudgmentSetItem item, int index)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructJudgmentSetItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "JudgmentSetItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateJudgmentSetFile();
|
|
}
|
|
|
|
structItem.Filter = item.Filter;
|
|
structItem.JudgmentDelayTime = item.JudgmentDelayTime;
|
|
structItem.DoubleDelayTime = item.DoubleDelayTime;
|
|
structItem.JudgmentCount = item.JudgmentCount;
|
|
structItem.FeedSpeed1 = item.FeedSpeed1;
|
|
structItem.FeedSpeed2 = item.FeedSpeed2;
|
|
structItem.FeedSpeed3 = item.FeedSpeed3;
|
|
structItem.DynamicCorrection = item.DynamicCorrection;
|
|
|
|
structItem.Sorter1Mode = item.Sorter1Mode;
|
|
structItem.Sorter1DelayTime = item.Sorter1DelayTime;
|
|
structItem.Sorter1RunTime = item.Sorter1RunTime;
|
|
structItem.Sorter2Mode = item.Sorter2Mode;
|
|
structItem.Sorter2DelayTime = item.Sorter2DelayTime;
|
|
structItem.Sorter2RunTime = item.Sorter2RunTime;
|
|
|
|
structItem.ProductLength = item.ProductLength;
|
|
structItem.AutoJudgment1 = item.AutoJudgment1;
|
|
structItem.AutoJudgment2 = item.AutoJudgment2;
|
|
structItem.AutoJudgment3 = item.AutoJudgment3;
|
|
|
|
structItem.AscendDelayTime = item.AscendDelayTime;
|
|
structItem.DescendDelayTime = item.DescendDelayTime;
|
|
structItem.MovingAverage = item.MovingAverage;
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
structItem.DummyString5 = "0";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, index);
|
|
this.smartFileIO.WriteStructure_End();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void SaveJudgmentSetFile(Collection<JudgmentSetItem> items)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructJudgmentSetItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "JudgmentSetItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateJudgmentSetFile();
|
|
}
|
|
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
structItem.Filter = items[i].Filter;
|
|
structItem.JudgmentDelayTime = items[i].JudgmentDelayTime;
|
|
structItem.DoubleDelayTime = items[i].DoubleDelayTime;
|
|
structItem.JudgmentCount = items[i].JudgmentCount;
|
|
structItem.FeedSpeed1 = items[i].FeedSpeed1;
|
|
structItem.FeedSpeed2 = items[i].FeedSpeed2;
|
|
structItem.FeedSpeed3 = items[i].FeedSpeed3;
|
|
structItem.DynamicCorrection = items[i].DynamicCorrection;
|
|
|
|
structItem.Sorter1Mode = items[i].Sorter1Mode;
|
|
structItem.Sorter1DelayTime = items[i].Sorter1DelayTime;
|
|
structItem.Sorter1RunTime = items[i].Sorter1RunTime;
|
|
structItem.Sorter2Mode = items[i].Sorter2Mode;
|
|
structItem.Sorter2DelayTime = items[i].Sorter2DelayTime;
|
|
structItem.Sorter2RunTime = items[i].Sorter2RunTime;
|
|
|
|
structItem.ProductLength = items[i].ProductLength;
|
|
structItem.AutoJudgment1 = items[i].AutoJudgment1;
|
|
structItem.AutoJudgment2 = items[i].AutoJudgment2;
|
|
structItem.AutoJudgment3 = items[i].AutoJudgment3;
|
|
|
|
structItem.AscendDelayTime = items[i].AscendDelayTime;
|
|
structItem.DescendDelayTime = items[i].DescendDelayTime;
|
|
structItem.MovingAverage = items[i].MovingAverage;
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
|
|
structItem.DummyString1 = "0";
|
|
structItem.DummyString2 = "0";
|
|
structItem.DummyString3 = "0";
|
|
structItem.DummyString4 = "0";
|
|
structItem.DummyString5 = "0";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadJudgmentSetFile(ref JudgmentSetItem item, int index)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructJudgmentSetItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "JudgmentSetItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateJudgmentSetFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructJudgmentSetItem)this.smartFileIO.ReadStructure(index, typeof(StructJudgmentSetItem));
|
|
|
|
item.Filter = structItem.Filter;
|
|
item.JudgmentDelayTime = structItem.JudgmentDelayTime;
|
|
item.DoubleDelayTime = structItem.DoubleDelayTime;
|
|
item.JudgmentCount = structItem.JudgmentCount;
|
|
item.FeedSpeed1 = structItem.FeedSpeed1;
|
|
item.FeedSpeed2 = structItem.FeedSpeed2;
|
|
item.FeedSpeed3 = structItem.FeedSpeed3;
|
|
item.DynamicCorrection = structItem.DynamicCorrection;
|
|
item.MovingAverage = structItem.MovingAverage;
|
|
|
|
item.Sorter1Mode = structItem.Sorter1Mode;
|
|
item.Sorter1DelayTime = structItem.Sorter1DelayTime;
|
|
item.Sorter1RunTime = structItem.Sorter1RunTime;
|
|
item.Sorter2Mode = structItem.Sorter2Mode;
|
|
item.Sorter2DelayTime = structItem.Sorter2DelayTime;
|
|
item.Sorter2RunTime = structItem.Sorter2RunTime;
|
|
|
|
item.ProductLength = structItem.ProductLength;
|
|
item.AutoJudgment1 = structItem.AutoJudgment1;
|
|
item.AutoJudgment2 = structItem.AutoJudgment2;
|
|
item.AutoJudgment3 = structItem.AutoJudgment3;
|
|
|
|
item.AscendDelayTime = structItem.AscendDelayTime;
|
|
item.DescendDelayTime = structItem.DescendDelayTime;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
private void LoadJudgmentSetFile(ref Collection<JudgmentSetItem> items)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructJudgmentSetItem structJudgment;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "JudgmentSetItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateJudgmentSetFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
if (this.smartFileIO.ReadStructureAllBuffer() == true)
|
|
{
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
structJudgment = (StructJudgmentSetItem)this.smartFileIO.ReadStructureBuffer(typeof(StructJudgmentSetItem), i);
|
|
|
|
items[i].Filter = structJudgment.Filter;
|
|
items[i].JudgmentDelayTime = structJudgment.JudgmentDelayTime;
|
|
items[i].DoubleDelayTime = structJudgment.DoubleDelayTime;
|
|
items[i].JudgmentCount = structJudgment.JudgmentCount;
|
|
items[i].FeedSpeed1 = structJudgment.FeedSpeed1;
|
|
items[i].FeedSpeed2 = structJudgment.FeedSpeed2;
|
|
items[i].FeedSpeed3 = structJudgment.FeedSpeed3;
|
|
items[i].DynamicCorrection = structJudgment.DynamicCorrection;
|
|
|
|
items[i].Sorter1Mode = structJudgment.Sorter1Mode;
|
|
items[i].Sorter1DelayTime = structJudgment.Sorter1DelayTime;
|
|
items[i].Sorter1RunTime = structJudgment.Sorter1RunTime;
|
|
items[i].Sorter2Mode = structJudgment.Sorter2Mode;
|
|
items[i].Sorter2DelayTime = structJudgment.Sorter2DelayTime;
|
|
items[i].Sorter2RunTime = structJudgment.Sorter2RunTime;
|
|
|
|
items[i].ProductLength = structJudgment.ProductLength;
|
|
items[i].AutoJudgment1 = structJudgment.AutoJudgment1;
|
|
items[i].AutoJudgment2 = structJudgment.AutoJudgment2;
|
|
items[i].AutoJudgment3 = structJudgment.AutoJudgment3;
|
|
|
|
items[i].AscendDelayTime = structJudgment.AscendDelayTime;
|
|
items[i].DescendDelayTime = structJudgment.DescendDelayTime;
|
|
items[i].MovingAverage = structJudgment.MovingAverage;
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void ReLoadJudgmentSetFile()
|
|
{
|
|
this.LoadJudgmentSetFile(ref this.CollectionJudgmentItem);
|
|
}
|
|
#endregion
|
|
|
|
#region Counter File
|
|
private void CreateCounterFile()
|
|
{
|
|
StructCounterItem structItem;
|
|
WeightData item = new WeightData();
|
|
item.ClearCount();
|
|
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
structItem.OverCount = item.OverCount;
|
|
structItem.OverSumWeight = item.OverSumWeight;
|
|
structItem.PassCount = item.PassCount;
|
|
structItem.PassSumWeight = item.PassSumWeight;
|
|
structItem.UnderCount = item.UnderCount;
|
|
structItem.UnderSumWeight = item.UnderSumWeight;
|
|
structItem.ExNGCount = item.ExNGCount;
|
|
|
|
structItem.NormalDistribution1 = item.CollectionNormalDistributionCount[0];
|
|
structItem.NormalDistribution2 = item.CollectionNormalDistributionCount[1];
|
|
structItem.NormalDistribution3 = item.CollectionNormalDistributionCount[2];
|
|
structItem.NormalDistribution4 = item.CollectionNormalDistributionCount[3];
|
|
structItem.NormalDistribution5 = item.CollectionNormalDistributionCount[4];
|
|
structItem.NormalDistribution6 = item.CollectionNormalDistributionCount[5];
|
|
structItem.NormalDistribution7 = item.CollectionNormalDistributionCount[6];
|
|
structItem.NormalDistribution8 = item.CollectionNormalDistributionCount[7];
|
|
structItem.NormalDistribution9 = item.CollectionNormalDistributionCount[8];
|
|
structItem.NormalDistribution10 = item.CollectionNormalDistributionCount[9];
|
|
|
|
structItem.StartTime = item.StartTime;
|
|
structItem.StopTime = item.StopTime;
|
|
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
structItem.DummyInt3 = 0;
|
|
structItem.DummyInt4 = 0;
|
|
structItem.DummyInt5 = 0;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
}
|
|
public void SaveCounterFile(WeightData item, int index)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructCounterItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateCounterFile();
|
|
}
|
|
|
|
structItem.OverCount = item.OverCount;
|
|
structItem.OverSumWeight = item.OverSumWeight;
|
|
structItem.PassCount = item.PassCount;
|
|
structItem.PassSumWeight = item.PassSumWeight;
|
|
structItem.UnderCount = item.UnderCount;
|
|
structItem.UnderSumWeight = item.UnderSumWeight;
|
|
structItem.ExNGCount = item.ExNGCount;
|
|
|
|
structItem.NormalDistribution1 = item.CollectionNormalDistributionCount[0];
|
|
structItem.NormalDistribution2 = item.CollectionNormalDistributionCount[1];
|
|
structItem.NormalDistribution3 = item.CollectionNormalDistributionCount[2];
|
|
structItem.NormalDistribution4 = item.CollectionNormalDistributionCount[3];
|
|
structItem.NormalDistribution5 = item.CollectionNormalDistributionCount[4];
|
|
structItem.NormalDistribution6 = item.CollectionNormalDistributionCount[5];
|
|
structItem.NormalDistribution7 = item.CollectionNormalDistributionCount[6];
|
|
structItem.NormalDistribution8 = item.CollectionNormalDistributionCount[7];
|
|
structItem.NormalDistribution9 = item.CollectionNormalDistributionCount[8];
|
|
structItem.NormalDistribution10 = item.CollectionNormalDistributionCount[9];
|
|
|
|
structItem.StartTime = item.StartTime;
|
|
structItem.StopTime = item.StopTime;
|
|
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
structItem.DummyInt3 = 0;
|
|
structItem.DummyInt4 = 0;
|
|
structItem.DummyInt5 = 0;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, index);
|
|
this.smartFileIO.WriteStructure_End();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void SaveCounterFile(Collection<WeightData> items)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructCounterItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateCounterFile();
|
|
}
|
|
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
structItem.OverCount = items[i].OverCount;
|
|
structItem.OverSumWeight = items[i].OverSumWeight;
|
|
structItem.PassCount = items[i].PassCount;
|
|
structItem.PassSumWeight = items[i].PassSumWeight;
|
|
structItem.UnderCount = items[i].UnderCount;
|
|
structItem.UnderSumWeight = items[i].UnderSumWeight;
|
|
structItem.ExNGCount = items[i].ExNGCount;
|
|
|
|
structItem.NormalDistribution1 = items[i].CollectionNormalDistributionCount[0];
|
|
structItem.NormalDistribution2 = items[i].CollectionNormalDistributionCount[1];
|
|
structItem.NormalDistribution3 = items[i].CollectionNormalDistributionCount[2];
|
|
structItem.NormalDistribution4 = items[i].CollectionNormalDistributionCount[3];
|
|
structItem.NormalDistribution5 = items[i].CollectionNormalDistributionCount[4];
|
|
structItem.NormalDistribution6 = items[i].CollectionNormalDistributionCount[5];
|
|
structItem.NormalDistribution7 = items[i].CollectionNormalDistributionCount[6];
|
|
structItem.NormalDistribution8 = items[i].CollectionNormalDistributionCount[7];
|
|
structItem.NormalDistribution9 = items[i].CollectionNormalDistributionCount[8];
|
|
structItem.NormalDistribution10 = items[i].CollectionNormalDistributionCount[9];
|
|
|
|
structItem.StartTime = items[i].StartTime;
|
|
structItem.StopTime = items[i].StopTime;
|
|
|
|
structItem.DummyInt1 = 0;
|
|
structItem.DummyInt2 = 0;
|
|
structItem.DummyInt3 = 0;
|
|
structItem.DummyInt4 = 0;
|
|
structItem.DummyInt5 = 0;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadCounterFile(ref WeightData item, int index)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructCounterItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateCounterFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
structItem = (StructCounterItem)this.smartFileIO.ReadStructure(index, typeof(StructCounterItem));
|
|
|
|
item.UnderCount = structItem.UnderCount;
|
|
item.UnderSumWeight = structItem.UnderSumWeight;
|
|
item.PassCount = structItem.PassCount;
|
|
item.PassSumWeight = structItem.PassSumWeight;
|
|
item.OverCount = structItem.OverCount;
|
|
item.OverSumWeight = structItem.OverSumWeight;
|
|
item.ExNGCount = structItem.ExNGCount;
|
|
|
|
item.CollectionNormalDistributionCount[0] = structItem.NormalDistribution1;
|
|
item.CollectionNormalDistributionCount[1] = structItem.NormalDistribution2;
|
|
item.CollectionNormalDistributionCount[2] = structItem.NormalDistribution3;
|
|
item.CollectionNormalDistributionCount[3] = structItem.NormalDistribution4;
|
|
item.CollectionNormalDistributionCount[4] = structItem.NormalDistribution5;
|
|
item.CollectionNormalDistributionCount[5] = structItem.NormalDistribution6;
|
|
item.CollectionNormalDistributionCount[6] = structItem.NormalDistribution7;
|
|
item.CollectionNormalDistributionCount[7] = structItem.NormalDistribution8;
|
|
item.CollectionNormalDistributionCount[8] = structItem.NormalDistribution9;
|
|
item.CollectionNormalDistributionCount[9] = structItem.NormalDistribution10;
|
|
|
|
item.StartTime = structItem.StartTime;
|
|
item.StopTime = structItem.StopTime;
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
private void LoadCounterFile(ref Collection<WeightData> items)
|
|
{
|
|
bool fileCheck = false;
|
|
string fullFilePath = "";
|
|
StructCounterItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
this.CreateCounterFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
if (this.smartFileIO.ReadStructureAllBuffer() == true)
|
|
{
|
|
for (int i = 0; i < this.ProductCount; i++)
|
|
{
|
|
structItem = (StructCounterItem)this.smartFileIO.ReadStructureBuffer(typeof(StructCounterItem), i);
|
|
|
|
items[i].UnderCount = structItem.UnderCount;
|
|
items[i].UnderSumWeight = structItem.UnderSumWeight;
|
|
items[i].PassCount = structItem.PassCount;
|
|
items[i].PassSumWeight = structItem.PassSumWeight;
|
|
items[i].OverCount = structItem.OverCount;
|
|
items[i].OverSumWeight = structItem.OverSumWeight;
|
|
items[i].ExNGCount = structItem.ExNGCount;
|
|
|
|
items[i].CollectionNormalDistributionCount[0] = structItem.NormalDistribution1;
|
|
items[i].CollectionNormalDistributionCount[1] = structItem.NormalDistribution2;
|
|
items[i].CollectionNormalDistributionCount[2] = structItem.NormalDistribution3;
|
|
items[i].CollectionNormalDistributionCount[3] = structItem.NormalDistribution4;
|
|
items[i].CollectionNormalDistributionCount[4] = structItem.NormalDistribution5;
|
|
items[i].CollectionNormalDistributionCount[5] = structItem.NormalDistribution6;
|
|
items[i].CollectionNormalDistributionCount[6] = structItem.NormalDistribution7;
|
|
items[i].CollectionNormalDistributionCount[7] = structItem.NormalDistribution8;
|
|
items[i].CollectionNormalDistributionCount[8] = structItem.NormalDistribution9;
|
|
items[i].CollectionNormalDistributionCount[9] = structItem.NormalDistribution10;
|
|
|
|
items[i].StartTime = structItem.StartTime;
|
|
items[i].StopTime = structItem.StopTime;
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void ReLoadCounterFile()
|
|
{
|
|
this.LoadCounterFile(ref this.CollectionWeightData);
|
|
}
|
|
#endregion
|
|
|
|
#region UserGroupPassword File
|
|
private void CreateUserGroupPasswordFile()
|
|
{
|
|
this.CurrentSystemStatus.CurrentUserPasswordType.Initialization();
|
|
|
|
this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level1Password, (int)DataStore.EnumFileUserPassword.f0_Level1);
|
|
this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level2Password, (int)DataStore.EnumFileUserPassword.f1_Level2);
|
|
this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level3Password, (int)DataStore.EnumFileUserPassword.f2_Level3);
|
|
}
|
|
public void SaveUserGroupPasswordFile(UserPasswordType item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroupPassword.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserGroupPasswordFile();
|
|
}
|
|
|
|
this.smartFileIO.WriteString(item.Level1Password, (int)DataStore.EnumFileUserPassword.f0_Level1);
|
|
this.smartFileIO.WriteString(item.Level2Password, (int)DataStore.EnumFileUserPassword.f1_Level2);
|
|
this.smartFileIO.WriteString(item.Level3Password, (int)DataStore.EnumFileUserPassword.f2_Level3);
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
private void LoadUserGroupPasswordFile()
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroupPassword.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserGroupPasswordFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
this.CurrentSystemStatus.CurrentUserPasswordType.Level1Password = this.smartFileIO.ReadString((int)DataStore.EnumFileUserPassword.f0_Level1);
|
|
this.CurrentSystemStatus.CurrentUserPasswordType.Level2Password = this.smartFileIO.ReadString((int)DataStore.EnumFileUserPassword.f1_Level2);
|
|
this.CurrentSystemStatus.CurrentUserPasswordType.Level3Password = this.smartFileIO.ReadString((int)DataStore.EnumFileUserPassword.f2_Level3);
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region UserGroupFile
|
|
private void CreateUserGroupFile()
|
|
{
|
|
StructUserGroupItem structItem;
|
|
UserGroupItem item = new UserGroupItem();
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
#region StructItem
|
|
structItem.IsBasic = item.IsBasic;
|
|
structItem.IsBasicDataBackup = item.IsBasicDataBackup;
|
|
structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
|
|
structItem.IsBasicProduct = item.IsBasicProduct;
|
|
structItem.IsBasicTime = item.IsBasicTime;
|
|
|
|
structItem.IsConfiCommunication = item.IsConfiCommunication;
|
|
structItem.IsConfiguration = item.IsConfiguration;
|
|
structItem.IsConfiOption = item.IsConfiOption;
|
|
|
|
structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
|
|
structItem.IsEquipInitialize = item.IsEquipInitialize;
|
|
structItem.IsEquipment = item.IsEquipment;
|
|
structItem.IsEquipUpdate = item.IsEquipUpdate;
|
|
structItem.IsEquipUser = item.IsEquipUser;
|
|
|
|
structItem.IsInforAS = item.IsInforAS;
|
|
structItem.IsInformation = item.IsInformation;
|
|
structItem.IsInforSystem = item.IsInforSystem;
|
|
|
|
structItem.IsSystem = item.IsSystem;
|
|
structItem.IsSystemAutoZero = item.IsSystemAutoZero;
|
|
structItem.IsSystemCalibration = item.IsSystemCalibration;
|
|
structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
|
|
structItem.IsSystemIOTest = item.IsSystemIOTest;
|
|
structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
|
|
structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;
|
|
|
|
structItem.Dummy1 = false;
|
|
structItem.Dummy2 = false;
|
|
structItem.Dummy3 = false;
|
|
structItem.Dummy4 = false;
|
|
structItem.Dummy5 = false;
|
|
structItem.Dummy6 = false;
|
|
structItem.Dummy7 = false;
|
|
structItem.Dummy8 = false;
|
|
structItem.Dummy9 = false;
|
|
structItem.Dummy10 = false;
|
|
structItem.Dummy11 = false;
|
|
structItem.Dummy12 = false;
|
|
structItem.Dummy13 = false;
|
|
structItem.Dummy14 = false;
|
|
structItem.Dummy15 = false;
|
|
structItem.Dummy16 = false;
|
|
structItem.Dummy17 = false;
|
|
structItem.Dummy18 = false;
|
|
structItem.Dummy19 = false;
|
|
structItem.Dummy20 = false;
|
|
#endregion
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
}
|
|
public void SaveUserGroupFile(UserGroup item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserGroupItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroup.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserGroupFile();
|
|
}
|
|
|
|
#region Level1
|
|
structItem.IsBasic = item.Level1.IsBasic;
|
|
structItem.IsBasicDataBackup = item.Level1.IsBasicDataBackup;
|
|
structItem.IsBasicDataStatistics = item.Level1.IsBasicDataStatistics;
|
|
structItem.IsBasicProduct = item.Level1.IsBasicProduct;
|
|
structItem.IsBasicTime = item.Level1.IsBasicTime;
|
|
|
|
structItem.IsConfiCommunication = item.Level1.IsConfiCommunication;
|
|
structItem.IsConfiguration = item.Level1.IsConfiguration;
|
|
structItem.IsConfiOption = item.Level1.IsConfiOption;
|
|
|
|
structItem.IsEquipFunctionSetting = item.Level1.IsEquipFunctionSetting;
|
|
structItem.IsEquipInitialize = item.Level1.IsEquipInitialize;
|
|
structItem.IsEquipment = item.Level1.IsEquipment;
|
|
structItem.IsEquipUpdate = item.Level1.IsEquipUpdate;
|
|
structItem.IsEquipUser = item.Level1.IsEquipUser;
|
|
|
|
structItem.IsInforAS = item.Level1.IsInforAS;
|
|
structItem.IsInformation = item.Level1.IsInformation;
|
|
structItem.IsInforSystem = item.Level1.IsInforSystem;
|
|
|
|
structItem.IsSystem = item.Level1.IsSystem;
|
|
structItem.IsSystemAutoZero = item.Level1.IsSystemAutoZero;
|
|
structItem.IsSystemCalibration = item.Level1.IsSystemCalibration;
|
|
structItem.IsSystemExternalOutput = item.Level1.IsSystemExternalOutput;
|
|
structItem.IsSystemIOTest = item.Level1.IsSystemIOTest;
|
|
structItem.IsSystemJudgmentSetting = item.Level1.IsSystemJudgmentSetting;
|
|
structItem.IsSystemSorterSetting = item.Level1.IsSystemSorterSetting;
|
|
|
|
structItem.Dummy1 = false;
|
|
structItem.Dummy2 = false;
|
|
structItem.Dummy3 = false;
|
|
structItem.Dummy4 = false;
|
|
structItem.Dummy5 = false;
|
|
structItem.Dummy6 = false;
|
|
structItem.Dummy7 = false;
|
|
structItem.Dummy8 = false;
|
|
structItem.Dummy9 = false;
|
|
structItem.Dummy10 = false;
|
|
structItem.Dummy11 = false;
|
|
structItem.Dummy12 = false;
|
|
structItem.Dummy13 = false;
|
|
structItem.Dummy14 = false;
|
|
structItem.Dummy15 = false;
|
|
structItem.Dummy16 = false;
|
|
structItem.Dummy17 = false;
|
|
structItem.Dummy18 = false;
|
|
structItem.Dummy19 = false;
|
|
structItem.Dummy20 = false;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.f0_Level1);
|
|
#endregion
|
|
|
|
#region Level2
|
|
structItem.IsBasic = item.Level2.IsBasic;
|
|
structItem.IsBasicDataBackup = item.Level2.IsBasicDataBackup;
|
|
structItem.IsBasicDataStatistics = item.Level2.IsBasicDataStatistics;
|
|
structItem.IsBasicProduct = item.Level2.IsBasicProduct;
|
|
structItem.IsBasicTime = item.Level2.IsBasicTime;
|
|
|
|
structItem.IsConfiCommunication = item.Level2.IsConfiCommunication;
|
|
structItem.IsConfiguration = item.Level2.IsConfiguration;
|
|
structItem.IsConfiOption = item.Level2.IsConfiOption;
|
|
|
|
structItem.IsEquipFunctionSetting = item.Level2.IsEquipFunctionSetting;
|
|
structItem.IsEquipInitialize = item.Level2.IsEquipInitialize;
|
|
structItem.IsEquipment = item.Level2.IsEquipment;
|
|
structItem.IsEquipUpdate = item.Level2.IsEquipUpdate;
|
|
structItem.IsEquipUser = item.Level2.IsEquipUser;
|
|
|
|
structItem.IsInforAS = item.Level2.IsInforAS;
|
|
structItem.IsInformation = item.Level2.IsInformation;
|
|
structItem.IsInforSystem = item.Level2.IsInforSystem;
|
|
|
|
structItem.IsSystem = item.Level2.IsSystem;
|
|
structItem.IsSystemAutoZero = item.Level2.IsSystemAutoZero;
|
|
structItem.IsSystemCalibration = item.Level2.IsSystemCalibration;
|
|
structItem.IsSystemExternalOutput = item.Level2.IsSystemExternalOutput;
|
|
structItem.IsSystemIOTest = item.Level2.IsSystemIOTest;
|
|
structItem.IsSystemJudgmentSetting = item.Level2.IsSystemJudgmentSetting;
|
|
structItem.IsSystemSorterSetting = item.Level2.IsSystemSorterSetting;
|
|
|
|
structItem.Dummy1 = false;
|
|
structItem.Dummy2 = false;
|
|
structItem.Dummy3 = false;
|
|
structItem.Dummy4 = false;
|
|
structItem.Dummy5 = false;
|
|
structItem.Dummy6 = false;
|
|
structItem.Dummy7 = false;
|
|
structItem.Dummy8 = false;
|
|
structItem.Dummy9 = false;
|
|
structItem.Dummy10 = false;
|
|
structItem.Dummy11 = false;
|
|
structItem.Dummy12 = false;
|
|
structItem.Dummy13 = false;
|
|
structItem.Dummy14 = false;
|
|
structItem.Dummy15 = false;
|
|
structItem.Dummy16 = false;
|
|
structItem.Dummy17 = false;
|
|
structItem.Dummy18 = false;
|
|
structItem.Dummy19 = false;
|
|
structItem.Dummy20 = false;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.f1_Level2);
|
|
#endregion
|
|
|
|
#region Level3
|
|
structItem.IsBasic = item.Level3.IsBasic;
|
|
structItem.IsBasicDataBackup = item.Level3.IsBasicDataBackup;
|
|
structItem.IsBasicDataStatistics = item.Level3.IsBasicDataStatistics;
|
|
structItem.IsBasicProduct = item.Level3.IsBasicProduct;
|
|
structItem.IsBasicTime = item.Level3.IsBasicTime;
|
|
|
|
structItem.IsConfiCommunication = item.Level3.IsConfiCommunication;
|
|
structItem.IsConfiguration = item.Level3.IsConfiguration;
|
|
structItem.IsConfiOption = item.Level3.IsConfiOption;
|
|
|
|
structItem.IsEquipFunctionSetting = item.Level3.IsEquipFunctionSetting;
|
|
structItem.IsEquipInitialize = item.Level3.IsEquipInitialize;
|
|
structItem.IsEquipment = item.Level3.IsEquipment;
|
|
structItem.IsEquipUpdate = item.Level3.IsEquipUpdate;
|
|
structItem.IsEquipUser = item.Level3.IsEquipUser;
|
|
|
|
structItem.IsInforAS = item.Level3.IsInforAS;
|
|
structItem.IsInformation = item.Level3.IsInformation;
|
|
structItem.IsInforSystem = item.Level3.IsInforSystem;
|
|
|
|
structItem.IsSystem = item.Level3.IsSystem;
|
|
structItem.IsSystemAutoZero = item.Level3.IsSystemAutoZero;
|
|
structItem.IsSystemCalibration = item.Level3.IsSystemCalibration;
|
|
structItem.IsSystemExternalOutput = item.Level3.IsSystemExternalOutput;
|
|
structItem.IsSystemIOTest = item.Level3.IsSystemIOTest;
|
|
structItem.IsSystemJudgmentSetting = item.Level3.IsSystemJudgmentSetting;
|
|
structItem.IsSystemSorterSetting = item.Level3.IsSystemSorterSetting;
|
|
|
|
structItem.Dummy1 = false;
|
|
structItem.Dummy2 = false;
|
|
structItem.Dummy3 = false;
|
|
structItem.Dummy4 = false;
|
|
structItem.Dummy5 = false;
|
|
structItem.Dummy6 = false;
|
|
structItem.Dummy7 = false;
|
|
structItem.Dummy8 = false;
|
|
structItem.Dummy9 = false;
|
|
structItem.Dummy10 = false;
|
|
structItem.Dummy11 = false;
|
|
structItem.Dummy12 = false;
|
|
structItem.Dummy13 = false;
|
|
structItem.Dummy14 = false;
|
|
structItem.Dummy15 = false;
|
|
structItem.Dummy16 = false;
|
|
structItem.Dummy17 = false;
|
|
structItem.Dummy18 = false;
|
|
structItem.Dummy19 = false;
|
|
structItem.Dummy20 = false;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.f2_Level3);
|
|
#endregion
|
|
|
|
this.smartFileIO.WriteStructure_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void SaveUserGroupFile_Level1(UserGroupItem item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserGroupItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroup.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserGroupFile();
|
|
}
|
|
|
|
#region Level1
|
|
structItem.IsBasic = item.IsBasic;
|
|
structItem.IsBasicDataBackup = item.IsBasicDataBackup;
|
|
structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
|
|
structItem.IsBasicProduct = item.IsBasicProduct;
|
|
structItem.IsBasicTime = item.IsBasicTime;
|
|
|
|
structItem.IsConfiCommunication = item.IsConfiCommunication;
|
|
structItem.IsConfiguration = item.IsConfiguration;
|
|
structItem.IsConfiOption = item.IsConfiOption;
|
|
|
|
structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
|
|
structItem.IsEquipInitialize = item.IsEquipInitialize;
|
|
structItem.IsEquipment = item.IsEquipment;
|
|
structItem.IsEquipUpdate = item.IsEquipUpdate;
|
|
structItem.IsEquipUser = item.IsEquipUser;
|
|
|
|
structItem.IsInforAS = item.IsInforAS;
|
|
structItem.IsInformation = item.IsInformation;
|
|
structItem.IsInforSystem = item.IsInforSystem;
|
|
|
|
structItem.IsSystem = item.IsSystem;
|
|
structItem.IsSystemAutoZero = item.IsSystemAutoZero;
|
|
structItem.IsSystemCalibration = item.IsSystemCalibration;
|
|
structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
|
|
structItem.IsSystemIOTest = item.IsSystemIOTest;
|
|
structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
|
|
structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;
|
|
|
|
structItem.Dummy1 = false;
|
|
structItem.Dummy2 = false;
|
|
structItem.Dummy3 = false;
|
|
structItem.Dummy4 = false;
|
|
structItem.Dummy5 = false;
|
|
structItem.Dummy6 = false;
|
|
structItem.Dummy7 = false;
|
|
structItem.Dummy8 = false;
|
|
structItem.Dummy9 = false;
|
|
structItem.Dummy10 = false;
|
|
structItem.Dummy11 = false;
|
|
structItem.Dummy12 = false;
|
|
structItem.Dummy13 = false;
|
|
structItem.Dummy14 = false;
|
|
structItem.Dummy15 = false;
|
|
structItem.Dummy16 = false;
|
|
structItem.Dummy17 = false;
|
|
structItem.Dummy18 = false;
|
|
structItem.Dummy19 = false;
|
|
structItem.Dummy20 = false;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.f0_Level1);
|
|
#endregion
|
|
|
|
this.smartFileIO.WriteStructure_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void SaveUserGroupFile_Level2(UserGroupItem item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserGroupItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroup.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserGroupFile();
|
|
}
|
|
|
|
#region Level2
|
|
structItem.IsBasic = item.IsBasic;
|
|
structItem.IsBasicDataBackup = item.IsBasicDataBackup;
|
|
structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
|
|
structItem.IsBasicProduct = item.IsBasicProduct;
|
|
structItem.IsBasicTime = item.IsBasicTime;
|
|
|
|
structItem.IsConfiCommunication = item.IsConfiCommunication;
|
|
structItem.IsConfiguration = item.IsConfiguration;
|
|
structItem.IsConfiOption = item.IsConfiOption;
|
|
|
|
structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
|
|
structItem.IsEquipInitialize = item.IsEquipInitialize;
|
|
structItem.IsEquipment = item.IsEquipment;
|
|
structItem.IsEquipUpdate = item.IsEquipUpdate;
|
|
structItem.IsEquipUser = item.IsEquipUser;
|
|
|
|
structItem.IsInforAS = item.IsInforAS;
|
|
structItem.IsInformation = item.IsInformation;
|
|
structItem.IsInforSystem = item.IsInforSystem;
|
|
|
|
structItem.IsSystem = item.IsSystem;
|
|
structItem.IsSystemAutoZero = item.IsSystemAutoZero;
|
|
structItem.IsSystemCalibration = item.IsSystemCalibration;
|
|
structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
|
|
structItem.IsSystemIOTest = item.IsSystemIOTest;
|
|
structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
|
|
structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;
|
|
|
|
structItem.Dummy1 = false;
|
|
structItem.Dummy2 = false;
|
|
structItem.Dummy3 = false;
|
|
structItem.Dummy4 = false;
|
|
structItem.Dummy5 = false;
|
|
structItem.Dummy6 = false;
|
|
structItem.Dummy7 = false;
|
|
structItem.Dummy8 = false;
|
|
structItem.Dummy9 = false;
|
|
structItem.Dummy10 = false;
|
|
structItem.Dummy11 = false;
|
|
structItem.Dummy12 = false;
|
|
structItem.Dummy13 = false;
|
|
structItem.Dummy14 = false;
|
|
structItem.Dummy15 = false;
|
|
structItem.Dummy16 = false;
|
|
structItem.Dummy17 = false;
|
|
structItem.Dummy18 = false;
|
|
structItem.Dummy19 = false;
|
|
structItem.Dummy20 = false;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.f1_Level2);
|
|
#endregion
|
|
|
|
this.smartFileIO.WriteStructure_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void SaveUserGroupFile_Level3(UserGroupItem item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserGroupItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroup.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserGroupFile();
|
|
}
|
|
|
|
#region Level3
|
|
structItem.IsBasic = item.IsBasic;
|
|
structItem.IsBasicDataBackup = item.IsBasicDataBackup;
|
|
structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
|
|
structItem.IsBasicProduct = item.IsBasicProduct;
|
|
structItem.IsBasicTime = item.IsBasicTime;
|
|
|
|
structItem.IsConfiCommunication = item.IsConfiCommunication;
|
|
structItem.IsConfiguration = item.IsConfiguration;
|
|
structItem.IsConfiOption = item.IsConfiOption;
|
|
|
|
structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
|
|
structItem.IsEquipInitialize = item.IsEquipInitialize;
|
|
structItem.IsEquipment = item.IsEquipment;
|
|
structItem.IsEquipUpdate = item.IsEquipUpdate;
|
|
structItem.IsEquipUser = item.IsEquipUser;
|
|
|
|
structItem.IsInforAS = item.IsInforAS;
|
|
structItem.IsInformation = item.IsInformation;
|
|
structItem.IsInforSystem = item.IsInforSystem;
|
|
|
|
structItem.IsSystem = item.IsSystem;
|
|
structItem.IsSystemAutoZero = item.IsSystemAutoZero;
|
|
structItem.IsSystemCalibration = item.IsSystemCalibration;
|
|
structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
|
|
structItem.IsSystemIOTest = item.IsSystemIOTest;
|
|
structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
|
|
structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;
|
|
|
|
structItem.Dummy1 = false;
|
|
structItem.Dummy2 = false;
|
|
structItem.Dummy3 = false;
|
|
structItem.Dummy4 = false;
|
|
structItem.Dummy5 = false;
|
|
structItem.Dummy6 = false;
|
|
structItem.Dummy7 = false;
|
|
structItem.Dummy8 = false;
|
|
structItem.Dummy9 = false;
|
|
structItem.Dummy10 = false;
|
|
structItem.Dummy11 = false;
|
|
structItem.Dummy12 = false;
|
|
structItem.Dummy13 = false;
|
|
structItem.Dummy14 = false;
|
|
structItem.Dummy15 = false;
|
|
structItem.Dummy16 = false;
|
|
structItem.Dummy17 = false;
|
|
structItem.Dummy18 = false;
|
|
structItem.Dummy19 = false;
|
|
structItem.Dummy20 = false;
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.f2_Level3);
|
|
#endregion
|
|
|
|
this.smartFileIO.WriteStructure_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
private void LoadUserGroupFile(ref UserGroup item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserGroupItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroup.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserGroupFile();
|
|
}
|
|
|
|
try
|
|
{
|
|
if (this.smartFileIO.ReadStructureAllBuffer() == true)
|
|
{
|
|
#region Level1
|
|
structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.EnumFileUserGroup.f0_Level1);
|
|
|
|
item.Level1.IsBasic = structItem.IsBasic;
|
|
item.Level1.IsBasicDataBackup = structItem.IsBasicDataBackup;
|
|
item.Level1.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
|
|
item.Level1.IsBasicProduct = structItem.IsBasicProduct;
|
|
item.Level1.IsBasicTime = structItem.IsBasicTime;
|
|
|
|
item.Level1.IsConfiCommunication = structItem.IsConfiCommunication;
|
|
item.Level1.IsConfiguration = structItem.IsConfiguration;
|
|
item.Level1.IsConfiOption = structItem.IsConfiOption;
|
|
|
|
item.Level1.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
|
|
item.Level1.IsEquipInitialize = structItem.IsEquipInitialize;
|
|
item.Level1.IsEquipment = structItem.IsEquipment;
|
|
item.Level1.IsEquipUpdate = structItem.IsEquipUpdate;
|
|
item.Level1.IsEquipUser = structItem.IsEquipUser;
|
|
|
|
item.Level1.IsInforAS = structItem.IsInforAS;
|
|
item.Level1.IsInformation = structItem.IsInformation;
|
|
item.Level1.IsInforSystem = structItem.IsInforSystem;
|
|
|
|
item.Level1.IsSystem = structItem.IsSystem;
|
|
item.Level1.IsSystemAutoZero = structItem.IsSystemAutoZero;
|
|
item.Level1.IsSystemCalibration = structItem.IsSystemCalibration;
|
|
item.Level1.IsSystemExternalOutput = structItem.IsSystemExternalOutput;
|
|
item.Level1.IsSystemIOTest = structItem.IsSystemIOTest;
|
|
item.Level1.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting;
|
|
item.Level1.IsSystemSorterSetting = structItem.IsSystemSorterSetting;
|
|
#endregion
|
|
|
|
#region Level2
|
|
structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.EnumFileUserGroup.f1_Level2);
|
|
|
|
item.Level2.IsBasic = structItem.IsBasic;
|
|
item.Level2.IsBasicDataBackup = structItem.IsBasicDataBackup;
|
|
item.Level2.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
|
|
item.Level2.IsBasicProduct = structItem.IsBasicProduct;
|
|
item.Level2.IsBasicTime = structItem.IsBasicTime;
|
|
|
|
item.Level2.IsConfiCommunication = structItem.IsConfiCommunication;
|
|
item.Level2.IsConfiguration = structItem.IsConfiguration;
|
|
item.Level2.IsConfiOption = structItem.IsConfiOption;
|
|
|
|
item.Level2.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
|
|
item.Level2.IsEquipInitialize = structItem.IsEquipInitialize;
|
|
item.Level2.IsEquipment = structItem.IsEquipment;
|
|
item.Level2.IsEquipUpdate = structItem.IsEquipUpdate;
|
|
item.Level2.IsEquipUser = structItem.IsEquipUser;
|
|
|
|
item.Level2.IsInforAS = structItem.IsInforAS;
|
|
item.Level2.IsInformation = structItem.IsInformation;
|
|
item.Level2.IsInforSystem = structItem.IsInforSystem;
|
|
|
|
item.Level2.IsSystem = structItem.IsSystem;
|
|
item.Level2.IsSystemAutoZero = structItem.IsSystemAutoZero;
|
|
item.Level2.IsSystemCalibration = structItem.IsSystemCalibration;
|
|
item.Level2.IsSystemExternalOutput = structItem.IsSystemExternalOutput;
|
|
item.Level2.IsSystemIOTest = structItem.IsSystemIOTest;
|
|
item.Level2.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting;
|
|
item.Level2.IsSystemSorterSetting = structItem.IsSystemSorterSetting;
|
|
#endregion
|
|
|
|
#region Level3
|
|
structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.EnumFileUserGroup.f2_Level3);
|
|
|
|
item.Level3.IsBasic = structItem.IsBasic;
|
|
item.Level3.IsBasicDataBackup = structItem.IsBasicDataBackup;
|
|
item.Level3.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
|
|
item.Level3.IsBasicProduct = structItem.IsBasicProduct;
|
|
item.Level3.IsBasicTime = structItem.IsBasicTime;
|
|
|
|
item.Level3.IsConfiCommunication = structItem.IsConfiCommunication;
|
|
item.Level3.IsConfiguration = structItem.IsConfiguration;
|
|
item.Level3.IsConfiOption = structItem.IsConfiOption;
|
|
|
|
item.Level3.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
|
|
item.Level3.IsEquipInitialize = structItem.IsEquipInitialize;
|
|
item.Level3.IsEquipment = structItem.IsEquipment;
|
|
item.Level3.IsEquipUpdate = structItem.IsEquipUpdate;
|
|
item.Level3.IsEquipUser = structItem.IsEquipUser;
|
|
|
|
item.Level3.IsInforAS = structItem.IsInforAS;
|
|
item.Level3.IsInformation = structItem.IsInformation;
|
|
item.Level3.IsInforSystem = structItem.IsInforSystem;
|
|
|
|
item.Level3.IsSystem = structItem.IsSystem;
|
|
item.Level3.IsSystemAutoZero = structItem.IsSystemAutoZero;
|
|
item.Level3.IsSystemCalibration = structItem.IsSystemCalibration;
|
|
item.Level3.IsSystemExternalOutput = structItem.IsSystemExternalOutput;
|
|
item.Level3.IsSystemIOTest = structItem.IsSystemIOTest;
|
|
item.Level3.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting;
|
|
item.Level3.IsSystemSorterSetting = structItem.IsSystemSorterSetting;
|
|
#endregion
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region UserLevel1File
|
|
private void CreateUserLevel1File()
|
|
{
|
|
StructUserItem structItem;
|
|
UserItem item = new UserItem();
|
|
|
|
structItem.ID = "L1";
|
|
structItem.Password = "1111";
|
|
structItem.Group = DataStore.UserGroup.Level1Operator;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, 0);
|
|
|
|
for (int i = 1; i < 5; i++)
|
|
{
|
|
structItem.ID = item.ID;
|
|
structItem.Password = item.Password;
|
|
structItem.Group = item.Group;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
}
|
|
public void SaveUserLevel1File(Collection<UserItem> item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserLevel1.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserLevel1File();
|
|
}
|
|
|
|
if (item.Count == 0)
|
|
return;
|
|
|
|
for (int i = 0; i < item.Count; i++)
|
|
{
|
|
structItem.ID = item[i].ID;
|
|
structItem.Password = item[i].Password;
|
|
structItem.Group = item[i].Group;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteString_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadUserLevel1File(Collection<UserItem> item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserLevel1.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserLevel1File();
|
|
}
|
|
|
|
try
|
|
{
|
|
for (int i = 0; i < item.Count; i++)
|
|
{
|
|
structItem = (StructUserItem)this.smartFileIO.ReadStructure(i, typeof(StructUserItem));
|
|
|
|
item[i].ID = structItem.ID;
|
|
item[i].Password = structItem.Password;
|
|
item[i].Group = structItem.Group;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
#region UserLevel2File
|
|
private void CreateUserLevel2File()
|
|
{
|
|
StructUserItem structItem;
|
|
UserItem item = new UserItem();
|
|
|
|
structItem.ID = "L2";
|
|
structItem.Password = "2222";
|
|
structItem.Group = DataStore.UserGroup.Level2Engineer;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, 0);
|
|
|
|
for (int i = 1; i < 5; i++)
|
|
{
|
|
structItem.ID = item.ID;
|
|
structItem.Password = item.Password;
|
|
structItem.Group = item.Group;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
}
|
|
public void SaveUserLevel2File(Collection<UserItem> item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserLevel2.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserLevel2File();
|
|
}
|
|
|
|
if (item.Count == 0)
|
|
return;
|
|
|
|
for (int i = 0; i < item.Count; i++)
|
|
{
|
|
structItem.ID = item[i].ID;
|
|
structItem.Password = item[i].Password;
|
|
structItem.Group = item[i].Group;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteString_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadUserLevel2File(Collection<UserItem> item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserLevel2.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserLevel2File();
|
|
}
|
|
|
|
try
|
|
{
|
|
for (int i = 0; i < item.Count; i++)
|
|
{
|
|
structItem = (StructUserItem)this.smartFileIO.ReadStructure(i, typeof(StructUserItem));
|
|
|
|
item[i].ID = structItem.ID;
|
|
item[i].Password = structItem.Password;
|
|
item[i].Group = structItem.Group;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
#region UserLevel3File
|
|
private void CreateUserLevel3File()
|
|
{
|
|
StructUserItem structItem;
|
|
UserItem item = new UserItem();
|
|
|
|
structItem.ID = "L3";
|
|
structItem.Password = "3333";
|
|
structItem.Group = DataStore.UserGroup.Level3Manager;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, 0);
|
|
|
|
for (int i = 1; i < 5; i++)
|
|
{
|
|
structItem.ID = item.ID;
|
|
structItem.Password = item.Password;
|
|
structItem.Group = item.Group;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteStructure_End();
|
|
}
|
|
public void SaveUserLevel3File(Collection<UserItem> item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserLevel3.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserLevel3File();
|
|
}
|
|
|
|
if (item.Count == 0)
|
|
return;
|
|
|
|
for (int i = 0; i < item.Count; i++)
|
|
{
|
|
structItem.ID = item[i].ID;
|
|
structItem.Password = item[i].Password;
|
|
structItem.Group = item[i].Group;
|
|
|
|
structItem.Dummy1 = "";
|
|
structItem.Dummy2 = "";
|
|
structItem.Dummy3 = "";
|
|
structItem.Dummy4 = "";
|
|
structItem.Dummy5 = "";
|
|
|
|
this.smartFileIO.WriteStructure_Begin(structItem, i);
|
|
}
|
|
this.smartFileIO.WriteString_End();
|
|
this.smartFileIO.Close();
|
|
}
|
|
public void LoadUserLevel3File(Collection<UserItem> item)
|
|
{
|
|
string fullFilePath = "";
|
|
bool fileCheck = false;
|
|
StructUserItem structItem;
|
|
|
|
fullFilePath = this.PathSDCardSystemFile1Folder + "UserLevel3.int";
|
|
this.smartFileIO.FilePathName = fullFilePath;
|
|
|
|
FileInfo fileInfo = new FileInfo(fullFilePath);
|
|
fileCheck = fileInfo.Exists;
|
|
|
|
if (fileCheck == true)
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
else
|
|
{
|
|
this.smartFileIO.Open(this.BufferSmartUart);
|
|
|
|
this.CreateUserLevel3File();
|
|
}
|
|
|
|
try
|
|
{
|
|
for (int i = 0; i < item.Count; i++)
|
|
{
|
|
structItem = (StructUserItem)this.smartFileIO.ReadStructure(i, typeof(StructUserItem));
|
|
|
|
item[i].ID = structItem.ID;
|
|
item[i].Password = structItem.Password;
|
|
item[i].Group = structItem.Group;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
|
|
myMsg.ShowDialog();
|
|
|
|
this.smartFileIO.Close();
|
|
}
|
|
this.smartFileIO.Close();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region Override Member
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
// 변수 초기 셋팅1
|
|
this.DefaultSetting1();
|
|
|
|
// SystemConfiguration 파일 읽기
|
|
this.LoadSystemConfigurationFile1();
|
|
this.LoadSystemConfigurationFile2();
|
|
|
|
// SystemParameter1
|
|
this.LoadSystemParameter1File(ref this.CurrentSystemParameter1);
|
|
|
|
// SystemParameter2
|
|
this.LoadSystemParameter2File(ref this.CurrentSystemParameter2);
|
|
|
|
// SystemParameter3
|
|
this.LoadSystemParameter3File(ref this.CurrentSystemParameter3);
|
|
|
|
// SystemParameter4
|
|
this.LoadSystemParameter4File(ref this.CurrentSystemParameter4);
|
|
|
|
// Product File Load
|
|
this.LoadProductFile(ref this.CollectionProductItem);
|
|
|
|
// Judgment File Load
|
|
this.LoadJudgmentSetFile(ref this.CollectionJudgmentItem);
|
|
|
|
// Counter File Load
|
|
this.LoadCounterFile(ref this.CollectionWeightData);
|
|
|
|
// UserGroupPassword 파일 읽기
|
|
this.LoadUserGroupPasswordFile();
|
|
|
|
// BLDC Motor Settings 파일 읽기
|
|
this.LoadBLDCMotorFile();
|
|
|
|
// UserGroup 파일 읽기
|
|
this.LoadUserGroupFile(ref this.CurrentUserGroup);
|
|
// User 파일 읽기
|
|
this.LoadUserLevel1File(this.CurrentUser.Level1Users);
|
|
this.LoadUserLevel2File(this.CurrentUser.Level2Users);
|
|
this.LoadUserLevel3File(this.CurrentUser.Level3Users);
|
|
|
|
// 폼 생성
|
|
this.CreateForm();
|
|
|
|
// 메인 통신 OPEN
|
|
this.OpenSmartUartLink();
|
|
// COM1 OPEN
|
|
this.OpenSerialCOM1();
|
|
// COM3 OPEN
|
|
this.OpenSerialCOM3();
|
|
// COM4 OPEN
|
|
this.OpenSerialCOM4();
|
|
// Modbus COM1 OPEN
|
|
this.OpenModbusCOM1();
|
|
// Modbus COM3 OPEN
|
|
this.OpenModbusCOM3();
|
|
// Modbus COM4 OPEN
|
|
this.OpenModbusCOM4();
|
|
|
|
// Write SystemParameter1
|
|
this.TransferParameter1();
|
|
|
|
// 변수 초기 셋팅2(바코드 셋팅, 이더넷)
|
|
this.DefaultSetting2();
|
|
|
|
this.SmartSplashProgramLoad.Finish();
|
|
this.smartForm.Show((int)DataStore.FormStore.FormMainDisplay);
|
|
this.ChildFormMainDisplay.CurrentBottomMenuControlEnable(DataStore.EquipmentStatus.Stop);
|
|
// Mouse On
|
|
//this.smartForm.Mode = SmartForm.RUNMODE.DEVELOPER;
|
|
//this.smartForm.MouseCursor = SmartForm.OnOff.ON;
|
|
}
|
|
#endregion
|
|
|
|
#region Event Handler
|
|
private void smartSerialPort1_OnReadQueueEvent()
|
|
{
|
|
int ret = 0;
|
|
string strTemp = "";
|
|
byte[] readByte;
|
|
|
|
SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;
|
|
|
|
try
|
|
{
|
|
receiveDataState = this.smartSerialPort1.ReadQueue(out readByte);
|
|
if (this.SystemConfig1.SerialCOM1Mode != 4 && this.SystemConfig1.SerialCOM1Mode != 5)
|
|
strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);
|
|
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true && strTemp != "")
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive COM1 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ((receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY) || (receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.FAILDATA))
|
|
{
|
|
return;
|
|
}
|
|
|
|
switch (this.SystemConfig1.SerialCOM1Mode)
|
|
{
|
|
case 5:
|
|
#region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
|
|
if (readByte[0] != 0x06) // ACK가 아니면 재발송
|
|
{
|
|
switch (this.HMCOM1_Step)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM1(this.RoomChange9028(2));
|
|
break;
|
|
case 3:
|
|
this.TransferSerialCOM1(this.RoomChange9028(1));
|
|
break;
|
|
case 4:
|
|
this.TransferSerialCOM1(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (this.HMCOM1_Step)
|
|
{
|
|
case 1:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.HMCOM1_Step = 2;
|
|
this.TransferSerialCOM1(this.RoomChange9028(2));
|
|
}
|
|
else
|
|
{
|
|
this.HMCOM1_Step = 3;
|
|
this.TransferSerialCOM1(this.RoomChange9028(1));
|
|
}
|
|
break;
|
|
case 2:
|
|
this.HMCOM1_Step = 4;
|
|
this.TransferSerialCOM1(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
case 3:
|
|
break;
|
|
case 4:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 10:
|
|
#region MACSA Laser
|
|
if (strTemp[0] == 0x02)
|
|
{
|
|
if (strTemp[3] == 0x15)
|
|
{
|
|
if (strTemp[6] == 0x54)
|
|
{
|
|
if (this.IsMACSARetransmissionCOM1 == true)
|
|
{
|
|
// MACSA 통신전송이 실패하였습니다.
|
|
DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
|
|
msg.ShowDialog();
|
|
|
|
this.IsMACSARetransmissionCOM1 = false;
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM1(this.CurrentMACSACOM1);
|
|
|
|
this.IsMACSARetransmissionCOM1 = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 15:
|
|
#region OPT2
|
|
int iValue = 0;
|
|
|
|
if (strTemp[0] == 0x02)
|
|
{
|
|
this.CurrentOPT2COM1.IsReceivedData = true;
|
|
|
|
if ((strTemp.Length != 7) || (strTemp.Length < 7) || (strTemp[6] != 0x03))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM1.IsErrorReceivedData = true;
|
|
this.TransferSerialCOM1(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
iValue = int.Parse(strTemp.Substring(4, 2));
|
|
}
|
|
catch
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM1.IsErrorReceivedData = true;
|
|
this.TransferSerialCOM1(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
if ((iValue < 0) || (iValue > 50))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM1.IsErrorSettingStatus = true;
|
|
this.TransferSerialCOM1(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
this.CurrentOPT2COM1.IsErrorReceivedData = false;
|
|
this.CurrentOPT2COM1.IsErrorSettingStatus = false;
|
|
|
|
this.TransferProductParameter(iValue);
|
|
|
|
this.Invoke(new SerialOPT2COM1_Delegate(this.SerialOPT2COM1Delegate));
|
|
}
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
private void smartSerialPort2_OnReadQueueEvent()
|
|
{
|
|
this.ReceiveData();
|
|
|
|
// 통신 확인
|
|
if (this.CommunicationCheckCount / 3 == 1)
|
|
{
|
|
this.ChildFormMainDisplay.pictureBoxCommunicationStatus.Visible = true;
|
|
this.CommunicationCheckCount = 0;
|
|
}
|
|
else
|
|
{
|
|
this.ChildFormMainDisplay.pictureBoxCommunicationStatus.Visible = false;
|
|
this.CommunicationCheckCount += 1;
|
|
}
|
|
}
|
|
private void smartSerialPort3_OnReadQueueEvent()
|
|
{
|
|
int productNo = 0;
|
|
string strTemp = "", value = "";
|
|
byte[] readByte;
|
|
BarcodeStatus status = BarcodeStatus.None;
|
|
SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;
|
|
|
|
try
|
|
{
|
|
receiveDataState = this.smartSerialPort3.ReadQueue(out readByte);
|
|
if (this.SystemConfig1.SerialCOM3Mode != 4 && this.SystemConfig1.SerialCOM3Mode != 5)
|
|
strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);
|
|
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true && strTemp != "")
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive COM3 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ((receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY) || (receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.FAILDATA))
|
|
{
|
|
return;
|
|
}
|
|
|
|
switch (this.SystemConfig1.SerialCOM3Mode)
|
|
{
|
|
case 5:
|
|
#region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
|
|
if (readByte[0] != 0x06) // ACK가 아니면 재발송
|
|
{
|
|
switch (this.HMCOM3_Step)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM3(this.RoomChange9028(2));
|
|
break;
|
|
case 3:
|
|
this.TransferSerialCOM3(this.RoomChange9028(1));
|
|
break;
|
|
case 4:
|
|
this.TransferSerialCOM3(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (this.HMCOM3_Step)
|
|
{
|
|
case 1:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.HMCOM3_Step = 2;
|
|
this.TransferSerialCOM3(this.RoomChange9028(2));
|
|
}
|
|
else
|
|
{
|
|
this.HMCOM3_Step = 3;
|
|
this.TransferSerialCOM3(this.RoomChange9028(1));
|
|
}
|
|
break;
|
|
case 2:
|
|
this.HMCOM3_Step = 4;
|
|
this.TransferSerialCOM3(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
case 3:
|
|
break;
|
|
case 4:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 10:
|
|
#region MACSA Laser
|
|
if (strTemp[0] == 0x02)
|
|
{
|
|
if (strTemp[3] == 0x15)
|
|
{
|
|
if (strTemp[6] == 0x54)
|
|
{
|
|
if (this.IsMACSARetransmissionCOM3 == true)
|
|
{
|
|
// MACSA 통신전송이 실패하였습니다.
|
|
DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
|
|
msg.ShowDialog();
|
|
|
|
this.IsMACSARetransmissionCOM3 = false;
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM3(this.CurrentMACSACOM3);
|
|
|
|
this.IsMACSARetransmissionCOM3 = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 15:
|
|
#region OPT2
|
|
int iValue = 0;
|
|
|
|
if (strTemp[0] == 0x02)
|
|
{
|
|
this.CurrentOPT2COM3.IsReceivedData = true;
|
|
|
|
if ((strTemp.Length != 7) || (strTemp.Length < 7) || (strTemp[6] != 0x03))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM3.IsErrorReceivedData = true;
|
|
this.TransferSerialCOM3(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
iValue = int.Parse(strTemp.Substring(4, 2));
|
|
}
|
|
catch
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM3.IsErrorReceivedData = true;
|
|
this.TransferSerialCOM3(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
if ((iValue < 0) || (iValue > 50))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM3.IsErrorSettingStatus = true;
|
|
this.TransferSerialCOM3(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
this.CurrentOPT2COM3.IsErrorReceivedData = false;
|
|
this.CurrentOPT2COM3.IsErrorSettingStatus = false;
|
|
|
|
this.TransferProductParameter(iValue);
|
|
|
|
this.Invoke(new SerialOPT2COM3_Delegate(this.SerialOPT2COM3Delegate));
|
|
}
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
#region 바코드
|
|
if (this.SystemConfig1.IsBarcodeEnable == true)
|
|
{
|
|
if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
|
|
{
|
|
this.CurrentBarcode.SetData(strTemp);
|
|
this.ChildFormMainDisplay.UpdateBarcodeDisplay(this.CurrentBarcode);
|
|
|
|
if (this.CurrentBarcode.GetQueueCount > 0)
|
|
this.BarcodeProductChange(this.CurrentBarcode);
|
|
}
|
|
else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.ConfiSerial)
|
|
{
|
|
switch (readByte[0])
|
|
{
|
|
case 0x4E: // 78, N : 설정 실패
|
|
value = strTemp.Substring(2, strTemp.Length - 2);
|
|
this.ChildFormMenu.CenterConfiSerial.ControlBarcode.DisplayStatus("> Fail : ErrorNo " + value);
|
|
break;
|
|
case 0x59: // 89, Y : 설정 성공
|
|
if (readByte[strTemp.Length - 1] == 0x41) // Barcode 설정 저장 시, 'Y<space>P<CR><LF><ESC>[A' 수신, A = 0x41
|
|
{
|
|
// Self Disconnection
|
|
this.ChildFormMenu.CenterConfiSerial.ControlBarcode.EnterOrExitCommandMode(0x5B);
|
|
}
|
|
else
|
|
{
|
|
value = strTemp.Substring(2, strTemp.Length - 2);
|
|
this.ChildFormMenu.CenterConfiSerial.ControlBarcode.DisplayLoadingValue(this.CurrentBarcode.SaveGettingShortCut, this.CurrentBarcode.SaveSettingShortCut, value);
|
|
}
|
|
break;
|
|
case 0x1B: // 27, <ESC>:응답
|
|
this.ChildFormMenu.CenterConfiSerial.ControlBarcode.EnterOrExitCommandMode(readByte[1]);
|
|
break;
|
|
case 0x02: //2
|
|
strTemp = strTemp.Substring(1, strTemp.Length - 2);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
this.ChildFormMenu.CenterConfiSerial.DisplayReceive(strTemp);
|
|
}
|
|
|
|
// 나중에 지울것
|
|
this.ChildFormMainDisplay.labelBarcode.Text = strTemp;
|
|
}
|
|
#endregion
|
|
}
|
|
private void smartSerialPort4_OnReadQueueEvent()
|
|
{
|
|
int ret = 0;
|
|
string strTemp = "";
|
|
byte[] readByte;
|
|
|
|
SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;
|
|
|
|
try
|
|
{
|
|
receiveDataState = this.smartSerialPort4.ReadQueue(out readByte);
|
|
if (this.SystemConfig1.SerialCOM4Mode != 4 && this.SystemConfig1.SerialCOM4Mode != 5)
|
|
strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);
|
|
|
|
// 로그
|
|
if (this.IsCommunicationLogOpen == true && strTemp != "")
|
|
this.smartFileCommunicationLog.WriteString(string.Format("Receive COM4 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ((receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY) || (receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.FAILDATA))
|
|
{
|
|
return;
|
|
}
|
|
|
|
switch (this.SystemConfig1.SerialCOM4Mode)
|
|
{
|
|
case 5:
|
|
#region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
|
|
if (readByte[0] != 0x06) // ACK가 아니면 재발송
|
|
{
|
|
switch (this.HMCOM4_Step)
|
|
{
|
|
case 1:
|
|
this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 2:
|
|
this.TransferSerialCOM4(this.RoomChange9028(2));
|
|
break;
|
|
case 3:
|
|
this.TransferSerialCOM4(this.RoomChange9028(1));
|
|
break;
|
|
case 4:
|
|
this.TransferSerialCOM4(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (this.HMCOM4_Step)
|
|
{
|
|
case 1:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.HMCOM4_Step = 2;
|
|
this.TransferSerialCOM4(this.RoomChange9028(2));
|
|
}
|
|
else
|
|
{
|
|
this.HMCOM4_Step = 3;
|
|
this.TransferSerialCOM4(this.RoomChange9028(1));
|
|
}
|
|
break;
|
|
case 2:
|
|
this.HMCOM4_Step = 4;
|
|
this.TransferSerialCOM4(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
case 3:
|
|
break;
|
|
case 4:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 10:
|
|
#region MACSA Laser
|
|
if (strTemp[0] == 0x02)
|
|
{
|
|
if (strTemp[3] == 0x15)
|
|
{
|
|
if (strTemp[6] == 0x54)
|
|
{
|
|
if (this.IsMACSARetransmissionCOM4 == true)
|
|
{
|
|
// MACSA 통신전송이 실패하였습니다.
|
|
DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
|
|
msg.ShowDialog();
|
|
|
|
this.IsMACSARetransmissionCOM4 = false;
|
|
}
|
|
else
|
|
{
|
|
this.TransferSerialCOM4(this.CurrentMACSACOM4);
|
|
|
|
this.IsMACSARetransmissionCOM4 = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 15:
|
|
#region OPT2
|
|
int iValue = 0;
|
|
|
|
if (strTemp[0] == 0x02)
|
|
{
|
|
this.CurrentOPT2COM4.IsReceivedData = true;
|
|
|
|
if ((strTemp.Length != 7) || (strTemp.Length < 7) || (strTemp[6] != 0x03))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM4.IsErrorReceivedData = true;
|
|
this.TransferSerialCOM4(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
iValue = int.Parse(strTemp.Substring(4, 2));
|
|
}
|
|
catch
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM4.IsErrorReceivedData = true;
|
|
this.TransferSerialCOM4(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
if ((iValue < 0) || (iValue > 50))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2COM4.IsErrorSettingStatus = true;
|
|
this.TransferSerialCOM4(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
this.CurrentOPT2COM4.IsErrorReceivedData = false;
|
|
this.CurrentOPT2COM4.IsErrorSettingStatus = false;
|
|
|
|
this.TransferProductParameter(iValue);
|
|
|
|
this.Invoke(new SerialOPT2COM4_Delegate(this.SerialOPT2COM4Delegate));
|
|
}
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
// OPC 설정 시 사용
|
|
private void smartModbusSlave1_OnReadHoldingRegisters(SmartModbusSlave.READHOLDINGREGISTERS datas)
|
|
{
|
|
byte[] madeDatas = new byte[TotalBytes];
|
|
|
|
// 수신 Slave Address 와 설정된 Slave Address가 같은 경우
|
|
if (datas.RequestDatas.iSlave == this.smartModbusSlave1.SlaveAddress)
|
|
{
|
|
madeDatas = this.Transfer_22_Modbus();
|
|
|
|
datas.ResponDatas.chDatas = madeDatas;
|
|
datas.ResponDatas.iNumberOfByte = TotalBytes;
|
|
}
|
|
}
|
|
private void smartModbusSlave3_OnReadHoldingRegisters(SmartModbusSlave.READHOLDINGREGISTERS datas)
|
|
{
|
|
byte[] madeDatas = new byte[TotalBytes];
|
|
|
|
// 수신 Slave Address 와 설정된 Slave Address가 같은 경우
|
|
if (datas.RequestDatas.iSlave == this.smartModbusSlave1.SlaveAddress)
|
|
{
|
|
madeDatas = this.Transfer_22_Modbus();
|
|
|
|
datas.ResponDatas.chDatas = madeDatas;
|
|
datas.ResponDatas.iNumberOfByte = TotalBytes;
|
|
}
|
|
}
|
|
private void smartModbusSlave4_OnReadHoldingRegisters(SmartModbusSlave.READHOLDINGREGISTERS datas)
|
|
{
|
|
byte[] madeDatas = new byte[TotalBytes];
|
|
|
|
// 수신 Slave Address 와 설정된 Slave Address가 같은 경우
|
|
if (datas.RequestDatas.iSlave == this.smartModbusSlave1.SlaveAddress)
|
|
{
|
|
madeDatas = this.Transfer_22_Modbus();
|
|
|
|
datas.ResponDatas.chDatas = madeDatas;
|
|
datas.ResponDatas.iNumberOfByte = TotalBytes;
|
|
}
|
|
}
|
|
|
|
private void smartTCPMultiServer_OnReceiveHandler(SmartTCPMultiServer.CHandleClinet.READINFO datas)
|
|
{
|
|
int ret = 0;
|
|
byte[] readByte;
|
|
string strRecData = "";
|
|
byte[] sendDatas = new byte[57];
|
|
byte[] madeDatas = new byte[TotalBytes];
|
|
|
|
try
|
|
{
|
|
readByte = datas.receiveDatas;
|
|
strRecData = SmartTCPMultiServer.ConvertAsciiByteToString(readByte);
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
switch (this.SystemConfig2.EthernetCommMode)
|
|
{
|
|
case 5:
|
|
#region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
|
|
if (readByte[0] != 0x06) // ACK가 아니면 재발송
|
|
{
|
|
switch (this.HMEthernet_Step)
|
|
{
|
|
case 1:
|
|
this.EthernetWeightData(this.SendChar(DataStore.CharValue.ENQ));
|
|
break;
|
|
case 2:
|
|
this.EthernetWeightData(this.RoomChange9028(2));
|
|
break;
|
|
case 3:
|
|
this.EthernetWeightData(this.RoomChange9028(1));
|
|
break;
|
|
case 4:
|
|
this.EthernetWeightData(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (this.HMEthernet_Step)
|
|
{
|
|
case 1:
|
|
if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
|
|
{
|
|
this.HMEthernet_Step = 2;
|
|
this.EthernetWeightData(this.RoomChange9028(2));
|
|
}
|
|
else
|
|
{
|
|
this.HMEthernet_Step = 3;
|
|
this.EthernetWeightData(this.RoomChange9028(1));
|
|
}
|
|
break;
|
|
case 2:
|
|
this.HMEthernet_Step = 4;
|
|
this.EthernetWeightData(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
|
|
break;
|
|
case 3:
|
|
break;
|
|
case 4:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 10:
|
|
#region MACSA Laser
|
|
if (readByte[0] == 0x02)
|
|
{
|
|
if (readByte[3] == 0x15)
|
|
{
|
|
if (readByte[6] == 0x54)
|
|
{
|
|
if (this.IsMACSARetransmissionEthernet == true)
|
|
{
|
|
// MACSA 통신전송이 실패하였습니다.
|
|
DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
|
|
msg.ShowDialog();
|
|
|
|
this.IsMACSARetransmissionEthernet = false;
|
|
}
|
|
else
|
|
{
|
|
this.EthernetWeightData(this.CurrentMACSAEthernet);
|
|
|
|
this.IsMACSARetransmissionEthernet = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
case 15:
|
|
#region OPT2
|
|
int iValue = 0;
|
|
|
|
if (readByte[0] == 0x02)
|
|
{
|
|
this.CurrentOPT2Ethernet.IsReceivedData = true;
|
|
|
|
if ((readByte.Length != 7) || (readByte.Length < 7) || (readByte[6] != 0x03))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2Ethernet.IsErrorReceivedData = true;
|
|
this.EthernetWeightData(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
iValue = int.Parse(strRecData.Substring(4, 2));
|
|
}
|
|
catch
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2Ethernet.IsErrorReceivedData = true;
|
|
this.EthernetWeightData(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
|
|
if ((iValue < 0) || (iValue > 50))
|
|
{
|
|
// Response 현재품번으로 해서 응답
|
|
this.CurrentOPT2Ethernet.IsErrorSettingStatus = true;
|
|
this.EthernetWeightData(this.ResponseFrameOPT2());
|
|
return;
|
|
}
|
|
this.CurrentOPT2Ethernet.IsErrorReceivedData = false;
|
|
this.CurrentOPT2Ethernet.IsErrorSettingStatus = false;
|
|
|
|
this.TransferProductParameter(iValue);
|
|
|
|
this.Invoke(new SerialOPT2Ethernet_Delegate(this.SerialOPT2EthernetDelegate));
|
|
}
|
|
#endregion
|
|
break;
|
|
case 16:
|
|
#region OPC
|
|
if (this.smartTCPMultiServer.ClientInfoList != null)
|
|
{
|
|
sendDatas[0] = readByte[0];
|
|
sendDatas[1] = readByte[1];
|
|
sendDatas[2] = 0x00;
|
|
sendDatas[3] = 0x00;
|
|
|
|
// Length(Unit ID~ 길이)
|
|
sendDatas[4] = 0x00;
|
|
sendDatas[5] = 0x33;
|
|
// Unit ID
|
|
sendDatas[6] = 0x01;
|
|
//Function code
|
|
sendDatas[7] = 0x03;
|
|
|
|
// Byte Count(Data의 개수)
|
|
sendDatas[8] = 0x30;
|
|
|
|
madeDatas = this.Transfer_22_Modbus();
|
|
|
|
for (int i = 0; i < TotalBytes; i++)
|
|
sendDatas[9 + i] = madeDatas[i];
|
|
|
|
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
|
|
{
|
|
this.smartTCPMultiServer.SendByteByClientID(client.strID, sendDatas);
|
|
}
|
|
}
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void smartThread_UIThreadFunction(ThreadArgs args)
|
|
{
|
|
// 메시지 23. 알람 조건이 충족하여 장비가 정지되었습니다
|
|
if (this.FlagThreadMessage1 == false)
|
|
{
|
|
DialogFormMessage myMsg = new DialogFormMessage(23, this.SystemConfig1.Language, this);
|
|
myMsg.ShowDialog();
|
|
|
|
this.FlagThreadMessage1 = true;
|
|
}
|
|
}
|
|
|
|
private void timeOut_Tick(object sender, EventArgs e)
|
|
{
|
|
this.timeOut.Enabled = false;
|
|
|
|
// 데이터백업 포맷 : OPT1 - 리젝데이터 Timeout 처리
|
|
if (this.CollectionBufferWeightData.Count > 0)
|
|
{
|
|
for (int i = 0; i < this.CollectionBufferWeightData.Count; i++)
|
|
{
|
|
this.CollectionBufferWeightData[i].Status = DataStore.JudgmentResult.Timeout.ToString();
|
|
this.DataBackup1(this.CollectionBufferWeightData[i]);
|
|
}
|
|
this.CollectionBufferWeightData.Clear();
|
|
}
|
|
}
|
|
|
|
// 전송지연시간 관련
|
|
private void timerCOM1_Tick(object sender, EventArgs e)
|
|
{
|
|
System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
timer.Enabled = false;
|
|
|
|
if (this.QueueCOM1.Count > 0)
|
|
{
|
|
Type type = this.QueueCOM1.Peek().GetType();
|
|
|
|
if (type == typeof(string))
|
|
this.TransferDirectSerialCOM1((string)this.QueueCOM1.Dequeue());
|
|
else if (type == typeof(byte[]))
|
|
this.TransferDirectSerialCOM1((byte[])this.QueueCOM1.Dequeue());
|
|
}
|
|
|
|
timer.Dispose();
|
|
timer = null;
|
|
}
|
|
private void timerCOM3_Tick(object sender, EventArgs e)
|
|
{
|
|
System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
timer.Enabled = false;
|
|
|
|
if (this.QueueCOM3.Count > 0)
|
|
{
|
|
Type type = this.QueueCOM3.Peek().GetType();
|
|
|
|
if (this.smartSerialPort3.FrameSeparationType == SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY)
|
|
{
|
|
if (type == typeof(string))
|
|
this.TransferDirectSerialCOM3RawData((string)this.QueueCOM3.Dequeue());
|
|
else if (type == typeof(byte[]))
|
|
this.TransferDirectSerialCOM3RawData((byte[])this.QueueCOM3.Dequeue());
|
|
}
|
|
else
|
|
{
|
|
if (type == typeof(string))
|
|
this.TransferDirectSerialCOM3((string)this.QueueCOM3.Dequeue());
|
|
else if (type == typeof(byte[]))
|
|
this.TransferDirectSerialCOM3((byte[])this.QueueCOM3.Dequeue());
|
|
}
|
|
}
|
|
|
|
timer.Dispose();
|
|
timer = null;
|
|
}
|
|
private void timerCOM4_Tick(object sender, EventArgs e)
|
|
{
|
|
System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
timer.Enabled = false;
|
|
|
|
if (this.QueueCOM4.Count > 0)
|
|
{
|
|
Type type = this.QueueCOM4.Peek().GetType();
|
|
|
|
if (type == typeof(string))
|
|
this.TransferDirectSerialCOM4((string)this.QueueCOM4.Dequeue());
|
|
else if (type == typeof(byte[]))
|
|
this.TransferDirectSerialCOM4((byte[])this.QueueCOM4.Dequeue());
|
|
}
|
|
|
|
timer.Dispose();
|
|
timer = null;
|
|
}
|
|
private void timerOPT2COM1_Tick(object sender, EventArgs e)
|
|
{
|
|
System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
timer.Enabled = false;
|
|
|
|
this.CurrentOPT2COM1.IsReceivedData = false;
|
|
|
|
timer.Dispose();
|
|
timer = null;
|
|
|
|
}
|
|
private void timerOPT2COM3_Tick(object sender, EventArgs e)
|
|
{
|
|
System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
timer.Enabled = false;
|
|
|
|
this.CurrentOPT2COM3.IsReceivedData = false;
|
|
|
|
timer.Dispose();
|
|
timer = null;
|
|
}
|
|
private void timerOPT2COM4_Tick(object sender, EventArgs e)
|
|
{
|
|
System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
timer.Enabled = false;
|
|
|
|
this.CurrentOPT2COM4.IsReceivedData = false;
|
|
|
|
timer.Dispose();
|
|
timer = null;
|
|
}
|
|
private void timerOPT2Ethernet_Tick(object sender, EventArgs e)
|
|
{
|
|
System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
timer.Enabled = false;
|
|
|
|
this.CurrentOPT2Ethernet.IsReceivedData = false;
|
|
|
|
timer.Dispose();
|
|
timer = null;
|
|
}
|
|
//private void timerImaje9410OPT1_Tick(object sender, EventArgs e)
|
|
//{
|
|
// System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
// timer.Enabled = false;
|
|
|
|
// this.TransferSerial_imaje9410OPT1(DataStore.MenuBottomConfiguration.SerialCOM4, this.CurrentWeightData);
|
|
// if (this.QueueCOM4.Count > 0)
|
|
// this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());
|
|
|
|
// timer.Dispose();
|
|
// timer = null;
|
|
//}
|
|
//private void timerImaje9028OPT1_Tick(object sender, EventArgs e)
|
|
//{
|
|
// System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
// timer.Enabled = false;
|
|
|
|
// if (this.QueueCOM4.Count > 0)
|
|
// this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());
|
|
|
|
// timer.Dispose();
|
|
// timer = null;
|
|
//}
|
|
//private void timerImaje9410OPT2_Tick(object sender, EventArgs e)
|
|
//{
|
|
// System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
// timer.Enabled = false;
|
|
|
|
// if (this.QueueCOM4.Count > 0)
|
|
// this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());
|
|
|
|
// timer.Dispose();
|
|
// timer = null;
|
|
//}
|
|
//private void timerImaje9028OPT2_Tick(object sender, EventArgs e)
|
|
//{
|
|
// System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
|
|
// timer.Enabled = false;
|
|
|
|
// if (this.QueueCOM4.Count > 0)
|
|
// this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());
|
|
|
|
// timer.Dispose();
|
|
// timer = null;
|
|
//}
|
|
private void smartTimerUpdate_Tick(object sender, EventArgs e)
|
|
{
|
|
this.smartTimerUpdate.Stop();
|
|
this.UpdateForMain.RetryCount++;
|
|
|
|
if (this.UpdateForMain.RetryCount < 5)
|
|
this.RetryUpdateForMain(this.UpdateForMain);
|
|
else
|
|
this.ChildFormMenu.CenterEquipUpdate.UpdateMainBoardFail(this.SystemConfig1.Language);
|
|
}
|
|
|
|
private void smartTCPMultiServer_OnClientAdd(SmartTCPMultiServer.CLIENTSINFOS addClientInfo)
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
} |