| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.UI.ControlDataContext;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Communications;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Event;
- using MECF.Framework.Common.FAServices.E40s;
- using MECF.Framework.Common.FAServices.E94s;
- using MECF.Framework.Common.IOCore;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.SubstrateTrackings;
- using OldWorldData.CommonData;
- using OldWorldData.CommonData.DeviceData;
- using OldWorldData.CommonData.SorterDefines;
- using System.Collections.Concurrent;
- using System.Collections.ObjectModel;
- using System.Data;
- using System.ServiceModel;
- namespace OldWorldDataAdaptor.Services;
- internal class DataQueryService : IDataQueryService, IDisposable
- {
- private ChannelFactory<IRTWcfService>? _channelFactory;
- private IRTWcfService? _rtService;
- private IQueryDataProvider? _provider;
- private readonly HashSet<string> _registedKeys = [];
- private readonly ReaderWriterLockSlim _keyRwLock = new();
- private readonly ConcurrentDictionary<string, object> _dataCache = [];
- private Timer? _updateTimer;
- bool IDataQueryService.Initialize(IQueryDataProvider provider)
- {
- if (this._provider is not null)
- return false;
- this._provider = provider;
- return true;
- }
- bool IDataQueryService.RegistDataKey(string keys)
- {
- try
- {
- _keyRwLock.EnterWriteLock();
- return this._registedKeys.Add(keys);
- }
- finally
- {
- _keyRwLock?.ExitWriteLock();
- }
- }
- bool IDataQueryService.RegistDataKey(IEnumerable<string> keys)
- {
- try
- {
- _keyRwLock.EnterWriteLock();
- keys.Foreach(key => this._registedKeys.Add(key));
- }
- finally
- {
- _keyRwLock?.ExitWriteLock();
- }
- return true;
- }
- bool IDataQueryService.StartService(string connectionString)
- {
- if (string.IsNullOrEmpty(connectionString))
- return false;
- if (this._updateTimer is not null)
- return false;
- EndpointAddress add = new(connectionString);
- NetTcpBinding binding = new(SecurityMode.None)
- {
- Name = "Aitex_netTcpBinding",
- MaxReceivedMessageSize = 2147483647,
- OpenTimeout = TimeSpan.FromSeconds(5),
- CloseTimeout = TimeSpan.FromMinutes(3),
- ReceiveTimeout = TimeSpan.FromMinutes(30)
- };
- binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
- binding.Security.Message.ClientCredentialType = MessageCredentialType.None;
- binding.ReaderQuotas.MaxDepth = 32;
- binding.ReaderQuotas.MaxArrayLength = 2147483647;
- binding.ReaderQuotas.MaxBytesPerRead = 4096;
- binding.ReaderQuotas.MaxNameTableCharCount = 16384;
- try
- {
- this._channelFactory = new(binding, add);
- this._rtService = this._channelFactory.CreateChannel();
- }
- catch
- {
- return false;
- }
- this._updateTimer = new(UpdateTimerCallback, null, 0, 1000);
- return true;
- }
- void UpdateTimerCallback(object? state)
- {
- try
- {
- Dictionary<string, object>? rawData = this._rtService?.PollData(this._registedKeys);
- if (rawData is null || rawData.Count == 0)
- return;
- Parallel.ForEach(_dataCache, data =>
- {
- this._provider?.DataChangedNotify(data.Key, data.Value);
- });
- }
- catch
- {
- }
- }
- public void Dispose()
- {
- }
- }
- [ServiceContract]
- [ServiceKnownType(typeof(SignalTowerDataItem))]
- [ServiceKnownType(typeof(GateValveDataItem))]
- [ServiceKnownType(typeof(EventItem))]
- [ServiceKnownType(typeof(List<EventItem>))]
- [ServiceKnownType(typeof(AlarmEventItem))]
- [ServiceKnownType(typeof(List<AlarmEventItem>))]
- [ServiceKnownType(typeof(List<HistoryCarrierData>))]
- [ServiceKnownType(typeof(List<HistoryProcessData>))]
- [ServiceKnownType(typeof(List<HistoryWaferData>))]
- [ServiceKnownType(typeof(List<HistoryMoveData>))]
- [ServiceKnownType(typeof(ProcessJobInfo))]
- [ServiceKnownType(typeof(ControlJobInfo))]
- [ServiceKnownType(typeof(List<ProcessJobInfo>))]
- [ServiceKnownType(typeof(List<ControlJobInfo>))]
- [ServiceKnownType(typeof(List<NotifiableIoItem>))]
- [ServiceKnownType(typeof(NotifiableIoItem))]
- [ServiceKnownType(typeof(AITChillerData))]
- [ServiceKnownType(typeof(AITChillerData1))]
- [ServiceKnownType(typeof(AITTempratureHumidityData))]
- [ServiceKnownType(typeof(AITValveData))]
- [ServiceKnownType(typeof(AITMfcData))]
- [ServiceKnownType(typeof(AITGasSplitterData))]
- [ServiceKnownType(typeof(AITHeaterData))]
- [ServiceKnownType(typeof(AITFFUData))]
- [ServiceKnownType(typeof(AITDeveloperCoupleData))]
- [ServiceKnownType(typeof(AITWaterFlowMeterData))]
- [ServiceKnownType(typeof(AITPressureMeterData))]
- [ServiceKnownType(typeof(AITRfData))]
- [ServiceKnownType(typeof(AITThrottleValveData))]
- [ServiceKnownType(typeof(AITAPCData))]
- [ServiceKnownType(typeof(AITAuxData))]
- [ServiceKnownType(typeof(List<AITAuxData>))]
- [ServiceKnownType(typeof(AITSensorData))]
- [ServiceKnownType(typeof(AITPumpData))]
- [ServiceKnownType(typeof(AITSignalTowerData))]
- [ServiceKnownType(typeof(AITEmoData))]
- [ServiceKnownType(typeof(AITStatisticsData))]
- [ServiceKnownType(typeof(AITBoostPumpData))]
- [ServiceKnownType(typeof(AITCylinderData))]
- [ServiceKnownType(typeof(AITWaterFlowSensorData))]
- [ServiceKnownType(typeof(AITServoMotorData))]
- [ServiceKnownType(typeof(AITLidData))]
- [ServiceKnownType(typeof(ServoState))]
- [ServiceKnownType(typeof(AITRfPowerData))]
- [ServiceKnownType(typeof(AITRfMatchData))]
- [ServiceKnownType(typeof(FlowMeterAlarmItem))]
- [ServiceKnownType(typeof(WaferInfo))]
- [ServiceKnownType(typeof(WaferInfo[]))]
- [ServiceKnownType(typeof(CarrierInfo))]
- [ServiceKnownType(typeof(CarrierInfo[]))]
- [ServiceKnownType(typeof(NotifiableIoItem))]
- [ServiceKnownType(typeof(RobotMoveInfo))]
- [ServiceKnownType(typeof(IndicatorState))]
- [ServiceKnownType(typeof(FoupClampState))]
- [ServiceKnownType(typeof(FoupDoorState))]
- [ServiceKnownType(typeof(LoadportCassetteState))]
- [ServiceKnownType(typeof(AITRfidReaderData))]
- [ServiceKnownType(typeof(AITAlignerData))]
- [ServiceKnownType(typeof(AITWaferIdReaderData))]
- [ServiceKnownType(typeof(ModuleName))]
- [ServiceKnownType(typeof(DeviceState))]
- [ServiceKnownType(typeof(SorterRecipeXml))]
- [ServiceKnownType(typeof(SorterRecipeType))]
- [ServiceKnownType(typeof(SorterRecipePlaceModeOrder))]
- [ServiceKnownType(typeof(SorterRecipePlaceModeTransfer1To1))]
- [ServiceKnownType(typeof(SorterRecipePlaceModePack))]
- [ServiceKnownType(typeof(ObservableCollection<SorterRecipeTransferTableItem>))]
- [ServiceKnownType(typeof(SorterRecipeTransferTableItem))]
- [ServiceKnownType(typeof(SlotTransferInfo))]
- [ServiceKnownType(typeof(SlotTransferInfo[]))]
- [ServiceKnownType(typeof(List<string>))]
- [ServiceKnownType(typeof(List<SCConfigItem>))]
- [ServiceKnownType(typeof(List<WaferTypeInfo>))]
- [ServiceKnownType(typeof(SerializableDictionary<string, bool>))]
- [ServiceKnownType(typeof(SerializableDictionary<string, string>))]
- [ServiceKnownType(typeof(AITWaterMappingData))]
- [ServiceKnownType(typeof(List<AITWaterMappingData>))]
- [ServiceKnownType(typeof(List<FAProcessJob>))]
- [ServiceKnownType(typeof(FAProcessJob))]
- [ServiceKnownType(typeof(List<FAControlJob>))]
- [ServiceKnownType(typeof(FAControlJob))]
- [ServiceKnownType(typeof(List<WCFProcessJobInterface>))]
- [ServiceKnownType(typeof(WCFProcessJobInterface))]
- [ServiceKnownType(typeof(List<WCFControlJobInterface>))]
- [ServiceKnownType(typeof(WCFControlJobInterface))]
- [ServiceKnownType(typeof(NotifiableConnectionItem))]
- [ServiceKnownType(typeof(List<NotifiableConnectionItem>))]
- [ServiceKnownType(typeof(WaferHistoryItemType))]
- [ServiceKnownType(typeof(RecipeStep))]
- [ServiceKnownType(typeof(List<RecipeStep>))]
- [ServiceKnownType(typeof(WaferHistoryItem))]
- [ServiceKnownType(typeof(WaferHistoryRecipe))]
- [ServiceKnownType(typeof(List<WaferHistoryWafer>))]
- [ServiceKnownType(typeof(List<WaferHistoryRecipe>))]
- [ServiceKnownType(typeof(List<WaferHistoryMovement>))]
- [ServiceKnownType(typeof(List<WaferHistoryLot>))]
- [ServiceKnownType(typeof(WaferSize))]
- [ServiceKnownType(typeof(AITDeviceData))]
- [ServiceKnownType(typeof(float[]))]
- [ServiceKnownType(typeof(bool[]))]
- [ServiceKnownType(typeof(int[]))]
- [ServiceKnownType(typeof(byte[]))]
- [ServiceKnownType(typeof(double[]))]
- [ServiceKnownType(typeof(Tuple<int, string>))]
- [ServiceKnownType(typeof(Tuple<int, string>[]))]
- [ServiceKnownType(typeof(ManualTransferTask))]
- [ServiceKnownType(typeof(ManualTransferTask[]))]
- [ServiceKnownType(typeof(Dictionary<string, string>))]
- [ServiceKnownType(typeof(RecipeFileNode))]
- [ServiceKnownType(typeof(List<RecipeFileNode>))]
- [ServiceKnownType(typeof(Dictionary<string, List<string>>))]
- [ServiceKnownType(typeof(Dictionary<string, Dictionary<string, string>>))]
- [ServiceKnownType(typeof(Dictionary<string, bool>))]
- public interface IRTWcfService
- {
- [OperationContract]
- object GetData(string key);
- [OperationContract]
- Dictionary<string, object> PollData(IEnumerable<string> keys);
- [OperationContract]
- Dictionary<string, object> PollConfig(IEnumerable<string> keys);
- [OperationContract]
- object GetConfig(string key);
- [OperationContract]
- List<NotifiableIoItem> GetDiList(string key);
- [OperationContract]
- List<NotifiableIoItem> GetDoList(string key);
- [OperationContract]
- List<NotifiableIoItem> GetAiList(string key);
- [OperationContract]
- List<NotifiableIoItem> GetAoList(string key);
- [OperationContract]
- string GetConfigFileContent();
- [OperationContract]
- string GetFileContent(string fileName);
- [OperationContract]
- string GetConfigFileDispenseByModule(string module);
- [OperationContract]
- List<string> GetFileListByFolderBrowser(string folderBrowser);
- [OperationContract]
- string GetConfigFileContentByModule(string module);
- [OperationContract]
- object GetConfigByModule(string module, string key);
- [OperationContract]
- List<SCConfigItem> GetConfigItemList();
- [OperationContract]
- SCConfigItem GetConfigItem(string key);
- [OperationContract]
- List<WaferTypeInfo> GetConfigWaferTypes();
- [OperationContract]
- Dictionary<string, object> PollConfigByModule(string module, IEnumerable<string> keys);
- [OperationContract]
- List<EventItem> QueryDBEvent(string sql);
- [OperationContract]
- List<HistoryCarrierData> QueryDBCarrier(string sql);
- [OperationContract]
- List<HistoryStatisticsOCRData> QueryDBOCRStatistics(string sql);
- [OperationContract]
- List<HistoryFfuDiffPressureData> QueryDBFfuDiffPressureStatistics(string sql);
- [OperationContract]
- List<StatsStatisticsData> QueryStatsDBStatistics(string sql);
- [OperationContract]
- List<HistoryOCRData> QueryDBOCRHistory(string sql);
- [OperationContract]
- List<HistoryProcessData> QueryDBProcess(string sql);
- [OperationContract]
- List<HistoryWaferData> QueryDBWafer(string sql);
- [OperationContract]
- List<HistoryMoveData> QueryDBMovement(string sql);
- [OperationContract]
- List<HistoryJobMoveData> QueryDBJobMovementByJobGuid(string jobGuid);
- [OperationContract]
- List<HistoryJobMoveData> QueryDBJobMovementByJobGuidAndStationName(string jobGuid, string stationName);
- [OperationContract]
- List<HistoryDataItem> GetHistoryData(IEnumerable<string> keys, string recipeRunGuid, string module);
- [OperationContract]
- List<HistoryDataItem> GetOneDayHistoryData(IEnumerable<string> keys, DateTime begin, string module);
- [OperationContract]
- List<HistoryDataItem> GetHistoryDataFromStartToEnd(IEnumerable<string> keys, DateTime begin, DateTime end, string module);
- [OperationContract]
- DataTable QueryData(string sql);
- [OperationContract]
- WaferHistoryRecipe GetWaferHistoryRecipe(string id);
- [OperationContract]
- List<WaferHistoryWafer> GetWaferHistoryWafers(string id);
- [OperationContract]
- List<WaferHistoryRecipe> GetWaferHistoryRecipes(string id);
- [OperationContract]
- List<WaferHistoryMovement> GetWaferHistoryMovements(string id);
- [OperationContract]
- List<WaferHistorySecquence> GetWaferHistorySecquences(string id);
- [OperationContract]
- List<WaferHistoryLot> QueryWaferHistoryLotsBySql(string sql);
- [OperationContract]
- List<WaferHistoryLot> GetWaferHistoryLots(DateTime startTime, DateTime endTime, string keyWord);
- [OperationContract]
- string GetTypedConfigContent(string type, string contentPath);
- [OperationContract]
- void SetTypedConfigContent(string type, string contentPath, string content);
- [OperationContract]
- List<string> GetExpertLayoutRecipeContent(string chamberId, string recipeFile);
- [OperationContract]
- List<string> GetLayoutRecipeContent(/*string chamberId, */string recipeFile, string slotCount, string cassetteSlotCount);
- [OperationContract]
- List<string> GetLayoutExpertRecipeContent(/*string chamberId, */string recipeFile, string slotCount, string cassetteSlotCount);
- [OperationContract]
- string GetInterlockConfigContent();
- [OperationContract]
- string GetInterlockUserDefineConfigContent();
- [OperationContract]
- void SetInterlockConfigContent(string content);
- [OperationContract]
- List<RecipeHistory> QueryByRecipePathHistory(string RecipePath, int row = 20);
- [OperationContract]
- bool ClearByRecipePathHistory(string RecipePath);
- [OperationContract]
- string GetFileXmlContent(string fileName, string diretory = "GasXml");
- }
|