Oracle DB: In the vt_zaehler_pindex_pd.korrimprate should be new CalibFactor, not OrigCalibFactor (Joern Goegge)
62 lines
2.4 KiB
C#
62 lines
2.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
|
{
|
|
internal class SimulationServices
|
|
{
|
|
const int Q2CorrFactorsAddr = 0x1878;
|
|
|
|
internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
|
{
|
|
byte[] configurationBuffer = new byte[ConfigStruct.Length] { 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
byte[] calibrationBuffer = new byte[CalibrationStructV4.Length] { 3, 0, 150, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 150, 10 };
|
|
buffer = new byte[length];
|
|
|
|
if (messageID == MessageID.Configuration)
|
|
{
|
|
Array.Copy(GetPCB(iperlHead), 0, configurationBuffer, 16, 5); // set PCB Number according to iPerlHead configuration
|
|
Array.Copy(configurationBuffer,offset,buffer,0,length);
|
|
}
|
|
else if (messageID == MessageID.Calibration)
|
|
{
|
|
Array.Copy(calibrationBuffer, offset, buffer, 0, length);
|
|
}
|
|
else if ((messageID == MessageID.MetrologyMemory) && (offset == Q2CorrFactorsAddr) && (length == 2))
|
|
{
|
|
buffer = new byte[2] { 0, 0 };
|
|
}
|
|
else
|
|
{
|
|
buffer = new byte[length];
|
|
}
|
|
|
|
return iperlHead.Name.Equals("iPerl13") ? 2 : 0; /// Simulates an error on position 13
|
|
}
|
|
|
|
internal static int WriteRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, byte[] buffer)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
private static Array GetPCB(IperlHead iperlHead)
|
|
{
|
|
string pcbStr = iperlHead.RfidComPortNr.ToString().PadRight(10,'0') + iperlHead.Position.ToString("D2");
|
|
long decVal = Convert.ToInt64(pcbStr);
|
|
string nHexStr = decVal.ToString("X4");
|
|
|
|
string hexStr = "";
|
|
for (int a = nHexStr.Length; a >= 1; a = a - 2)
|
|
{
|
|
hexStr = hexStr + nHexStr.Substring(a - 2, 2);
|
|
}
|
|
|
|
return Enumerable.Range(0, hexStr.Length)
|
|
.Where(x => x % 2 == 0)
|
|
.Select(x => Convert.ToByte(hexStr.Substring(x, 2), 16))
|
|
.ToArray();
|
|
|
|
}
|
|
}
|
|
}
|