Compare commits

2 Commits

Author SHA1 Message Date
2e45a0562e Cambios en la Etiqueta.prn
Se agregaron dos nuevos valores: $v4 y $v5 para agregar un número de serie y la fecha de impresión.
Cambios en el modo debug para realizar pruebas de impresorea sin el sensor
2026-03-24 15:59:13 -06:00
7c8fcb16ae # Cambios en la etiqueta
Se agregaron dos variables nuevas para las etiquetas
$V4$ - Número consecutivo
$V5$ - Fecha/Hora de ejecución-impresión

Se agregó una condición para que el consecutivo se reinicie cada dia.

Se arreglaron algunos errores de compilación
2026-03-12 11:40:14 -06:00
9 changed files with 445 additions and 78 deletions

View File

@@ -49,7 +49,7 @@ namespace ScaBox30.Controller
#endregion #endregion
#region ZEBRA -> buildPrn() #region ZEBRA -> buildPrn()
public void buildPrn(String v1, String v2, String v3, String barcode) public void buildPrn(String v1, String v2, String v3, String v4, DateTime v5, String barcode)
{ {
try try
{ {
@@ -85,6 +85,16 @@ namespace ScaBox30.Controller
{ {
etiqueta += line.Replace("$V3$", v3); etiqueta += line.Replace("$V3$", v3);
} }
else if (line.Contains("$V4$"))
{
etiqueta += line.Replace("$V4$", v4.ToString()); //consecutivo
}
else if (line.Contains("$V5$"))
{
// Insertar fecha formateada en formato juliano (yyyyDDD)
int julianDay = v5.DayOfYear;
etiqueta += line.Replace("$V5$", $"{v5:yyyy}{julianDay:000}"); // yyyyDDD
}
else else
{ {
etiqueta += line; etiqueta += line;
@@ -94,7 +104,6 @@ namespace ScaBox30.Controller
} }
} }
#endregion #endregion

View File

@@ -0,0 +1,308 @@
# ?? Gu<47>a de Pruebas sin Sensor SR-X300W
## Estado Actual
? **La variable `Globals.debug = true` ya est<73> activada** en `Globals.cs`
## <20>C<EFBFBD>mo Funciona el Modo Debug?
### 1. **Flujo de Ejecuci<63>n con Debug Activado**
Cuando presionas el bot<6F>n **"Ejecutar Lectura"** (`TgrBtn_Click`):
```
???????????????????????????????????????????????????????????????
? Bot<6F>n "Ejecutar Lectura" ? TgrBtn_Click() ?
???????????????????????????????????????????????????????????????
?
?
???????????????????????????????????
? <20>Se encontr<74> sensor? (reader_found) ?
???????????????????????????????????
?
???????????????????????
? ?
S<> (real) NO (debug)
? ?
? ?
Conecta a ???????????????????????????
sensor real ? <20>Globals.debug = true? ?
Env<6E>a LON ???????????????????????????
? ?
? ???????????????
? ? ?
? S<> NO
? ? ?
? ? ?
? Usa datos (No hace nada)
? simulados
???????????????????????????
?
?
ReceivedDataWrite()
(Procesa datos igual que
si vinieran del sensor real)
```
### 2. **Datos de Prueba Disponibles**
En `Globals.cs` tienes definido:
```csharp
private static string codigo = "0037613825"; // 30 lentes
public static string testdata = codigo + ":001," +
codigo + ":002," +
codigo + ":003," +
// ... hasta
codigo + ":030";
```
**Esto significa:** Se simula una lectura de 30 lentes, todos con el c<>digo `0037613825`.
---
## ?? Pasos para Hacer Pruebas
### **Paso 1: Verificar que Debug est<73> Activado**
Abre `Globals.cs` y confirma:
```csharp
public static Boolean debug = true; // ? Debe estar en true
```
### **Paso 2: Aseg<65>rate que el Sensor NO se Encuentra**
Cuando inicies el programa:
- Si el sensor est<73> en la red, se conectar<61> autom<6F>ticamente
- Si el sensor NO est<73> disponible:
- La etiqueta `sr2000w_ip_lbl` mostrar<61> `0.0.0.0` en rojo
- El bot<6F>n "Ejecutar Lectura" estar<61> deshabilitado EN MODO AUTOM<4F>TICO
- ? **Esto es correcto para debug**
### **Paso 3: Cambiar a Modo Manual**
1. Haz clic en el bot<6F>n **"Cambiar Modo"**
2. Selecciona **"Manual"**
3. El bot<6F>n "Ejecutar Lectura" ahora se habilitar<61>
### **Paso 4: Ejecutar la Prueba**
1. Haz clic en **"Ejecutar Lectura"**
2. **En la consola de Visual Studio ver<65>s:**
```
Ejecutando: BLOAD,1 en la linea XXX
Ejecutando: LON en la linea XXX
```
3. El programa usar<61> `Globals.testdata` en lugar del sensor
### **Paso 5: Espera los Resultados**
En el textbox "Data" ver<65>s:
```
0037613825:001,0037613825:002,0037613825:003,...,0037613825:030
```
**Resultados esperados:**
- ? **30 lentes OK** (todos el mismo c<>digo)
- El contador mostrar<61>: **OK: 30, NOK: 0, Questionable: 0**
- Se guardar<61> en CSV (si aplica)
- Se imprimir<69> en la etiqueta (si la impresora est<73> habilitada)
---
## ?? C<>mo Modificar los Datos de Prueba
### **Cambiar el C<>digo de Prueba**
En `Globals.cs`, busca esta l<>nea:
```csharp
private static string codigo = "0037613825"; // 30 lentes
```
C<EFBFBD>mbialo al c<>digo que desees probar:
```csharp
private static string codigo = "0123456789"; // Tu c<>digo
```
### **Cambiar la Cantidad de Lentes**
Actualmente simula 30 lentes (posiciones 001 a 030).
Para cambiar a 45 lentes, modifica:
```csharp
public static string testdata = codigo + ":001," +
codigo + ":002," +
// ... agrega m<>s l<>neas hasta :045
codigo + ":045";
```
### **Simular Errores (C<>digos Incorrectos)**
Para probar c<>mo reacciona el programa ante c<>digos incorrectos:
```csharp
public static string testdata = codigo + ":001," +
codigo + ":002," +
// ...
"0199170978" + ":015," + // ?? C<>digo diferente en posici<63>n 15
// ...
codigo + ":030";
```
**Resultado esperado:**
- OK: 29, NOK: 1
- El programa mostrar<61> **"X"** en la posici<63>n 15 con fondo rojo
### **Simular Lectura con Error**
```csharp
public static string testdata = "ERROR," + // Fuerza un error
codigo + ":001," +
// ... resto de datos
```
**Resultado esperado:**
- OK: 29, NOK: 0, Questionable: 1
---
## ?? Monitorizar Ejecuci<63>n
### **Ver Mensajes en Consola**
En Visual Studio:
1. **Debug ? Windows ? Output** (o `Ctrl + Alt + O`)
2. Ver<65>s todos los comandos ejecutados:
```
[TCP] Conectando a 192.168.100.100:9004...
ERROR: IpAddress no configurada (esperado en modo debug)
Ejecutando: BLOAD,1 en la linea 456
Ejecutando: LON en la linea 458
```
### **Ver Datos Procesados**
En el textbox etiquetado **"Data"** (arriba a la izquierda):
- Muestra los datos recibidos en bruto
- Se actualiza autom<6F>ticamente
### **Ver Resultados**
Los contadores en la pantalla:
- **OK:** Lentes que coinciden con el c<>digo master
- **NOK:** Lentes con c<>digo incorrecto
- **Questionable:** Lecturas con error
---
## ?? Flujo Completo de Prueba
```
1. Inicia ScanBox
?? Busca sensor en la red
?? No lo encuentra ? sr2000w_ip_lbl = 0.0.0.0 (rojo)
2. Cambias a "Modo Manual"
?? Bot<6F>n "Ejecutar Lectura" se habilita
3. Haces clic en "Ejecutar Lectura"
?? Verifica reader_found = false
?? Entra al bloque: if (Globals.debug)
?? Llama: ReceivedDataWrite(Globals.testdata)
4. ReceivedDataWrite procesa testdata
?? Divide por comas
?? Extrae c<>digo y posici<63>n
?? Compara con "master code"
?? Marca OK o NOK
5. Actualiza pantalla
?? Muestra contadores
?? Dibuja etiquetas (OK en verde, X en rojo)
?? Guarda en CSV si aplica
?? Imprime etiqueta si est<73> habilitado
6. El programa est<73> listo para otra lectura
```
---
## ?? Notas Importantes
1. **Debug solo funciona sin sensor:**
- Si conectas un sensor real, el programa lo usar<61>
- Para forzar debug, comenta la b<>squeda de sensores
2. **El c<>digo debe existir en la base de datos:**
- Si el c<>digo en `testdata` no est<73> en `data.json`, mostrar<61> error
- Verifica que `0037613825` exista en tu `data.json`
3. **La cantidad de lentes debe coincidir con la configuraci<63>n:**
- En `App.config`: `program1_OPCcodes = 1` (para 1 lente)
- Si `testdata` tiene 30 lentes, necesita un programa con 30+ lentes
4. **Cada lectura limpia los datos:**
- El textbox "Data" se borra despu<70>s de 5 segundos (configurable)
- Los contadores se reinician
---
## ?? Ejemplo Pr<50>ctico
### **Escenario: Probar con 3 c<>digos incorrectos en 30**
Modificar `Globals.cs`:
```csharp
private static string codigo = "0037613825";
public static string testdata = codigo + ":001," +
codigo + ":002," +
codigo + ":003," +
"9999999999" + ":004," + // ? C<>digo incorrecto
codigo + ":005," +
codigo + ":006," +
"1111111111" + ":007," + // ? C<>digo incorrecto
codigo + ":008," +
// ... m<>s l<>neas ...
"2222222222" + ":030"; // ? C<>digo incorrecto
```
**Resultado esperado:**
- OK: 27
- NOK: 3
- Fondo rojo ? "Uno o m<>s c<>digos son incorrectos"
- Opci<63>n para repetir o guardar
---
## ?? Casos de Prueba Recomendados
| Caso | Modificaci<63>n en testdata | Resultado Esperado |
|------|--------------------------|-------------------|
| **OK Completo** | Todos con mismo c<>digo | OK: 30, NOK: 0, Questionable: 0 |
| **Parcial OK** | 15 OK, 15 NOK | OK: 15, NOK: 15, Questionable: 0 |
| **Con Error** | Agregar "ERROR," | OK: 29, NOK: 0, Questionable: 1 |
| **C<>digo Incorrecto** | Cambiar c<>digo en posici<63>n 15 | OK: 29, NOK: 1, Questionable: 0 |
| **Caja Vac<61>a** | "ERROR," solo | OK: 0, NOK: 0, Questionable: 1 |
---
## ? Checklist para Empezar
- [ ] Verificar `Globals.debug = true`
- [ ] Verificar que el sensor NO est<73> disponible
- [ ] Verificar que el c<>digo en `testdata` existe en `data.json`
- [ ] Cambiar a "Modo Manual"
- [ ] Hacer clic en "Ejecutar Lectura"
- [ ] Ver resultados en pantalla
- [ ] Revisar la consola de Visual Studio para detalles
---
**<EFBFBD>Ya tienes todo lo necesario para hacer pruebas sin sensor!** ??

View File

@@ -19,9 +19,11 @@ namespace ScaBox30
public static List<User> users = new List<User>(); public static List<User> users = new List<User>();
public static List<Config> config = new List<Config>(); public static List<Config> config = new List<Config>();
public static Boolean valid_user = false; public static Boolean valid_user = false;
public static Boolean debug = false; public static Boolean debug = true;
public static Boolean boxcapacity = false; public static Boolean boxcapacity = false;
public static Config cfg = new Config(); public static Config cfg = new Config();
public static int consec = 1;
public static DateTime consecDate = DateTime.MinValue;
//Fields //Fields
@@ -61,7 +63,7 @@ namespace ScaBox30
//0037614674:001:26/583,0037614674:002:182/471,0037614674:003:281/474,0037614674:004:383/466,0037614674:005:487/463,0037614674:006:593/464,0037614674:007:695/461,0037614674:008:806/464,0037614674:009:913/476,0037614674:010:1021/479,0037614674:011:1136/487,0037614674:012:1231/486,0037614674:013:1337/484,0037614674:014:1441/489,0037614674:015:1545/482,0037614674:016:1653/488,0037614674:017:109/739,0037614674:018:440/731,0037614674:019:794/742,0037614674:020:1152/750,0037614674:021:1499/755,0037614674:022:51/1050,0037614674:023:201/948,0037614674:024:297/952,0037614674:025:402/954,0037614674:026:503/950,0037614674:027:605/957,0037614674:028:711/949,0037614674:029:817/955,0037614674:030:922/957,0037614674:031:1023/955,0037614674:032:1129/952,0037614674:033:1236/956,0037614674:034:1337/957,0037614674:035:1442/955,0037614674:036:1542/958,0037614674:037:1645/962,0037614674:038:1787/372,0037614674:039:1796/479,0037614674:040:1806/591,0037614674:041:1847/689,0037614674:042:1849/791,0037614674:043:1798/905,0037614674:044:1786/1018,0037614674:045:1784/1129 //0037614674:001:26/583,0037614674:002:182/471,0037614674:003:281/474,0037614674:004:383/466,0037614674:005:487/463,0037614674:006:593/464,0037614674:007:695/461,0037614674:008:806/464,0037614674:009:913/476,0037614674:010:1021/479,0037614674:011:1136/487,0037614674:012:1231/486,0037614674:013:1337/484,0037614674:014:1441/489,0037614674:015:1545/482,0037614674:016:1653/488,0037614674:017:109/739,0037614674:018:440/731,0037614674:019:794/742,0037614674:020:1152/750,0037614674:021:1499/755,0037614674:022:51/1050,0037614674:023:201/948,0037614674:024:297/952,0037614674:025:402/954,0037614674:026:503/950,0037614674:027:605/957,0037614674:028:711/949,0037614674:029:817/955,0037614674:030:922/957,0037614674:031:1023/955,0037614674:032:1129/952,0037614674:033:1236/956,0037614674:034:1337/957,0037614674:035:1442/955,0037614674:036:1542/958,0037614674:037:1645/962,0037614674:038:1787/372,0037614674:039:1796/479,0037614674:040:1806/591,0037614674:041:1847/689,0037614674:042:1849/791,0037614674:043:1798/905,0037614674:044:1786/1018,0037614674:045:1784/1129
/*public static string testdata = codigo + ":001:1138/525," + public static string testdata = codigo + ":001:1138/525," +
codigo + ":002:1138/525," + codigo + ":002:1138/525," +
codigo + ":003:1138/525," + codigo + ":003:1138/525," +
codigo + ":004:1138/525," + codigo + ":004:1138/525," +
@@ -107,9 +109,9 @@ namespace ScaBox30
codigo + ":042:1138/525," + codigo + ":042:1138/525," +
codigo + ":043:1138/525," + codigo + ":043:1138/525," +
//codigo + ":044:1138/525," + //codigo + ":044:1138/525," +
codigo + ":045:1138/525";*/ codigo + ":045:1138/525";
public static string testdata = codigo + ":001," + /* public static string testdata = codigo + ":001," +
codigo + ":002," + codigo + ":002," +
codigo + ":003," + codigo + ":003," +
codigo + ":004," + codigo + ":004," +
@@ -139,7 +141,8 @@ namespace ScaBox30
codigo + ":028," + codigo + ":028," +
codigo + ":029," + codigo + ":029," +
codigo + ":030"; codigo + ":030";
//"0199170978" + ":030"; //"0199170978" + ":030";
//"ERROR"; //"ERROR";
*/
} }
} }

