diff --git a/IOB-WIN/IobOmron.cs b/IOB-WIN/IobOmron.cs index 12b65488..4b53cf50 100644 --- a/IOB-WIN/IobOmron.cs +++ b/IOB-WIN/IobOmron.cs @@ -118,25 +118,6 @@ namespace IOB_WIN int.TryParse(fullVal, out answ); return answ; } -#if false - /// - /// Converte un valore intero in 2 short che il PLC riporterà ad HEX x visualizzare: - /// es: legge delle coppie di valori INT, vanno trasformati in HEX e POI accodati, dove il primo è x 1 e il secondo x 10000 (in pratica va in testa) - /// 12540 --> diviso in 1 | 2540 --> in HEX diventa 1 | 9472, ma il 9472 va su byte[0] e 1 su byte[1] - /// - /// - /// - private short[] convToHex(int valoreInt) - { - short[] answ = new short[2]; - string fullVal = valoreInt.ToString("D8"); - // converto un pezzo alla volta... - answ[0] = (short)convHD(fullVal.Substring(4, 4)); - answ[1] = (short)convHD(fullVal.Substring(0, 4)); - return answ; - } -#endif - /// /// estende l'init della classe base... /// @@ -508,65 +489,7 @@ namespace IOB_WIN #endif } } - /// - /// Lettura e log valori x debug - /// - private void readAndLog() - { -#if false - short[] response1; - short[] response2; - short bit1; - short bit2; - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 20, 2, out response1); - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 22, 2, out response2); - // legge delle coppie di valori INT, vanno trasformati in HEX e POI accodati, dove il primo è x 1 e il secondo x 10000 (in pratica va in testa) - // esempio 12540 --> diviso in 1 | 2540 --> in HEX diventa 1 | 9472, ma il 9472 va su byte[0] e 1 su byte[1] - -#endif - - - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.CIO, 0, 8, out memReadCIO_IN); - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.CIO, 100, 8, out memReadCIO_OUT); - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 0, 8, out memReadDM); - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.WR, 0, 8, out memReadWR); - - lgInfo("Effettuata lettura dati CIO"); - foreach (var item in memReadCIO_IN) - { - lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); - } - lgInfo("Effettuata lettura dati DM"); - foreach (var item in memReadDM) - { - lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); - } - lgInfo("Effettuata lettura dati WR"); - foreach (var item in memReadWR) - { - lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); - } - - - - short[] respDM20; - short[] respDM22; - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 20, 2, out respDM20); - OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 22, 2, out respDM22); - // legge delle coppie di valori INT, vanno trasformati in HEX e POI accodati, dove il primo è x 1 e il secondo x 10000 (in pratica va in testa) - lgInfo("Effettuata lettura dati respDM20"); - foreach (var item in respDM20) - { - lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); - } - lgInfo("Effettuata lettura dati respDM22"); - foreach (var item in respDM22) - { - lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); - } - - } /// /// Effettua lettura semafori principale /// Parametri da aggiornare x display in form @@ -769,16 +692,14 @@ namespace IOB_WIN { // valore non presente in vers default... se gestito fare override Dictionary outVal = new Dictionary(); - outVal.Add("PESO_RILEVATO", pesoRilevato.ToString()); - outVal.Add("PESO_RICHIESTO", pesoRichiesto.ToString()); - - // leggo e scrivo LOG... !!!FIXME!!! poi togliere - readAndLog(); - + outVal.Add("kgAct", pesoRilevato.ToString()); + outVal.Add("kgImp", pesoRichiesto.ToString()); return outVal; } - - + /// + /// OVerride metodo x scrittura parametri su PLC + /// + /// protected override void plcWriteParams(List updatedPar) { int valInt = 0; @@ -811,6 +732,11 @@ namespace IOB_WIN } } + + #endregion + + #region metodi testing *non usati( + /// /// Test completo funzioni OMRON /// @@ -828,6 +754,51 @@ namespace IOB_WIN // scrivo DM 52-53 del lotto richiesto quantitaLotto = 66666; + } + /// + /// Lettura e log valori x debug + /// + private void readAndLog() + { + OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.CIO, 0, 8, out memReadCIO_IN); + OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.CIO, 100, 8, out memReadCIO_OUT); + OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 0, 8, out memReadDM); + OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.WR, 0, 8, out memReadWR); + + lgInfo("Effettuata lettura dati CIO"); + foreach (var item in memReadCIO_IN) + { + lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); + } + lgInfo("Effettuata lettura dati DM"); + foreach (var item in memReadDM) + { + lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); + } + lgInfo("Effettuata lettura dati WR"); + foreach (var item in memReadWR) + { + lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); + } + + + + short[] respDM20; + short[] respDM22; + OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 20, 2, out respDM20); + OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 22, 2, out respDM22); + // legge delle coppie di valori INT, vanno trasformati in HEX e POI accodati, dove il primo è x 1 e il secondo x 10000 (in pratica va in testa) + lgInfo("Effettuata lettura dati respDM20"); + foreach (var item in respDM20) + { + lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); + } + lgInfo("Effettuata lettura dati respDM22"); + foreach (var item in respDM22) + { + lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}"); + } + } #endregion