diff --git a/IOB-WIN/IOB-WIN.csproj b/IOB-WIN/IOB-WIN.csproj
index a5b8160b..52a48b49 100644
--- a/IOB-WIN/IOB-WIN.csproj
+++ b/IOB-WIN/IOB-WIN.csproj
@@ -272,7 +272,9 @@
False
-
+
+
+
diff --git a/IOB-WIN/IobKawasaki.cs b/IOB-WIN/IobKawasaki.cs
index 4a5b69e8..c8174ef4 100644
--- a/IOB-WIN/IobKawasaki.cs
+++ b/IOB-WIN/IobKawasaki.cs
@@ -18,6 +18,10 @@ namespace IOB_WIN
/// Array delle risposte dal controllo KAWASAKI
///
protected System.Collections.ArrayList resDataArray;
+ ///
+ /// Comando inviato al robot
+ ///
+ protected string comando;
#if false
@@ -78,7 +82,7 @@ namespace IOB_WIN
///
public IobKawasaki(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
{
-
+ // faccio un try-catch di test vari...
try
{
KAWASAKI_ref = new KRcc.Commu("TCP 192.168.0.92");
@@ -87,66 +91,49 @@ namespace IOB_WIN
// connect ok
resDataArray = KAWASAKI_ref.command("where", 3000); // WHERE [RET]
Console.WriteLine(resDataArray[0]);
-
+ }
+ if (KAWASAKI_ref.IsConnected)
+ {
resDataArray = KAWASAKI_ref.command("TYPE TASK (1004)", 3000); // thread 4 ok --> " 1\r\n"
-
+ }
+ if (KAWASAKI_ref.IsConnected)
+ {
resDataArray = KAWASAKI_ref.command("TYPE $id_true", 3000); // id macchina --> "BX100N-B001 Sn. 2366\r\n"
-
+ }
+ if (KAWASAKI_ref.IsConnected)
+ {
resDataArray = KAWASAKI_ref.command("TYPE $status", 3000); // status --> "0|0|1|0|0|1|0|0\r\n"
resDataArray = KAWASAKI_ref.command("TYPE $signal", 3000); // segnali --> "1|0|1|1|1|0|0|0\r\n"
-
+ }
+ if (KAWASAKI_ref.IsConnected)
+ {
resDataArray = KAWASAKI_ref.command("TYPE i_prelevati", 3000); // num pz prelevati --> "0\r\n"
resDataArray = KAWASAKI_ref.command("TYPE i_cicli", 3000); // num cicli depositati/fatti --> " 0\r\n"
resDataArray = KAWASAKI_ref.command("TYPE r_tempo", 3000); // ultimo TCiclo rilevato --> " 349.19\r\n"
-
- resDataArray = KAWASAKI_ref.command("TYPE $exe", 3000); // missione --> "\r\n" (vuoto, no missione)
-
-
- // scrivo valore cicli
- resDataArray = KAWASAKI_ref.command("i_cicli=3", 3000); // imposto cicli depositati/fatti a 3 --> " 0\r\n"
-
- resDataArray = KAWASAKI_ref.command("TYPE i_cicli", 3000); // num cicli depositati/fatti --> " 0\r\n"
-
-
- // comandi x setup programma...
-
- resDataArray = KAWASAKI_ref.command("ferma", 3000); // ferma processi (all) --> ""
-
- resDataArray = KAWASAKI_ref.command("togli", 3000); // toglie processi da pronta esecuzione --> ""
-
- //resp = com.command("SAVE nome_del_file", 3000); // salvataggio file... FORSE --> "\u0005\u0002Bnome_del_file.as\u0017" --> verificare DOVE salva...
-
-
- int ret = KAWASAKI_ref.save("foo_02.as"); // SAVE foo.as[RET]
- if (ret == 0)
- { // Success
- }
- if (ret == -1)
- { // Communication error
- }
- if (ret == -2)
- { // Robot Controller error
- }
- if (ret == -3)
- { // Internal error
- }
-
- // carico...
- KAWASAKI_ref.asInquiry = delegate (string as_msg)
- {
- Console.WriteLine(as_msg); if (as_msg.StartsWith("Are you sure ?")) return "0\n"; // 0 [RET]
- if (as_msg.StartsWith("Load data?")) return "1\n"; // 1 [RET]
- return null;
- };
- int retLoad = KAWASAKI_ref.load("foo.as", "/Q"); // LOAD/Q foo.as[RET]
-
-
}
+ if (KAWASAKI_ref.IsConnected)
+ {
+ resDataArray = KAWASAKI_ref.command("TYPE $exe", 3000); // missione --> "\r\n" (vuoto, no missione)
+ }
+
+
+ // leggo i pezzi
+ int currCount = pzCounter;
+ // imposto a 100
+ pzCounter = 100;
+ // rileggo x verifica
+ int newCount = pzCounter;
+ // reimposto corretti
+ pzCounter = currCount;
+
+ //saveProgram("prog", "current");
+ saveProgram("prog", "default");
+ sendProgram("prog", "default");
}
catch (Exception e)
{ // e.Message = "can't connect TCP/IP" or // "can't login"
@@ -291,6 +278,93 @@ namespace IOB_WIN
lgInfo("End init Adapter FANUC");
#endif
}
+
+ private int pzCounter
+ {
+ get
+ {
+ int answ = 0;
+ if (KAWASAKI_ref.IsConnected)
+ {
+ resDataArray = KAWASAKI_ref.command("TYPE i_cicli", 3000); // num cicli depositati/fatti --> " 0\r\n"
+ int.TryParse(resDataArray[0].ToString().Replace("/n", "").Replace("/r", ""), out answ);
+ }
+ return answ;
+ }
+ set
+ {
+ if (KAWASAKI_ref.IsConnected)
+ {
+ comando = string.Format("i_cicli={0}", value);
+ // scrivo valore cicli
+ resDataArray = KAWASAKI_ref.command(comando, 3000); // imposto cicli depositati/fatti a 3 --> " 0\r\n"
+ }
+ }
+
+ }
+
+ ///
+ /// Effettua salvataggio del programma corrente
+ ///
+ /// Dir di riferimento
+ /// Nome Programma (se mancasse *.as lo aggiunge)
+ private void saveProgram(string progDir = "prog", string progName = "current.as")
+ {
+ // path completo
+ progName = progName.EndsWith(".as") ? progName : progName + ".as";
+ string prgPath = string.Format("{0}/{1}", progDir, progName);
+ if (KAWASAKI_ref.IsConnected)
+ {
+ // comandi x setup programma...
+ resDataArray = KAWASAKI_ref.command("ferma", 3000); // ferma processi (all) --> ""
+ resDataArray = KAWASAKI_ref.command("togli", 3000); // toglie processi da pronta esecuzione --> ""
+
+ //resp = com.command("SAVE nome_del_file", 3000); // salvataggio file... FORSE --> "\u0005\u0002Bnome_del_file.as\u0017" --> verificare DOVE salva...
+
+ int ret = KAWASAKI_ref.save(prgPath); // SAVE current.as[RET]
+ if (ret == 0)
+ {
+ // Success
+ }
+ if (ret == -1)
+ {
+ // Communication error
+ }
+ if (ret == -2)
+ {
+ // Robot Controller error
+ }
+ if (ret == -3)
+ {
+ // Internal error
+ }
+ }
+ }
+
+ ///
+ /// Effettua invio del programma di alvorazione al ROBOT
+ /// Dir di riferimento
+ /// Nome Programma (se mancasse *.as lo aggiunge)
+ ///
+ private void sendProgram(string progDir = "prog", string progName = "default.as")
+ {
+ // path completo
+ progName = progName.EndsWith(".as") ? progName : progName + ".as";
+ string prgPath = string.Format("{0}/{1}", progDir, progName);
+ if (KAWASAKI_ref.IsConnected)
+ {
+ // carico...
+ KAWASAKI_ref.asInquiry = delegate (string as_msg)
+ {
+ Console.WriteLine(as_msg); if (as_msg.StartsWith("Are you sure ?")) return "0\n"; // 0 [RET]
+ if (as_msg.StartsWith("Load data?")) return "1\n"; // 1 [RET]
+ return null;
+ };
+ int retLoad = KAWASAKI_ref.load(prgPath, "/Q"); // LOAD/Q default.as[RET]
+ }
+ }
+
+
#if false
///
/// Area memoria G (copia)