View File

@@ -1,4 +1,4 @@
//using Keyence.AutoID.SDK; //using Keyence.AutoID.SDK;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
@@ -158,7 +158,7 @@ namespace ScaBox30
m_searcher.Start((res) => m_searcher.Start((res) =>
{ {
//Define searched actions here.Defined actions work asynchronously. //Defines searched actions here.Defined actions work asynchronously.
//"SearchListUp" works when a reader was searched. //"SearchListUp" works when a reader was searched.
BeginInvoke(new delegateUserControl(SearchListUp), res.IpAddress); BeginInvoke(new delegateUserControl(SearchListUp), res.IpAddress);
}); });
@@ -188,6 +188,9 @@ namespace ScaBox30
// CARGA DE CONFIGURACIONES // CARGA DE CONFIGURACIONES
LoadConfigJson(Globals.config_json); LoadConfigJson(Globals.config_json);
// Initialize daily consecutive date to today to avoid unexpected reset on first print
Globals.consecDate = DateTime.Today;
if (Globals.cfg.printerenabled) if (Globals.cfg.printerenabled)
{ {
btnPrinter.ForeColor = Color.White; btnPrinter.ForeColor = Color.White;
@@ -344,14 +347,14 @@ namespace ScaBox30
if (received_data_package != "") if (received_data_package != "")
{ {
// En la exploración obtenemos los códigos recibidos y encontramos el que se repita más veces // En la exploraci<EFBFBD>n obtenemos los c<EFBFBD>digos recibidos y encontramos el que se repita m<EFBFBD>s veces
string[] tempTriad = new string[3]; string[] tempTriad = new string[3];
string boxType = ""; string boxType = "";
string command = "BLOAD,"; string command = "BLOAD,";
string response = ""; string response = "";
Data element = null; Data element = null;
// Limpieza de códigos coincidentes cada lectura // Limpieza de c<EFBFBD>digos coincidentes cada lectura
foundCodes.Clear(); foundCodes.Clear();
for (int i = 0; i < individual_receivedData.Count(); i++) for (int i = 0; i < individual_receivedData.Count(); i++)
{ {
@@ -371,8 +374,6 @@ namespace ScaBox30
string found_code = keyOfMaxCount; string found_code = keyOfMaxCount;
element = Globals.actual_data.Find(x => x.CCE.Equals(found_code)); //Busca el elemento que coincide con el codigo -> obtiene fila con la informacion de la etiqueta element = Globals.actual_data.Find(x => x.CCE.Equals(found_code)); //Busca el elemento que coincide con el codigo -> obtiene fila con la informacion de la etiqueta
Console.WriteLine($"Buscando código: '{found_code}'");
Console.WriteLine($"Total registros en BD: {Globals.actual_data.Count}");
Globals.found_element = element; Globals.found_element = element;
} }
@@ -393,7 +394,7 @@ namespace ScaBox30
labelCapacity.Text = temp.Length > 2 ? temp.Substring(0, 2) : temp; labelCapacity.Text = temp.Length > 2 ? temp.Substring(0, 2) : temp;
// El layout no está programado en el scanner // El layout no est<EFBFBD> programado en el scanner
if (boxType == null) if (boxType == null)
{ {
ClearScreen(); ClearScreen();
@@ -405,12 +406,18 @@ namespace ScaBox30
{ {
int lineNumber = (new System.Diagnostics.StackFrame(0, true)).GetFileLineNumber(); int lineNumber = (new System.Diagnostics.StackFrame(0, true)).GetFileLineNumber();
Console.WriteLine("Ejecutando: {0} en la linea {1}", command, lineNumber + 2); Console.WriteLine("Ejecutando: {0} en la linea {1}", command, lineNumber + 2);
response = m_reader.ExecCommand(command); // En modo debug, no enviar comando al sensor
if (!Globals.debug)
{
response = m_reader.ExecCommand(command);
}
else
{
response = "OK"; // Simular respuesta
}
System.Threading.Thread.Sleep(Globals.cfg.interval); System.Threading.Thread.Sleep(Globals.cfg.interval);
} }
Console.WriteLine("[DEBUG] BLOAD completado, esperando 300ms para estabilización...");
System.Threading.Thread.Sleep(300); // El sensor necesita tiempo después de cambiar programa
response = ""; response = "";
@@ -433,7 +440,7 @@ namespace ScaBox30
response = ""; response = "";
} }
} }
//Console.WriteLine(command); Console.WriteLine(command);
} }
@@ -506,9 +513,6 @@ namespace ScaBox30
{ {
ok_count++; ok_count++;
labels_ok2[ordered_receivedData[i + 1].position].Visible = true; labels_ok2[ordered_receivedData[i + 1].position].Visible = true;
//labels_ok2[ordered_receivedData[i + 1].position].Text = "OK";
//labels_ok2[ordered_receivedData[i + 1].position].Text = ordered_receivedData[i + 1].position.ToString();
//labels_ok2[ordered_receivedData[i + 1].position].Text = Globals.cfg.resultado.Equals("number") ? ordered_receivedData[i + 1].position.ToString() : "OK" ;
switch (Globals.cfg.resultado) switch (Globals.cfg.resultado)
{ {
case "number": case "number":
@@ -532,9 +536,6 @@ namespace ScaBox30
{ {
bad_count++; bad_count++;
labels_ok2[ordered_receivedData[i + 1].position].Visible = true; labels_ok2[ordered_receivedData[i + 1].position].Visible = true;
//labels_ok2[ordered_receivedData[i + 1].position].Text = "X";
//labels_ok2[ordered_receivedData[i + 1].position].Text = ordered_receivedData[i + 1].position.ToString();
//labels_ok2[ordered_receivedData[i + 1].position].Text = Globals.cfg.resultado.Equals("number") ? ordered_receivedData[i + 1].position.ToString() : "X";
switch (Globals.cfg.resultado) switch (Globals.cfg.resultado)
{ {
case "number": case "number":
@@ -576,7 +577,7 @@ namespace ScaBox30
TgrBtn.Enabled = true; TgrBtn.Enabled = true;
//Change background color to red //Change background color to red
this.BackColor = Color.Red; this.BackColor = Color.Red;
DialogResult dialogResult = RJMessageBox.Show("Uno o más codigos son incorrectos!", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult dialogResult = RJMessageBox.Show("Uno o m<EFBFBD>s codigos son incorrectos!", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.BackColor = SystemColors.Control; this.BackColor = SystemColors.Control;
} }
@@ -588,7 +589,7 @@ namespace ScaBox30
TgrBtn.Enabled = true; TgrBtn.Enabled = true;
//Change background color to red //Change background color to red
this.BackColor = Color.Red; this.BackColor = Color.Red;
DialogResult dialogResult = RJMessageBox.Show("¿Desea realizar la prueba de nuevo?", "ScanBox", MessageBoxButtons.YesNo, MessageBoxIcon.Information); DialogResult dialogResult = RJMessageBox.Show("<EFBFBD>Desea realizar la prueba de nuevo?", "ScanBox", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
this.BackColor = SystemColors.Control; this.BackColor = SystemColors.Control;
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
@@ -627,7 +628,7 @@ namespace ScaBox30
} }
catch (IOException) catch (IOException)
{ {
RJMessageBox.Show("¡El archivo se encuentra abierto!\nCierre el archivo y repita la lectura.", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Warning); RJMessageBox.Show("<EFBFBD>El archivo se encuentra abierto!\nCierre el archivo y repita la lectura.", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
else else
@@ -684,7 +685,7 @@ namespace ScaBox30
} }
else else
{ {
RJMessageBox.Show("El opc no tiene un boxcapacity correcto. Por favor configúrelo en la base de datos primero y después repita la prueba.", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Stop); RJMessageBox.Show("El opc no tiene un boxcapacity correcto. Por favor config<EFBFBD>relo en la base de datos primero y despu<EFBFBD>s repita la prueba.", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Stop);
} }
save_data = false; save_data = false;
@@ -697,7 +698,7 @@ namespace ScaBox30
private void btnToogleMode_Click(object sender, EventArgs e) private void btnToogleMode_Click(object sender, EventArgs e)
{ {
DialogResult result = RJMessageBox.Show("Desea cambiar el modo de operación a " + (scanbox ? operation_mode.manual : operation_mode.automatico) + "?", "ScanBox", MessageBoxButtons.OKCancel); DialogResult result = RJMessageBox.Show("Desea cambiar el modo de operaci<EFBFBD>n a " + (scanbox ? operation_mode.manual : operation_mode.automatico) + "?", "ScanBox", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
@@ -714,7 +715,8 @@ namespace ScaBox30
{ {
//ESTABLECE EL MODO DE OPERACION A MANUAL (ESCANER 1D) //ESTABLECE EL MODO DE OPERACION A MANUAL (ESCANER 1D)
scanbox = false; scanbox = false;
TgrBtn.Enabled = false; // En modo manual, habilitar el bot<6F>n si debug est<73> activado o hay sensor
TgrBtn.Enabled = (Globals.debug || reader_connected) ? true : false;
UpdateTgrBtn(); UpdateTgrBtn();
KeyPreview = true; //Habilita el scanner 1d KeyPreview = true; //Habilita el scanner 1d
ActiveControl = barcode_lbl; ActiveControl = barcode_lbl;
@@ -744,9 +746,6 @@ namespace ScaBox30
//disable image clear timer //disable image clear timer
timer1.Enabled = false; timer1.Enabled = false;
//Disable button for re-clic and master barcode from being scanned //Disable button for re-clic and master barcode from being scanned
TgrBtn.Enabled = false; TgrBtn.Enabled = false;
UpdateTgrBtn(); UpdateTgrBtn();
@@ -763,8 +762,8 @@ namespace ScaBox30
// REFERENCIA DE COMANDOS UTILIZADOS OBTENIDOS DEL MANUAL // REFERENCIA DE COMANDOS UTILIZADOS OBTENIDOS DEL MANUAL
// LON -> Inicia la lectura // LON -> Inicia la lectura
// BLOAD -> Carga archivos de copia de seguridad // BLOAD -> Carga archivos de copia de seguridad
// RP -> Comando de configuración de operación // RP -> Comando de configuraci<EFBFBD>n de operaci<EFBFBD>n
// RP 215 -> Especificación de rango de captura de imagen // RP 215 -> Especificaci<EFBFBD>n de rango de captura de imagen
if (reader_found) if (reader_found)
{ {
@@ -772,7 +771,7 @@ namespace ScaBox30
string command = "BLOAD," + program; string command = "BLOAD," + program;
string response = ""; string response = "";
//Envía el comando hasta obtener una respuest //Env<EFBFBD>a el comando hasta obtener una respuest
while (response.Equals(string.Empty)) while (response.Equals(string.Empty))
{ {
int lineNumber = (new System.Diagnostics.StackFrame(0, true)).GetFileLineNumber(); int lineNumber = (new System.Diagnostics.StackFrame(0, true)).GetFileLineNumber();
@@ -809,16 +808,31 @@ namespace ScaBox30
//Dispose before closing Form for avoiding error. //Dispose before closing Form for avoiding error.
private void Form1_FormClosing(object sender, FormClosingEventArgs e) private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{ {
m_reader.Dispose(); m_reader?.Dispose();
m_searcher.Dispose(); m_searcher?.Dispose();
liveviewForm1.Dispose(); liveviewForm1?.Dispose();
} }
private Form CreateDataUIInstance()
{
// Use reflection to instantiate the Form type named "DataUI" (avoids compiler ambiguity if a generated resource class shares the name)
var asm = typeof(Principal).Assembly;
var dataUiType = asm.GetTypes().FirstOrDefault(t => t.Name == "DataUI" && typeof(Form).IsAssignableFrom(t));
if (dataUiType != null)
{
return Activator.CreateInstance(dataUiType) as Form;
}
return null;
}
private void btnBD_MouseClick(object sender, MouseEventArgs e) private void btnBD_MouseClick(object sender, MouseEventArgs e)
{ {
DataUI data = new DataUI(); var dataForm = CreateDataUIInstance();
data.ShowDialog(); if (dataForm != null)
{
dataForm.ShowDialog();
}
} }
@@ -920,7 +934,6 @@ namespace ScaBox30
string sr2000w_ip; string sr2000w_ip;
sr2000w_ip = Globals.cfg.ipscanner; sr2000w_ip = Globals.cfg.ipscanner;
if (reader_found) if (reader_found)
{ {
//Stop liveview. //Stop liveview.
@@ -1033,7 +1046,7 @@ namespace ScaBox30
{ {
sensor_ip_list.Add(ip); sensor_ip_list.Add(ip);
//if (ConfigurationManager.AppSettings.Get("sr2000w_ip") == ip) //if (ConfigurationManager.AppSettings.Get("sr2000w_ip") == ip)
if (Globals.cfg.ipscanner == ip) if ( Globals.cfg.ipscanner == ip)
{ {
sr2000w_ip_lbl.Text = ip; sr2000w_ip_lbl.Text = ip;
reader_found = true; reader_found = true;
@@ -1084,7 +1097,7 @@ namespace ScaBox30
Globals.cfg.usbprinter = "none"; Globals.cfg.usbprinter = "none";
Globals.cfg.ipprinter = "192.168.100.101"; Globals.cfg.ipprinter = "192.168.100.101";
Globals.cfg.printertype = "eth"; // Puede ser eth o usb Globals.cfg.printertype = "eth"; // Puede ser eth o usb
Globals.cfg.resultado = "label"; // Etiquetas mostradas en el layout (OK,X), Región ó (OK,X) + Región Globals.cfg.resultado = "label"; // Etiquetas mostradas en el layout (OK,X), Regi<EFBFBD>n <EFBFBD> (OK,X) + Regi<EFBFBD>n
Globals.cfg.printerenabled = true; Globals.cfg.printerenabled = true;
Globals.config.Clear(); Globals.config.Clear();
@@ -1112,8 +1125,25 @@ namespace ScaBox30
// | | // | |
// | | // | |
// -----------------* // -----------------*
// (c,d) // (c,d)
// En modo debug, no intentar leer del sensor
if (Globals.debug)
{
// Usar valores por defecto para debug
xLeftCornner = 0;
yLeftCornner = 0;
xScale = 1;
yScale = 1;
globalScale = 1;
imgWidth = liveviewForm1?.Bounds.Width ?? 800;
imgHeight = liveviewForm1?.Bounds.Height ?? 600;
xOffset = 0;
yOffset = 0;
return;
}
//Get LiveView Size for scale and scale from sensor using command RP,215 //Get LiveView Size for scale and scale from sensor using command RP,215
imageAreaStr = m_reader.ExecCommand("RP,215"); //Read captured image area imageAreaStr = m_reader.ExecCommand("RP,215"); //Read captured image area
//List<string> coordinates = (from Match m in Regex.Matches(imageAreaStr, @"\d{4}") select m.Value).Where(p => !string.IsNullOrEmpty(p)).ToList(); //List<string> coordinates = (from Match m in Regex.Matches(imageAreaStr, @"\d{4}") select m.Value).Where(p => !string.IsNullOrEmpty(p)).ToList();
@@ -1165,16 +1195,26 @@ namespace ScaBox30
if (Globals.cfg.printerenabled) if (Globals.cfg.printerenabled)
{ {
// Reset daily consecutive counter if day changed
if (Globals.consecDate.Date != DateTime.Today)
{
Globals.consec = 1;
Globals.consecDate = DateTime.Today;
}
string etiqueta = barcode_lbl.Text; string etiqueta = barcode_lbl.Text;
if (Globals.found_element.CCE == etiqueta) if (Globals.found_element.CCE == etiqueta)
{ {
String v1 = Globals.found_element.nom_1; String v1 = Globals.found_element.nom_1;
String v2 = Globals.found_element.@base + " / " + Globals.found_element.addition + " " + Globals.found_element.oeil; String v2 = Globals.found_element.@base + " / " + Globals.found_element.addition + " " + Globals.found_element.oeil;
String v3 = btnToogleMode.Text == operation_mode.manual ? "" : completa_parcial + " contiene: " + ok_count.ToString() + " de: " + Globals.found_element.Box_Capacity.Substring(0, 2); // Mostrar informaci<63>n en todos los modos (manual y scanbox)
String v3 = completa_parcial + ": " + ok_count.ToString() + " de " + Globals.found_element.Box_Capacity.Substring(0, 2);
String v4 = Globals.consec.ToString("D5"); //Numero consecutivo
DateTime v5 = DateTime.Now; //Fecha y hora de impresi<73>n
String barcode = Globals.found_element.CCE; String barcode = Globals.found_element.CCE;
ZT231.buildPrn(v1, v2, v3, barcode); ZT231.buildPrn(v1, v2, v3, v4, v5, barcode);
switch (Globals.cfg.printertype) switch (Globals.cfg.printertype)
{ {
@@ -1186,6 +1226,7 @@ namespace ScaBox30
break; break;
} }
} }
Globals.consec++;
} }
} }
@@ -1249,7 +1290,7 @@ namespace ScaBox30
{ {
if (result != DialogResult.Cancel) if (result != DialogResult.Cancel)
{ {
RJMessageBox.Show("No tiene permiso para realizar esta acción", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Warning); RJMessageBox.Show("No tiene permiso para realizar esta acci<EFBFBD>n", "ScanBox", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }

View File

@@ -124,7 +124,7 @@
<data name="blackimg_picbx.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="blackimg_picbx.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAA44AAAGLCAIAAAAHx1tZAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO iVBORw0KGgoAAAANSUhEUgAAA44AAAGLCAIAAAAHx1tZAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAABCxJREFUeF7twTEBAAAAwqD1T20Gf6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA wgAADsIBFShKgAAABCxJREFUeF7twTEBAAAAwqD1T20Gf6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -149,7 +149,7 @@
<value>105, 12</value> <value>105, 12</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>51</value> <value>25</value>
</metadata> </metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>

File diff suppressed because one or more lines are too long

View File

@@ -299,6 +299,8 @@
<EmbeddedResource Include="Usuario.resx"> <EmbeddedResource Include="Usuario.resx">
<DependentUpon>Usuario.cs</DependentUpon> <DependentUpon>Usuario.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<None Include="data.json" />
<None Include="GUIA_PRUEBAS_SIN_SENSOR.md" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@@ -329,6 +331,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\chat.png" /> <None Include="Resources\chat.png" />
<None Include="Resources\data.json" />
<None Include="Resources\error.png" /> <None Include="Resources\error.png" />
<None Include="Resources\exclamation.png" /> <None Include="Resources\exclamation.png" />
<None Include="Resources\information.png" /> <None Include="Resources\information.png" />

1
ScanBox/data.json Normal file

File diff suppressed because one or more lines are too long

1
data.json Normal file

File diff suppressed because one or more lines are too long