modifiche FANUC preliminari x gestire CMZ

This commit is contained in:
Samuele E. Locatelli
2018-04-05 11:08:55 +02:00
parent 6c8105ca32
commit 6a9de8c943
+88 -42
View File
@@ -205,22 +205,48 @@ namespace IOB_WIN
parentForm.sIN = Semaforo.SV;
// leggo SEMAFORI, leggo da Y8 ...leggo 3 bit in Y8..Y10 HARD CODED, rendere parametrico!!!
byte[] MemBlock = new byte[4];
// Red: Y8.4 | Yellow: Y8.5 | Green Y8.6 | WrkZone Y8.7 | All DoorsClosed: Y10.5
int memIndex = 8;
inizio = DateTime.Now;
FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlock);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-Y", MemBlock.Length), DateTime.Now.Subtract(inizio).Ticks);
// riporto!
Buffer.BlockCopy(MemBlock, 0, RawInput, 0, 4);
// ora mi leggo 2 byte in area X... HARD CODED, rendere parametrico...
MemBlock = new byte[2];
// GESTIONE memoria endcycle
// la variabile X7.0 (da 1 a 0) oppure la X7.1 (da 0 a 1) indica il CONTAPEZZI --> copio 2 byte!
inizio = DateTime.Now;
FanucMemRW(R, FANUC.MemType.X, 6, ref MemBlock);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-X", MemBlockF.Length), DateTime.Now.Subtract(inizio).Ticks);
// da rivedere: cambio come leggo i dati hard coded in base al modello, RENDERE CMQ PARAMETRICO!!!
if (currIobConf.vendor == "TORNOS" && currIobConf.model == "DT26")
{
// Red: Y8.4 | Yellow: Y8.5 | Green Y8.6 | WrkZone Y8.7 | All DoorsClosed: Y10.5
int memIndex = 8;
inizio = DateTime.Now;
FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlock);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-Y", MemBlock.Length), DateTime.Now.Subtract(inizio).Ticks);
// riporto!
Buffer.BlockCopy(MemBlock, 0, RawInput, 0, 4);
// ora mi leggo 2 byte in area X... HARD CODED, rendere parametrico...
MemBlock = new byte[2];
// GESTIONE memoria endcycle
// la variabile X7.0 (da 1 a 0) oppure la X7.1 (da 0 a 1) indica il CONTAPEZZI --> copio 2 byte!
inizio = DateTime.Now;
FanucMemRW(R, FANUC.MemType.X, 6, ref MemBlock);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-X", MemBlockF.Length), DateTime.Now.Subtract(inizio).Ticks);
}
else if (currIobConf.vendor == "CMZ" && currIobConf.model == "TA20")// caso CMZ
{
// Red: Y3.7 | Yellow: Y3.6 | Green Y3.5 | All DoorsClosed: Y5.1 | ..........WrkZone Y8.7
int memIndex = 3;
inizio = DateTime.Now;
FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlock);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-Y", MemBlock.Length), DateTime.Now.Subtract(inizio).Ticks);
// riporto!
Buffer.BlockCopy(MemBlock, 0, RawInput, 0, 4);
#if false
// ora mi leggo 2 byte in area X... HARD CODED, rendere parametrico...
MemBlock = new byte[2];
// GESTIONE memoria endcycle
// la variabile X7.0 (da 1 a 0) oppure la X7.1 (da 0 a 1) indica il CONTAPEZZI --> copio 2 byte!
inizio = DateTime.Now;
FanucMemRW(R, FANUC.MemType.X, 6, ref MemBlock);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-X", MemBlockF.Length), DateTime.Now.Subtract(inizio).Ticks);
#endif
}
// riporto!
Buffer.BlockCopy(MemBlock, 0, RawInput, 4, 2);
// log
if (verboseLog) lg.Info(string.Format("RawInput: {0}", utils.binaryForm((int)RawInput[0])));
// salvo il solo BYTE dell'input decifrando il semaforo...
decodeToBitmap();
@@ -240,42 +266,62 @@ namespace IOB_WIN
int byteCount = RawInput[5];
if (verboseLog) lg.Info(string.Format("PrimoByte: {0}", byteSem));
if (utils.CRB("macOnFromConn"))
// SE SI E' CONNESSO al FANUC allora è 1...
if (FANUC_ref.Connected)
{
// SE SI E' CONNESSO al FANUC allora è 1...
if (FANUC_ref.Connected)
B_input += 1 << 0;
}
// da rivedere: cambio come leggo i dati hard coded in base al modello, RENDERE CMQ PARAMETRICO!!!
if (currIobConf.vendor == "TORNOS" && currIobConf.model == "DT26")
{
// B1: verde! Y8.6
if ((byteSem & 64) > 0)
{
B_input += 1 << 0;
B_input += 1 << 1;
}
// B2: contapezzi da area X
if ((byteCount & 2) > 0)
{
B_input += 1 << 2;
}
// B3: Rosso! Y8.4
if ((byteSem & 16) > 0)
{
B_input += 1 << 3;
}
// B4: giallo! Y8.5
if ((byteSem & 32) > 0)
{
B_input += 1 << 4;
}
}
else
else if (currIobConf.vendor == "CMZ" && currIobConf.model == "TA20")// caso CMZ
{
// B0: facio un OR tra i 3 semafori...
if ((byteSem & 112) > 0)
// B1: verde! Y3.5 (era Y8.6)
if ((byteSem & 32) > 0)
{
B_input += 1 << 0;
B_input += 1 << 1;
}
// FARE da lettura parametro 6711...
//// B2: contapezzi da area X
//if ((byteCount & 2) > 0)
//{
// B_input += 1 << 2;
//}
// B3: Rosso! Y3.7 (era Y8.4)
if ((byteSem & 128) > 0)
{
B_input += 1 << 3;
}
// B4: giallo! Y3.6 (era Y8.5)
if ((byteSem & 64) > 0)
{
B_input += 1 << 4;
}
}
// B1: verde! Y8.6
if ((byteSem & 64) > 0)
{
B_input += 1 << 1;
}
// B2: contapezzi da area X
if ((byteCount & 2) > 0)
{
B_input += 1 << 2;
}
// B3: Rosso! Y8.4
if ((byteSem & 16) > 0)
{
B_input += 1 << 3;
}
// B4: giallo! Y8.5
if ((byteSem & 32) > 0)
{
B_input += 1 << 4;
}
// log opzionale!
if (verboseLog) lg.Info(string.Format("Trasformazione B_input: {0}", B_input));
}