FileGenerated.cs
9.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
namespace OnlineStore.DeviceLibrary.doubleStore
{
public class FileGenerated
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/**
* プログラム変更受信 (基板搬入抑制)通知 Program change receive (board loading prohibit) notification
*/
public static string REQUEST_ACK = "ACK";
/**
* プログラム変更不可通知 Program change cancel notification
*/
public static string REQUEST_CAN = "CAN";
/**
* プログラム変更正常終了通知 Program change normal end notification
*/
public static string REQUEST_OK = "OK";
/**
* プログラム変更異常終了通知 Program change abnormal end notification
*/
public static string REQUEST_NG = "NG";
//private static string remoteURL = ConfigAppSettings.GetValue(Setting_Init.RemoteURL);
//private static string remoteURL = "//192.168.10.1/othersystem/iLNBIF/MachineIF/M-TowertoiLNB/";
//private static string remoteURL = "/testFile/";
private static string remoteURL = ConfigAppSettings.GetValue(Setting_Init.RemoteWriteURL);
//private static string remoteURL = "//192.168.10.11/doubleStore/";
private static char spiltStr = '&';
private static string localFileDir = "F:/FileDir/";
public static void WriteStrToRemoteUrl(string fileName, string[] lines)
{
try
{
if (!Directory.Exists(remoteURL))//若文件夹不存在则新建文件夹
{
Directory.CreateDirectory(remoteURL); //新建文件夹
}
//先写入本地
//string localFileFullName = "" + localFileDir + fileName;
//写入远程共享文件夹
String FullRemotePath = remoteURL + fileName;
FileShare.WriteFiles(FullRemotePath, lines);
}
catch (Exception ex)
{
LogUtil.error(LOGGER,"写入文件出错:[" + fileName + "]"+ex.ToString());
}
}
public static string GetDateStr()
{
// MCxxxxx&Lane&YYYYMMDDhhmmss&ZZ&TTTT&BZ&LV&A-A.SGI
string dateStr = DateTime.Now.ToString("yyyyMMddHHmmss");
return dateStr;
}
/**
* 8.2.1.1. ファイル名/File name MCxxxxx&Lane&YYYYMMDDhhmmss&ZZ&TTTT&BZ&LV&A-A.SGI
* 設備起動時。状態が変わった時 When machine started When state changed
*/
public static void writeSGIFile(string machineId, string lightT, string alarmInfo, string errorInfo, int autoRun, int troubleStop)
{
string fileEndName = ".SGI";
//固定值レーン No. 01 固定
string BZ = "0";
string ZZ = "00";
string lane = "01";
//拼接长度
lightT = lightT.PadLeft(4, '0');
machineId = machineId.PadLeft(5, '0');
alarmInfo = alarmInfo.PadLeft(2, '0');
errorInfo = errorInfo.PadLeft(8, '0');
string fileName = "MC" + machineId + spiltStr + lane + spiltStr + GetDateStr() + spiltStr + ZZ +
spiltStr + lightT + spiltStr + BZ + spiltStr + alarmInfo + spiltStr + errorInfo + fileEndName;
String warnMessage = DBStoreManager.GetWarMsg();
FileInfomation fileInfo = new FileInfomation();
string[] text = fileInfo.WarnMsgToFileString(warnMessage);
//FileInfomation fileInfo = new FileInfomation(autoRun, troubleStop);
//string[] text = fileInfo.ToFileString();
WriteStrToRemoteUrl(fileName, text);
}
/**
* 8.2.2.1. ファイル名/File name MCxxxxx&Lane&YYYYMMDDhhmmss &ZZ.STS
* 設備起動時。状態が変わった時 When machine started When state changed
*/
public static void writeSTSFile(string machineId, int autoRun, int troubleStop)
{
string fileEndName = ".STS";
//固定值レーン No. 01 固定
string ZZ = "00";
string lane = "01";
//拼接长度
machineId = machineId.PadLeft(5, '0');
string fileName = "MC" + machineId + spiltStr + lane + spiltStr + GetDateStr() + spiltStr + ZZ + fileEndName;
FileInfomation fileInfo = new FileInfomation(autoRun, troubleStop);
string[] text = fileInfo.ToFileString();
//string[] text = new string[] { };
WriteStrToRemoteUrl(fileName, text);
}
/**
* 8.2.3.1. ファイル名/File name (△2) MCxxxxx&Lane&CC.LCT
* 設備状態を常時出力( 500ms~可 変) Always output machine state (500ms–variable)
* 一直需要输出的文件
*/
public static void writeLCTFile(string machineId, int autoRun, int troubleStop,int pcbCount)
{
string fileEndName = ".LCT";
string CC =pcbCount.ToString().PadLeft(2,'0') ;
string lane = "01";
//拼接长度
machineId = machineId.PadLeft(5, '0');
string fileName = "MC" + machineId + spiltStr + lane + spiltStr + CC + fileEndName;
//FileInfomation fileInfo = new FileInfomation(autoRun, troubleStop);
//string[] text = fileInfo.ToFileString();
string[] text = new string[] { };
WriteStrToRemoteUrl(fileName, text);
}
/**
* 8.2.3.1. ファイル名/File name (△2) MCxxxxx&Lane.LST
* 設備状態を常時出力( 500ms~可 変) Always output machine state (500ms–variable)
* 一直需要输出的文件
*/
public static void writeLSTFile(string machineId)
{
string fileEndName = ".LST";
string lane = "01";
//拼接长度
machineId = machineId.PadLeft(5, '0');
string fileName = "MC" + machineId + spiltStr + lane + fileEndName;
//FileInfomation fileInfo = new FileInfomation(autoRun, troubleStop);
//string[] text = fileInfo.ToFileString();
string[] text = new string[] {
"PROGRAM_NAME1",
"PROGRAM_NAME2",
"PROGRAM_NAME3"
};
text = DBLineControl.GetProgramList();
WriteStrToRemoteUrl(fileName, text);
}
/**
* 10.1.2. 機種切り替え替えに使用するファイル一覧/List of files used for product change
* プログラム変更受信 (基板搬入抑制)通知 Program change receive (board loading prohibit) notification
* MCxxxxx&Lane&A-A&P-P&YYYYMMDDhhmmss.ACK
*/
public static void writeACKFile(string machineId, string AA, string PP,string m_time)
{
string fileEndName = ".ACK";
string lane = "01";
string fileName = "MC" + machineId + spiltStr + lane + spiltStr + AA + spiltStr + PP + spiltStr + m_time + fileEndName;
string[] text = new string[] { };
WriteStrToRemoteUrl(fileName, text);
}
/**
* 10.1.2. 機種切り替え替えに使用するファイル一覧/List of files used for product change
* Program change notification
* MCxxxxx&Lane&A-A&P-P&YYYYMMDDhhmmss.RequestType
*/
public static void writeRequestFile(string machineId, string AA, string PP, string RequestType,string m_time)
{
string fileEndName = "." + RequestType;
string lane = "01";
//拼接长度
machineId = machineId.PadLeft(5, '0');
//AA = AA.PadLeft(10, '0');
string fileName = "MC" + machineId + spiltStr + lane + spiltStr + AA + spiltStr + PP + spiltStr + m_time + fileEndName;
string[] text = new string[] { };
WriteStrToRemoteUrl(fileName, text);
}
/**
* 10.1.2. 機種切り替え替えに使用するファイル一覧/List of files used for product change
* MCxxxxx&Lane&A-A&P-P&YYYYMMDDhhmmss.CMD
* 由iLNB方创建
*/
public static void ReadCMDFile(string fullPath,String fileNameh)
{
String fileName = System.IO.Path.GetFileName(fileNameh);
String[] txt = fileName.Split(spiltStr);
String machineId = txt[0].Replace("MC","");
String AA = txt[2];
String PP = txt[3];
String m_time = txt[4].Substring(0,14);
writeACKFile(machineId, AA, PP, m_time);
DBLineControl.UpdateProject(AA,PP,m_time);
//String RequestType = "OK";
//writeRequestFile(machineId, AA, PP, RequestType, m_time);
//删除文件
//string fullPath = "//192.168.10.1/othersystem/iLNBIF/MachineIF/iLNBtoM-Tower/" + fileNameh;
Thread.Sleep(100);
deleteFile(fullPath);
}
/**
* 启动文件夹监视
*/
public static void StartListerDirectory(String DirectoryPath,String filter)
{
FileLister.WatcherStrat(DirectoryPath, filter);
}
public static void deleteFile(String fullName)
{
try
{
//if (!Directory.Exists(remoteURL))//若文件夹不存在则新建文件夹
//{
//}
File.Delete(fullName); //新建文件夹
}
catch (Exception ex)
{
LogUtil.error(LOGGER,"写入文件出错:[" + fullName + "]"+ex.ToString());
}
}
}
}