[IGN-11942] When working with a dataset type, date values are lost when restarting the computer

Hello everyone,

I am working with dataset memory tags with four columns, the first of which is a date type with the index “DATE” storing a date. When I restart my machine, I have noticed that the values allocated in this column are blank. I have no idea what could be causing this. I will share the script I am using to write this data to my columns.

def onScheduledEvent():
    # Caminho do tag
    pathDataset = "[edge]Plant/Prod_Data/TAG_B_TESTE"

    # Ler o dataset atual
    datasetAtual = system.tag.readBlocking([pathDataset])[0].value
    pyDataset = system.dataset.toPyDataSet(datasetAtual)

    # Leitura dos valores dos tags
    wt01 = system.tag.readBlocking(["[edge]Ramp/Ramp1"])[0].value
    wt02 = system.tag.readBlocking(["[edge]Ramp/Ramp4"])[0].value
    wt03 = system.tag.readBlocking(["[edge]Ramp/Ramp7"])[0].value
    dataAtual = system.date.now()

    # Criar lista de linhas
    linhas = []
    for linha in pyDataset:
            linhas.append([linha["DATE"], linha["WT01"], linha["WT02"], linha["WT03"]])

    # Adicionar nova linha com data válida
    linhas.append([dataAtual, wt01, wt02, wt03])

    # Cabeçalhos
    colunas = ["DATE", "WT01", "WT02", "WT03"]

    # Criar novo dataset
    novoDataset = system.dataset.toDataSet(colunas, linhas)

    # Escrever no tag
    system.tag.writeBlocking([pathDataset], [novoDataset])

As transistor said, you need to format code properly for us to be and to read it properly.

That said, I have a few remarks already:

  • batch tag reads
  • You should be using the built-in addRow function, it would make the whole thing much simpler
  • we need to know more about the script context: what triggers it ?
1 Like

Hi @pascal.fragnoud

I updated the code block to be formatted correctly. The trigger for it is a Scheduled Gateway designed to record the date every hour.

I condenced your code. I also changed it to use the addRow function. Try it and see if you have better results.

def onScheduledEvent():
    # Caminhos de tag
    caminhos = ["[edge]Plant/Prod_Data/TAG_B_TESTE","[edge]Ramp/Ramp1","[edge]Ramp/Ramp4","[edge]Ramp/Ramp7"]

    # Leia todos os valores de tags em uma única chamada
    datasetAtual,wt01,wt02,wt03 = [qv.value for qv in system.tag.readBlocking(caminhos)]

	# Obtenha a data atual
    dataAtual = system.date.now()

    # adicionar linha ao conjunto de dados
    novoDataset = system.dataset.addRow(datasetAtual,[dataAtual,wt01,wt02,wt03])

    # Escrever para marcar
    system.tag.writeBlocking([pathDataset], [novoDataset])
1 Like

I think the 2nd parameter to addRow should be a simple list, instead of a list of lists.
addRows would take a list of lists.

2 Likes

Yep, that's what I get for not looking.

I tried both methods, addRow and addRows, and neither of them worked for me.

The data was saved, but when restarting the machine, the date column still appears blank as if nothing had been saved in the history.

Before turning off the computer:

After turning off the computer:

There must be something about that column’s type, since the other one are just fine.
Can you try adding a new column of type datetime and see if it does the same thing ?

Or add a column of type string and typecast the date into it, to see if it’s a type issue or data missing issue.

What computer are you turning off?

The computer I am turning off is mine, which hosts the Gateway and Designer

What happens if you only restart the gateway ?

Are there any errors in the gateway logs? Upload the wrapper log if you're not sure.

@pascal.fragnoud

Due to restrictions at the company where I work, it seems that the gateway reset commands are disabled. I was denied access when executing the commands.

”Acesso negado” = “Access denied”

@paul-griffith

I did not encounter any errors when registering the gateway.
everything seems to be fine

Run the command prompt as administrator…or navigate to the shutdown/startup short cuts, right click and run as administrator

@robertm

The administrator privileges are blocked on this machine. I am restarting the gateway “manually” by resetting the computer.

I tested it with a column defined “DATE_TEST_STRING" as a string type to see if the data would be lost.

before restarting the machine

after restarting the machine

Except that values don’t seem to be making it to the internal DB.

I’m not sure what registering the gateway has to do with your issue. That was not the question that Paul asked.

Something appears to be interfearing with a memory tag persisting its value, so I at least would expect there to be some type of error, even if it’s only listed in the wrapper log.

Upload a copy of your wrapper log. If you don’t know where to get that, then ask that question.

What locale is being used on your system?

Edit: If you are running into the bug I think you are then the workaround would be to set the gateway’s language to English by adding this additional parameter to the ignition.conf file. Just make sure you replace the X with the next available integer according to your .conf file.

wrapper.java.additional.X=-Duser.language=en

1 Like

So the data is there, just some issue with persistence on date_time type.