Bootstrap

台达DOP-100系列触摸屏(LUA程序编写用户管理应用)

前言

台达DOP-100系列的触摸屏全系内置的Lua程序开发环境,提供了一整套完善的用户的类。把之前我需要的功能也完善了。不错不错,欢迎各路看官可以试用。

正文

触摸屏效果图

Lua程序

--[[
地址交互
-$140.0 登录用户
-$140.1 创建用户
-$140.2 删除用户
-$140.3 变更用户名称
-$140.4 变更用户密码
-$140.5 变更用户权限
-$140.6 变更用户天数
-$140.7 变更密码天数
-$141 状态提示 
-$142 读取用户权限
-$143 读取用户状态
-$150 读取用户名称
-$155 读取用户密码
-$160 写入用户
-$165 写入用户新名称
-$170 写入用户密码
-$175 写入用户权限
-$176 写入用户天数
-$177 写入密码天数
]]

while true do
	--用户管理
    AccoutPage = screen.IsOpen(111) 
    if AccoutPage == 1 then 
        iGetCurrentLogin, StrName, iLevel = account.GetCurrentLogin()
        if iGetCurrentLogin == 1 then 
            mem.inter.WriteAscii(150, StrName, 8)
            mem.inter.Write(142, iLevel)
            iGetPassword, StrPassword = account.GetPassword(StrName)
            iGetStatus = account.GetStatus(StrName)
            if iGetStatus == 1 then 
               mem.inter.Write(143, 1)
            else
               mem.inter.Write(143, 0)
            end           
            if iGetPassword == 1 then 
                mem.inter.WriteAscii(155, StrPassword, 8)
            end           
        end

        StrAccount     = mem.inter.ReadAscii(160, 8)
        StrNewName     = mem.inter.ReadAscii(165, 8)
        StrNewPassword = mem.inter.ReadAscii(170, 8)
        iNewLevel      = mem.inter.Read(175)
        iNewUserDays   = mem.inter.Read(176)
        iNewPwdDays    = mem.inter.Read(177)
        bLoginAccout    = mem.inter.ReadBit(140, 0)
        bAddAccout      = mem.inter.ReadBit(140, 1)
        bSubAccout      = mem.inter.ReadBit(140, 2)
        bChangeName     = mem.inter.ReadBit(140, 3)
        bChangePW       = mem.inter.ReadBit(140, 4)
        bChangeLevel    = mem.inter.ReadBit(140, 5)        
        bChangeUserDays = mem.inter.ReadBit(140, 6)
        bChangePwdDays  = mem.inter.ReadBit(140, 7)
    
				bExist      = account.IsExist(StrAccount)
        --用户是否存在
        if bExist == 1 then 
            mem.inter.Write(141,9)--用户已存在,请登录
        end
    
        --登录用户    
        if (bLoginAccout == 1) then
            iLogin = account.Login(StrAccount, StrNewPassword)
            if (iLogin == 1) then
                mem.inter.Write(141,20)       --登录用户成功
                mem.inter.WriteBit(140, 0, 0) --复位登录按钮
            end           
        end
    
        --创建用户    
        if (bExist == 0) and (bAddAccout == 1) then 
            iAdd = account.Add(StrAccount, StrNewPassword, iNewLevel)
            if iAdd == 1 then
                mem.inter.Write(141,21)      --创建用户成功
                mem.inter.WriteBit(140, 1, 0)--复位创建按钮
            end
        end

        --删除用户
        if (bExist == 1) and (bSubAccout == 1) then 	
           iSub = account.Delete(StrAccount) 
            if iSub == 1 then
                mem.inter.Write(141,22)      --删除用户成功
                mem.inter.WriteBit(140, 2, 0)--复位删除按钮
            end
        end
        --变更用户名
        if (bChangeName == 1) then 	
           iChangeName = account.ChangeName(StrAccount, StrNewName) 
            if iChangeName == 1 then
                mem.inter.Write(141,23)      --变更用户名成功
                mem.inter.WriteBit(140, 3, 0)--复位变更用户名按钮
            end
        end
    
         --变更密码
        if (bChangePW == 1) then 	
           iChangePW = account.ChangePassword(StrAccount, StrNewPassword) 
            if iChangePW == 1 then
                mem.inter.Write(141,24)      --变更密码成功
                mem.inter.WriteBit(140, 4, 0)--复位变更密码按钮
            end
        end
    
       --变更权限
        if (bChangeLevel == 1) then 	
           iChangeLevel = account.ChangeLevel(StrAccount, iNewLevel) 
            if iChangeLevel == 1 then
                mem.inter.Write(141,25)      --变更密码成功
                mem.inter.WriteBit(140, 5, 0)--复位变更密码按钮
            end
        end

        --变更用户使用天数
        if (bChangeUserDays == 1) then 	
           iChangeUserDays = account.ChangeUserExpiredDays(StrAccount, iNewUserDays) 
            if iChangeUserDays == 1 then
                mem.inter.Write(141,26)      --变更密码成功
                mem.inter.WriteBit(140, 6, 0)--复位变更密码按钮
            end
        end

        --变更密码使用天数
        if (bChangePwdDays == 1) then 	
           iChangePwdDays = account.ChangePwdExpiredDays(StrAccount, iNewPwdDays) 
            if iChangePwdDays == 1 then
                mem.inter.Write(141,27)      --变更密码成功
                mem.inter.WriteBit(140, 7, 0)--复位变更密码按钮
            end
        end
    end   
end

通过上述程序可以看出使用Lua程序的便利性。

结尾

后期我还会继续把我一些常用的Lua程序分享出来给大家。