|
@@ -101,7 +101,7 @@ namespace MECF.Framework.Common.Device.Festo
|
|
|
item.DataIndex = index;
|
|
|
_doFestoNameDictionary[item.Name] = deviceConfig.Name;
|
|
|
_doDictionary[item.Name]= item;
|
|
|
- _doIndexDictionary[$"{item.DataIndex}-{item.Bit}"] = item.Name;
|
|
|
+ _doIndexDictionary[$"{deviceConfig.Name}-{item.DataIndex}-{item.Bit}"] = item.Name;
|
|
|
if (!lst.Contains(item.Name))
|
|
|
{
|
|
|
lst.Add(item.Name);
|
|
@@ -201,48 +201,48 @@ namespace MECF.Framework.Common.Device.Festo
|
|
|
/// <summary>
|
|
|
/// 更新Festo数组
|
|
|
/// </summary>
|
|
|
- /// <param name="name"></param>
|
|
|
+ /// <param name="festoName"></param>
|
|
|
/// <param name="datas"></param>
|
|
|
- public void UpdateFestoData(string name, byte[] datas)
|
|
|
+ public void UpdateFestoData(string festoName, byte[] datas)
|
|
|
{
|
|
|
- if (!_nameDataLengthDictionary.ContainsKey(name))
|
|
|
+ if (!_nameDataLengthDictionary.ContainsKey(festoName))
|
|
|
{
|
|
|
- LOG.WriteLog(eEvent.ERR_FESTO, "Festo", $"festo device {name} is invalid");
|
|
|
+ LOG.WriteLog(eEvent.ERR_FESTO, "Festo", $"festo device {festoName} is invalid");
|
|
|
return;
|
|
|
}
|
|
|
- int dataLength = _nameDataLengthDictionary[name];
|
|
|
+ int dataLength = _nameDataLengthDictionary[festoName];
|
|
|
byte[] bytes = null;
|
|
|
- if (!_nameDatasDictionary.ContainsKey(name))
|
|
|
+ if (!_nameDatasDictionary.ContainsKey(festoName))
|
|
|
{
|
|
|
bytes = new byte[dataLength];
|
|
|
- FirstUpdateDatas(datas);
|
|
|
+ FirstUpdateDatas(festoName,datas);
|
|
|
Array.Copy(datas,0,bytes,0,dataLength);
|
|
|
- _nameDatasDictionary[name] = bytes;
|
|
|
+ _nameDatasDictionary[festoName] = bytes;
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- bytes=_nameDatasDictionary[name];
|
|
|
+ bytes=_nameDatasDictionary[festoName];
|
|
|
}
|
|
|
if (bytes.Length != datas.Length)
|
|
|
{
|
|
|
- LOG.WriteLog(eEvent.ERR_FESTO, "Festo", $"festo device {name} array source data length {bytes.Length} is not equal to {datas.Length}");
|
|
|
+ LOG.WriteLog(eEvent.ERR_FESTO, "Festo", $"festo device {festoName} array source data length {bytes.Length} is not equal to {datas.Length}");
|
|
|
return;
|
|
|
}
|
|
|
- CheckSourceDataUpdated(bytes, datas);
|
|
|
+ CheckSourceDataUpdated(festoName,bytes, datas);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 首次更新数据
|
|
|
/// </summary>
|
|
|
/// <param name="datas"></param>
|
|
|
- private void FirstUpdateDatas(byte[] datas)
|
|
|
+ private void FirstUpdateDatas(string festoName,byte[] datas)
|
|
|
{
|
|
|
for (int i = 0; i < datas.Length; i++)
|
|
|
{
|
|
|
bool[] sourceBits = GetByteBitValue(datas[i]);
|
|
|
for(int j = 0; j < sourceBits.Length; j++)
|
|
|
{
|
|
|
- UpdateIOBitValue(i, j, sourceBits[j]);
|
|
|
+ UpdateIOBitValue(festoName,i, j, sourceBits[j]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -251,7 +251,7 @@ namespace MECF.Framework.Common.Device.Festo
|
|
|
/// </summary>
|
|
|
/// <param name="source"></param>
|
|
|
/// <param name="datas"></param>
|
|
|
- private void CheckSourceDataUpdated(byte[] sourceDatas, byte[] datas)
|
|
|
+ private void CheckSourceDataUpdated(string festoName,byte[] sourceDatas, byte[] datas)
|
|
|
{
|
|
|
for (int i = 0; i < datas.Length; i++)
|
|
|
{
|
|
@@ -259,7 +259,7 @@ namespace MECF.Framework.Common.Device.Festo
|
|
|
byte source=sourceDatas[i];
|
|
|
if (data != source)
|
|
|
{
|
|
|
- CheckSourceDOUpdated(source, data,i);
|
|
|
+ CheckSourceDOUpdated(festoName,source, data,i);
|
|
|
sourceDatas[i] = data;
|
|
|
}
|
|
|
}
|
|
@@ -269,7 +269,7 @@ namespace MECF.Framework.Common.Device.Festo
|
|
|
/// </summary>
|
|
|
/// <param name="source"></param>
|
|
|
/// <param name="data"></param>
|
|
|
- private void CheckSourceDOUpdated(byte source,byte data,int index)
|
|
|
+ private void CheckSourceDOUpdated(string festoName,byte source,byte data,int index)
|
|
|
{
|
|
|
bool[] sourceBits=GetByteBitValue(source);
|
|
|
bool[] dataBits=GetByteBitValue(data);
|
|
@@ -279,7 +279,7 @@ namespace MECF.Framework.Common.Device.Festo
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
- UpdateIOBitValue(index, i, dataBits[i]);
|
|
|
+ UpdateIOBitValue(festoName,index, i, dataBits[i]);
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -288,9 +288,9 @@ namespace MECF.Framework.Common.Device.Festo
|
|
|
/// <param name="index"></param>
|
|
|
/// <param name="bit"></param>
|
|
|
/// <param name="value"></param>
|
|
|
- private void UpdateIOBitValue(int index,int bit,bool value)
|
|
|
+ private void UpdateIOBitValue(string festoName,int index,int bit,bool value)
|
|
|
{
|
|
|
- string strIndex = $"{index}-{bit}";
|
|
|
+ string strIndex = $"{festoName}-{index}-{bit}";
|
|
|
if (!_doIndexDictionary.ContainsKey(strIndex))
|
|
|
{
|
|
|
return;
|