Skip to content

Commit

Permalink
Set correct channel type for channels (#39)
Browse files Browse the repository at this point in the history
* Set correct type of Channel

* Update Version

* Fix Lint

* Revert test change
  • Loading branch information
dkleber89 committed Jan 25, 2021
1 parent c37d594 commit 12ed99b
Show file tree
Hide file tree
Showing 6 changed files with 475 additions and 545 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018-2020 dkleber89 <dkleber89@gmail.com>
Copyright (c) 2018-2021 dkleber89 <dkleber89@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Upload your *.tpy File from your PLC Project -> Every Time you change something
3. Sync never meant the Dataexchange of the Symbols. Sync is the create or delete the States in ioBroker dependent on the GlobalVariableTable in the PLC.

## Changelog
### 1.3.0 (2021-01-25)

- (dkleber89) Set correct type for channels

### 1.2.2 (2020-05-30)

- (dkleber89) Clear reconnectTimeout on Adapter unload;
Expand Down Expand Up @@ -109,17 +113,11 @@ Upload your *.tpy File from your PLC Project -> Every Time you change something

- (dkleber 89) Stable Release, Update Gulp, add new Translations

### 0.3.0 (2019-03-09)

- (Appollon77) Core Files/Testing Update and introduce adapter-core
- (dkleber89) Fix Problem 'write after End'


## License

The MIT License (MIT)

Copyright (c) 2018-2020 dkleber89 <dkleber89@gmail.com>
Copyright (c) 2018-2021 dkleber89 <dkleber89@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 13 additions & 13 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
{
"common": {
"name": "beckhoff",
"version": "1.2.2",
"version": "1.3.0",
"news": {
"0.3.0": {
"en": "New Core- and Testfiles from Apollon77 and fix 'write after end'. Issue #2",
"de": "Neue Core- and Testfiles von Apollon77 und Lösung für das 'write after end' Problem. Issue #2",
"ru": "Новое ядро - и Testfiles от Apollon77 и исправить 'писать после конца'. Выпуск #2",
"pt": "Novo Núcleo - e Testfiles de Apollon77 e correção 'de gravação após o final'. Edição #2",
"nl": "Nieuwe Kern - en Testfiles van Apollon77 en fix 'schrijf na het einde'. Probleem #2",
"fr": "Les nouveaux Core - et Testfiles de Apollon77 et réparer \"écrire après la fin\". Question #2",
"it": "Nuovo Core - e Testfiles da Apollon77 e fix 'scrivere dopo la fine'. Problema #2",
"es": "Nuevo Núcleo - y Testfiles de Apollon77 y arreglar \"escribir después de la final\". Problema #2",
"pl": "Nowe jądro - Smsd od Apollon77 i naprawić 'pisać po końca'. Odcinek #2",
"zh-cn": "新的核心和Testfiles从Apollon77和修复写信之后结束的。 第2个问题"
},
"1.0.0": {
"en": "Stable Release, Update Gulp, add new Translations",
"de": "Stable-Release, Update Gulp, hinzufügen neuer Übersetzungen",
Expand Down Expand Up @@ -146,6 +134,18 @@
"es": "Borrar reconectTimeout en la descarga del adaptador",
"pl": "Wyczyść reconnectTimeout przy rozładowaniu adaptera",
"zh-cn": "清除适配器卸载时的reconnectTimeout"
},
"1.3.0": {
"en": "Set correct type for channels",
"de": "Korrekten type für die Channels setzen",
"ru": "Установите правильный тип для каналов",
"pt": "Defina o tipo correto de canais",
"nl": "Stel het juiste type kanalen in",
"fr": "Définir le type correct pour les chaînes",
"it": "Imposta il tipo corretto per i canali",
"es": "Establecer el tipo correcto de canales",
"pl": "Ustaw prawidłowy typ kanałów",
"zh-cn": "为频道设置正确的类型"
}
},
"title": "Beckhoff TwinCat ADS",
Expand Down
50 changes: 30 additions & 20 deletions lib/createObjectsAndHandles.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,31 +150,41 @@ module.exports = (adsC, adapter) => {
statename = `plc.${item.symname}`;
}

const channelname = statename.slice(0, statename.lastIndexOf('.'));

adapter.setObjectNotExists(
statename,
channelname,
{
type: 'state',
common: {
type,
role,
def,
name: symbolName,
read: true,
write: true,
},
native: { bytelength: item.bytelength },
type: 'channel',
},
() => {
// When State is created then register handler for value changing on PLC
adapter.log.debug(`Send Subscription for: ${item.symname} to PLC`);

adsC.notify(item, err => {
if (err) {
adapter.log.warn(`Subscription for: ${item.symname} occure an Error: ${err}`);
} else {
adapter.log.debug(`Subscription for: ${item.symname} done.`);
adapter.setObjectNotExists(
statename,
{
type: 'state',
common: {
type,
role,
def,
name: symbolName,
read: true,
write: true,
},
native: { bytelength: item.bytelength },
},
() => {
// When State is created then register handler for value changing on PLC
adapter.log.debug(`Send Subscription for: ${item.symname} to PLC`);

adsC.notify(item, err => {
if (err) {
adapter.log.warn(`Subscription for: ${item.symname} occure an Error: ${err}`);
} else {
adapter.log.debug(`Subscription for: ${item.symname} done.`);
}
});
}
});
);
}
);
}
Expand Down
Loading

0 comments on commit 12ed99b

Please sign in to comment.