Задать вопрос
  • Какую SCADA систему используете?

    @erlashko
    SCADA engineer
    ребята к вам вопрос я только начинаю в сфере SCADA WinCC
    как написать Script VBS о опросе состоянии линий скажем определенного устройства по IP адресу
    и интегрировать его в график как линию чтоб при появлении связи горела зеленый всегда и при пропаданий он горел красный скажем через пинг опроса
    тег создал написал не большой скрипт но почему то не работает Sub CheckAllHosts()
    Dim i, result
    Dim ipAddresses(113)

    ' массив IP-адресами ЦДП
    ipAddresses(0) = "10.1.80.100"
    ipAddresses(1) = "10.1.90.100"

    ipAddresses(2) = "10.1.80.101"
    ipAddresses(3) = "10.1.90.101"

    ' массив IP-адресами ЛКУ
    ipAddresses(4) = "10.1.56.101"
    ipAddresses(5) = "10.1.65.101"

    ipAddresses(6) = "10.1.56.102"
    ipAddresses(7) = "10.1.65.102"

    ipAddresses(8) = "10.1.56.103"
    ipAddresses(9) = "10.1.65.103"

    ipAddresses(10) = "10.1.56.104"
    ipAddresses(11) = "10.1.65.104"

    ipAddresses(12) = "10.1.56.105"
    ipAddresses(13) = "10.1.65.105"

    ipAddresses(14) = "10.1.57.106"
    ipAddresses(15) = "10.1.66.106"

    ipAddresses(16) = "10.1.57.107"
    ipAddresses(17) = "10.1.66.107"

    ipAddresses(18) = "10.1.57.108"
    ipAddresses(19) = "10.1.66.108"

    ipAddresses(20) = "10.1.57.109"
    ipAddresses(21) = "10.1.66.109"

    ipAddresses(22) = "10.1.57.110"
    ipAddresses(23) = "10.1.66.110"

    ipAddresses(24) = "10.1.57.111"
    ipAddresses(25) = "10.1.66.111"

    ipAddresses(26) = "10.1.57.112"
    ipAddresses(27) = "10.1.66.112"

    ipAddresses(28) = "10.1.57.113"
    ipAddresses(29) = "10.1.66.113"

    ipAddresses(30) = "10.1.57.114"
    ipAddresses(31) = "10.1.66.114"

    ipAddresses(32) = "10.1.57.115"
    ipAddresses(33) = "10.1.66.115"

    ipAddresses(34) = "10.1.58.116"
    ipAddresses(35) = "10.1.67.116"

    ipAddresses(36) = "10.1.58.117"
    ipAddresses(37) = "10.1.67.117"

    ipAddresses(38) = "10.1.58.118"
    ipAddresses(39) = "10.1.67.118"

    ipAddresses(40) = "10.1.58.119"
    ipAddresses(41) = "10.1.67.119"

    ipAddresses(42) = "10.1.58.120"
    ipAddresses(43) = "10.1.67.120"

    ipAddresses(44) = "10.1.59.121"
    ipAddresses(45) = "10.1.68.121"

    ipAddresses(46) = "10.1.59.122"
    ipAddresses(47) = "10.1.68.122"

    ipAddresses(48) = "10.1.59.123"
    ipAddresses(49) = "10.1.68.123"

    ipAddresses(50) = "10.1.59.124"
    ipAddresses(51) = "10.1.68.124"

    ipAddresses(52) = "10.1.59.125"
    ipAddresses(53) = "10.1.68.125"

    ipAddresses(54) = "10.1.59.126"
    ipAddresses(55) = "10.1.68.126"

    ipAddresses(56) = "10.1.59.127"
    ipAddresses(57) = "10.1.68.127"

    ipAddresses(58) = "10.1.59.128"
    ipAddresses(59) = "10.1.68.128"

    ipAddresses(60) = "10.1.59.129"
    ipAddresses(61) = "10.1.68.129"

    ipAddresses(62) = "10.1.59.130"
    ipAddresses(63) = "10.1.68.130"

    ipAddresses(64) = "10.1.60.131"
    ipAddresses(65) = "10.1.69.131"

    ipAddresses(66) = "10.1.60.132"
    ipAddresses(67) = "10.1.69.132"

    ipAddresses(68) = "10.1.60.133"
    ipAddresses(69) = "10.1.69.133"

    ipAddresses(70) = "10.1.60.134"
    ipAddresses(71) = "10.1.69.134"

    ipAddresses(72) = "10.1.60.135"
    ipAddresses(73) = "10.1.69.135"

    ipAddresses(74) = "10.1.60.136"
    ipAddresses(75) = "10.1.69.136"

    ipAddresses(76) = "10.1.60.137"
    ipAddresses(77) = "10.1.69.137"

    ipAddresses(78) = "10.1.60.138"
    ipAddresses(79) = "10.1.69.138"

    ipAddresses(80) = "10.1.60.139"
    ipAddresses(81) = "10.1.69.139"

    ipAddresses(82) = "10.1.60.140"
    ipAddresses(83) = "10.1.69.140"

    ' массив IP-адресами НПС8
    ipAddresses(84) = "10.1.8.70"
    ipAddresses(85) = "10.1.108.70"

    ipAddresses(86) = "10.1.8.72"
    ipAddresses(87) = "10.1.108.72"

    ipAddresses(88) = "10.1.8.73"
    ipAddresses(89) = "10.1.108.73"

    ' массив IP-адресами НПС9
    ipAddresses(90) = "10.1.9.70"
    ipAddresses(91) = "10.1.109.70"

    ipAddresses(92) = "10.1.9.72"
    ipAddresses(93) = "10.1.109.72"

    ipAddresses(94) = "10.1.9.73"
    ipAddresses(95) = "10.1.109.73"

    ' массив IP-адресами НПС10
    ipAddresses(96) = "10.1.10.70"
    ipAddresses(97) = "10.1.110.70"

    ipAddresses(98) = "10.1.10.72"
    ipAddresses(99) = "10.1.110.72"

    ipAddresses(100) = "10.1.10.73"
    ipAddresses(101) = "10.1.110.73"

    ' массив IP-адресами НПС11
    ipAddresses(102) = "10.1.11.70"
    ipAddresses(103) = "10.1.111.70"

    ipAddresses(104) = "10.1.11.72"
    ipAddresses(105) = "10.1.111.72"

    ipAddresses(106) = "10.1.1.73"
    ipAddresses(107) = "10.1.111.73"

    ' массив IP-адресами Алашанькоу
    ipAddresses(108) = "10.1.20.70"
    ipAddresses(109) = "10.1.120.70"

    ipAddresses(110) = "10.1.20.72"
    ipAddresses(111) = "10.1.120.72"

    ' массив IP-адресами КТО
    ipAddresses(112) = "121.0.0.0"
    ipAddresses(113) = "121.0.0.0"


    For i = 0 To UBound(ipAddresses)
    result = PingHost(ipAddresses(i))
    SmartTags("Line" & (i + 1) & "Status") = result ' Сохранение результат в тег
    Next
    End Sub

    Function PingHost(Host)
    Dim ws, res
    Set ws = CreateObject("WScript.Shell")
    res = ws.Run("ping -n 1 " & Host, 0, True)
    If res = 0 Then
    PingHost = True
    Else
    PingHost = False
    End If
    Set ws = Nothing
    End Function
    Ответ написан
    Комментировать